Requirements:
- One line query through uri.
- Filtering
- Sorting
- Limitation
- Partial fetching
- Fetching linked resources
- Normalized response
- Bulk requests
- Metadata discovery
URI special symbols (encoded by encodeURIComponent
but not encodeURI
): =
, @
, #
, $
, &
, +
, ;
, :
, ,
, /
, ?
.
Common query string format: pairs separated by &
, key and value separated by =
.
Common path format: chunks sparated by /
.
:
can't be used in first chunk of path. Repeated ?
and #
may be escaped by some libs.
So mostly safe symbols: =
, @
, $
, &
, +
, ;
, ,
, /
.
Symbols that can be used in the path in any place, escaped by encodURIComponent, but not escaped by ChromeDev Tools: /
, @
, $
, &
, +
, =
, [
, ]
, ;
, ,
.
Examples:
/
- metadata of all types/user=jin,john[name][age]
- name and age of users by primary key/user[sex=male,female][age=&18,20,40&50,100&][role@admin]
- sex, age and role of users by filter:male
orfemale
but nottrans
, and not admin, with age <=18, age = 20, 40 <= age <= 50, age >= 100/user[+birthday=2000-01-01&][-created][&10]
- 10 users with birthday from2000-01-01
sorted by birthday asc then created desc/user[name][friend[name][-age=18&][&10]]
- users with names and 10 older friends with names and ages that have age > 18/user=jin[friend[name]],article=hello[liker[name]]
- all "jin" friend names and "hello" liker names, without users data dublication
Syntax:
- Field name:
user
,article
etc. - Order field predicate:
+
- asc,-
- desc. - Fetch modifier:
[field]
- additinal fetch of this field,[10&20]
- slice part of list - Predicates for filtering:
=
- positive,@
- negative - Lists:
1,2,3
- Range:
1&5
- between,1&
- greated then or equal,&5
- lower then or equal,3
- only this value