Querying Data
Overview
The base URL for the DeliveryGo API is https://api.istrada.net/api.
INFO
The DeliveryGo API is built on top of the LoopBack framework. For detailed documentation on querying data, see the LoopBack / Querying data documentation.
A query is a read operation on models that returns a set of data or results. You can query data using filters, as outlined in the following table. Filters specify criteria for the returned data set.
| Query | REST API |
|---|---|
Find all model instances using specified filters.
|
See Filters below. |
| Find first model instance using specified filters. |
See Filters below. |
| Find instance by ID. |
|
A query must include the literal string "filter" in the URL query string.
TIP
If you are trying query filters with curl, use the -g or --globoff option to use brackets [ and ] in request URLs.
DeliveryGo API supports the following kinds of filters:
Examples
An example query with both a where and a limit filter:
https://api.istrada.net/api/customers?filter[where][name]=John&filter[limit]=3
See additional examples of each kind of filter in the individual articles on filters (for example Where filter).
Filters
You can use any number of filters to define a query.
DeliveryGo API supports a specific filter syntax: it's a lot like SQL, but designed specifically to serialize safely without injection and to be native to JavaScript.
The following table describes DeliveryGo API filter types:
| Filter type | Type | Description |
|---|---|---|
| fields | Object, Array, or String | Specify fields to include in or exclude from the response. See Fields filter. |
| include | String, Object, or Array | Include results from related models. See Include filter. |
| limit | Number | Limit the number of instances to return. See Limit filter. |
| order | String | Specify sort order: ascending or descending. See Order filter. |
| skip (offset) | Number | Skip the specified number of instances. See Skip filter. |
| where | Object | Specify search criteria; similar to a WHERE clause in SQL. See Where filter. |
REST syntax
Specify filters in the HTTP query string:
?filter_filterType_=_spec_&_filterType_=_spec_....
The number of filters that you can apply to a single request is limited only by the maximum URL length, which generally depends on the client used.
WARNING
There is no equal sign after ?filter in the query string; for example /api/devices?filter[where][id]=1
INFO
See https://github.com/hapijs/qs for more details.
Using "stringified" JSON in REST queries
Instead of the standard REST syntax described above, you can also use "stringified JSON" in REST queries, as follows:
?filter={ Stringified-JSON }
WARNING
When using stringified JSON, you must use an equal sign after ?filter in the query string.
For example: https://api.istrada.net/api/projects?filter={%22where%22:{%22id%22:2}}
For example: GET https://api.istrada.net/api/projects/findOne?filter={"where":{"id":1234}}