Skip to content
John McArthur edited this page Mar 22, 2023 · 9 revisions

Welcome to the REST-Parser wiki!

Filters

Services that support $filter SHOULD support the following minimal set of operations.

Operator Description Example
Comparison Operators
eq Equal city[eq]=Redmond
ne Not equal city[ne]=London
gt Greater than price[gt]=20
ge Greater than or equal price[ge]=10
lt Less than price[lt]=20
le Less than or equal price[le]=100
contains contains the value surname[contains]=Mac

request examples

GET /items?surname[eq]smith

Sorting

Request examples

GET /items?$sort_by=surname
GET /items?$sort_by[asc]=surname
GET /items?$sort_by[desc]=surname
GET /items?$sort_by[asc]=surname&sort_by[desc]=firstname

Pagination

Standard

Request

GET /items?$page=2&$pageSize=10

Result

{
    "data" : [
        {  data item 1 with all relevant fields    },
        {  data item 2   },
        ...
        {  data item 10 }
    ],
    "Pagination": {
        "PageNumber": 1,
        "PageSize": 10,
        "PageCount": 1,
        "TotalCount": 9
    }
}

Putting it all together

GET /items?surname[contains]=Smi&hometown[eq]=Edinburgh&$sort_by[asc]=surname&sort_by[desc]=firstname&$page=1&$pageSize=10

TO BE ADDED AT A LATER DATE

Return Previous/Next links in paging

    "Pagination":  {
        "Previous":  "http://api.example.com/items/$page=1&$pageSize=10", 
        "Next":  "http://api.example.com/items/$page=3&$pageSize=10",
        "PageNumber": 1,
        "PageSize": 10,
        "PageCount": 1,
        "TotalCount": 9
    }

Recordset count

Developers who want to know the full number of records across all pages, MAY include the query parameter $count=true to tell the server to include the count of items in the response.

Request

GET /items?$count=true

Result

   {
       "data" : [
           {  data item 1 with all relevant fields    },
           {  data item 2   },
           ...
           {  data item 45 }
       ],
       "Pagination":  {
           "TotalCount": 45
       }
   }