rest api queries

With queries you can retrieve an array of objects by sending a GET request to the class URL. You can also send conditions in the request so the objects that you get are filtered.

In the following example we will use our Car table and send a query with the following conditions: 

{car_year": "2019","car_model":"BMW"}

By default, conditions are used with an "and" operator so the results should be and array of  BMW cars from 2019.

In the Header we will add 3 parameters:

1. X-Parse-Application-Id: your application Id

2. X-Parse-Session-Token: your session token (You can use an API-K  X-PARSE-API-KEY instead)

3. Content-Type: application/json 

Our URL will be:

https://apps.simbla.com/parse/classes/Cars/?where={"car_year": "2019","car_model":"BMW"}



The results are array of Cars from 2019 and their car_model is BMW.


Query Operators

Our API supports these comparison options:


Option

Description

Example

$lt

Less Than

{"car_year": {"$lt":2018}}

Retrieve cars from year lest than 2018

$lte

Less Than Or Equal To

{"car_year": {"$lte":2018}}

Retrieve cars from year lest than or equal to 2018

$gt

Greater Than

{"car_year": {"$gt":2018}}

Retrieve cars from year greater than 2018

$gte

Greater Than Or Equal To

{"car_year": {"$gte":2018,"$lte":2019}}

Retrieve cars from year greater than or equal to 2018 and less than or equal to 2019

$ne

Not Equal To

{"car_year": {"$ne":2019},"car_model":{"$ne":"BMW"}}

Retrieve cars that are not from 2019 and not BMW

$in

Contained In

{"car_year": {"$in":[2018,2019]},"car_model":{"$in":["BMW","Fiat"]}}

Retrieve Fiat and BMW cars from 2018 and 2019

$nin

Not Contained in

{"car_year": {"$nin":[2018,2019]},"car_model":{"$nin":["BMW","Fiat"]}}

Retrieve cars that are not Fiat and BMW and not from 2018 and 2019

$exists

A value is set

{"car_color":{"$exists":true}}

Retrieve all cars that has a defined color

$select

select

{"car_color":{"$select":{"query":{"className":"Bikes","where":{"bike_year":{"$gt":2016}}},"key":"bike_color"}}}

Retrieve all records from Cars that their color match a key result – bike color of a given subquery.

$dontSelect

Don’t select

{"car_color":{"$select":{"query":{"className":"Bikes","where":{"bike_year":{"$gt":2016}}},"key":"bike_color"}}}

Retrieve all records from Cars that their color not in a key result – bike color of a given subquery.

$all

All

{"categories":{"$all":[1,3,5]}}

Retrieve all records with an array field which contains all of the values in the query

$regex

            Regular expression

{"car_model":{"$regex":"^BM"}}

Retrieve all records that starts with "BM"


$or

  or


{"$or":[{"car_year":"2018"},{"car_model":"Fiat"}]}


Retrieve all car from 2018 or their model is Fiat



Query Parameters:

Order results by car year descending and then car_color ascending

Order=-car_year,car_color

Specify a field to sort by

order

Limit results to 10 records

order=car_color&Limit=10

Limit the number of objects returned by the query

limit

Skip 10 results. This can be used for paging

order=car_color&Limit=10& skip=10

Use with limit to paginate through results

skip

Return only the following Keys in the results

Keys=car_color

Restrict the fields returned by the query

keys

Include pointer table

Include=Color

Use on Pointer columns to return the full object

include