All model relations can be conditionally loaded using the include
query parameter.
include=topics
If a model has multiple relationships, each can be included with a ,
separator
include=user,questions,topic
Only white-listed relations are enabled. relationships not white-listed will be ignored.
?filter[level]=CXC or filter[level][value]=CXC
{
"method": "get",
"url": "https://api.edufocal.net/v1/subjects?filter[level]=CXC"
}
or
{
"method": "get",
"url": "https://api.edufocal.net/v1/subjects?filter[level][value]=CXC"
}
For more complex queries you may need to filter multiple fields from the same resource. To support this behaviour we can use the format
filter[`insert_label_here`][condition][path]=level // field to filter
filter[`insert_label_here`][condition][value]=cxc // field value
filter[`insert_label_here`][condition][operator]=eq //operator
where _insert_label_here
is any uniquely matching label
Lets say we want to find all subjects whos level
field contains a term looking like cxc
and where their ids are greater than 60. Of course we want to also include their topics
relation as well as limiting our results to only 4 items.
include=topics
limit=4
filter[level-filter][condition][path]=level // field to filter
filter[level-filter][condition][value]=cxc // field value
filter[level-filter][condition][operator]=like //operator
filter[id-filter][condition][path]=id // field to filter
filter[id-filter][condition][value]=60 // field value
filter[id-filter][condition][operator]= > //operator
which would map out to
{
"method": "get",
"url": "https://api.edufocal.net/v1/subjects?limit=4&include=topics&filter[level-filter][condition][path]=level&filter[level-filter][condition][value]=cxc&filter[level-filter][condition][operator]=like&filter[id-filter][condition][path]=id&filter[id-filter][condition][value]=60&filter[id-filter][condition][operator]=gt"
}
{
"subjects": [
{
"id": 63,
"name": "Sit hic sint.",
"abbrev": "corrupti",
"permalink": "magnam",
"level": "CXC",
"rank": 1,
"active": 1,
"icon": "Et perspiciatis rem.",
"level_id": "PEP6",
"topics": []
},
{
"id": 64,
"name": "Corporis.",
"abbrev": "exercitationem",
"permalink": "temporibus",
"level": "CXC",
"rank": 1,
"active": 1,
"icon": "Eum sunt ipsam.",
"level_id": "PEP6",
"topics": []
},
{
"id": 65,
"name": "Quo.",
"abbrev": "et",
"permalink": "eius",
"level": "CXC",
"rank": 1,
"active": 1,
"icon": "Consequatur et non.",
"level_id": "PEP5",
"topics": []
},
{
"id": 67,
"name": "Assumenda.",
"abbrev": "voluptatem",
"permalink": "dolorem",
"level": "CXC",
"rank": 1,
"active": 1,
"icon": "Consequatur.",
"level_id": "PEP4",
"topics": []
}
],
"cursor": {
"starting_at": "aWQ9NjgsbGltaXQ9NA=="
}
}
WHERE <
WHERE <=
WHERE >
WHERE >=
WHERE =
WHERE like %{some term}%
OR WHERE =
path
and value
are required for all filtering
formats to work.filters
will be applied, all others will be ignored.For Resources that allow filtering there also exists the capability to sort allowed field names.
Example
?sort[id]=desc
?sort[id]=asc