API Responses: Difference between revisions
(4 intermediate revisions by the same user not shown) | |||
Line 29: | Line 29: | ||
If you wish to restrict to multiple values you can use the special term "$in" or "$nin" (not in) like so: | If you wish to restrict to multiple values you can use the special term "$in" or "$nin" (not in) like so: | ||
Display_Name[$in][]=A&Display_Name[$in][]=I,B&Display_Name[$in][]=R | Display_Name[$in][]=A&Display_Name[$in][]=I,B&Display_Name[$in][]=R | ||
For example: | |||
'''curl -X GET -H "Content-Type: application/json" -H "authorization: <api_key>" "<nowiki>https://api.thedog.io/dictionary?Display_Name[$in][]=A&Display_Name[$in][]=I,B&Display_Name[$in][]=R</nowiki>"''' | '''curl -X GET -H "Content-Type: application/json" -H "authorization: <api_key>" "<nowiki>https://api.thedog.io/dictionary?Display_Name[$in][]=A&Display_Name[$in][]=I,B&Display_Name[$in][]=R</nowiki>"''' | ||
or | or | ||
Line 43: | Line 44: | ||
etc | etc | ||
For example: | |||
'''curl -X GET -H "Content-Type: application/json" -H "authorization: <api_key>" "<nowiki>https://api.thedog.io/dictionary?Dictionary_no[$lt]=43</nowiki>"''' | '''curl -X GET -H "Content-Type: application/json" -H "authorization: <api_key>" "<nowiki>https://api.thedog.io/dictionary?Dictionary_no[$lt]=43</nowiki>"''' | ||
or | or | ||
Line 59: | Line 61: | ||
or | or | ||
'''curl -X GET -H "Content-Type: application/json" -H "authorization: <api_key>" "<nowiki>https://api.thedog.io/dictionary?%24or%5BDisplay_Name%5D%5B%24search%5D=5L37&%24or%5BDisplay_Name%5D%5B%24search%5D=5L38</nowiki>"''' | '''curl -X GET -H "Content-Type: application/json" -H "authorization: <api_key>" "<nowiki>https://api.thedog.io/dictionary?%24or%5BDisplay_Name%5D%5B%24search%5D=5L37&%24or%5BDisplay_Name%5D%5B%24search%5D=5L38</nowiki>"''' | ||
==== Microsoft Azure ==== | |||
When integrating the API with Microsoft Azure data pipelines there is an additional parameter that can be of assistance. The response from our API is a JSON object with a key called "data" which contains an array of objects. Azure instead wants the response to simply be that array of objects only. So in order to force the Golden Retriever API to return the data in the format expected by Azure add the URL parameter $azure=1 | |||
For example: | |||
'''curl -X GET -H "Content-Type: application/json" -H "authorization: <api_key>" "<nowiki>https://api.thedog.io/dictionary?$azure=1</nowiki>"''' | |||
or | |||
'''curl -X GET -H "Content-Type: application/json" -H "authorization: <api_key>" "<nowiki>https://api.thedog.io/dictionary?%24azure=1</nowiki>"''' |
Latest revision as of 16:37, 22 December 2023
Pagination
By default, the results will be paginated in pages of 10 results. To change the amount of results per page (the limit) or the amount of records to skip (the skip) you would add additional URL parameters, beginning with a $ (or %24 when URL encoded)
curl -X GET -H "Content-Type: application/json" -H "authorization: <api_key>" "https://api.thedog.io/dictionary?$limit=2&$skip=6"
or
curl -X GET -H "Content-Type: application/json" -H "authorization: <api_key>" "https://api.thedog.io/dictionary?%24limit=2&%24skip=6"
This will grab two records starting on the 7th record.
Sorting
You can also sort the records by one of the field names by using the following format:
$sort[CreatedOn]=asc (or when URL encoded: %24sort%5BCreatedOn%5D=asc)
curl -X GET -H "Content-Type: application/json" -H "authorization: <api_key>" "https://api.thedog.io/dictionary?$sort[CreatedOn]=asc"
or
curl -X GET -H "Content-Type: application/json" -H "authorization: <api_key>" "https://api.thedog.io/dictionary?%24sort%5BCreatedOn%5D=asc"
You can either use "asc" or "desc" for the direction of the sort.
Filtering Results
If you wish to restrict to multiple values you can use the special term "$in" or "$nin" (not in) like so:
Display_Name[$in][]=A&Display_Name[$in][]=I,B&Display_Name[$in][]=R
For example:
curl -X GET -H "Content-Type: application/json" -H "authorization: <api_key>" "https://api.thedog.io/dictionary?Display_Name[$in][]=A&Display_Name[$in][]=I,B&Display_Name[$in][]=R"
or
curl -X GET -H "Content-Type: application/json" -H "authorization: <api_key>" "https://api.thedog.io/dictionary?Display_Name%5B%24in%5D%5B%5D=A&Display_Name%5B%24in%5D%5B%5D=I,B&Display_Name%5B%24in%5D%5B%5D=R"
You can also use greater than, greater than or equal to, less than, etc
Dictionary_no[$gte]=55 Dictionary_no[$lt]=43 Dictionary_no[$eq]=55 Dictionary_no[$ne]=55 etc
For example:
curl -X GET -H "Content-Type: application/json" -H "authorization: <api_key>" "https://api.thedog.io/dictionary?Dictionary_no[$lt]=43"
or
curl -X GET -H "Content-Type: application/json" -H "authorization: <api_key>" "https://api.thedog.io/dictionary?Dictionary_no%5B%24lt%5D=43"
Search
Lastly we also have the ability to search for a substring in a field:
$or[Display_Name][$search]=5L37 $or[Display_Name][$search]=5L38
For example:
curl -X GET -H "Content-Type: application/json" -H "authorization: <api_key>" "https://api.thedog.io/dictionary?$or[Display_Name][$search]=5L37&$or[Display_Name][$search]=5L38"
or
curl -X GET -H "Content-Type: application/json" -H "authorization: <api_key>" "https://api.thedog.io/dictionary?%24or%5BDisplay_Name%5D%5B%24search%5D=5L37&%24or%5BDisplay_Name%5D%5B%24search%5D=5L38"
Microsoft Azure
When integrating the API with Microsoft Azure data pipelines there is an additional parameter that can be of assistance. The response from our API is a JSON object with a key called "data" which contains an array of objects. Azure instead wants the response to simply be that array of objects only. So in order to force the Golden Retriever API to return the data in the format expected by Azure add the URL parameter $azure=1
For example:
curl -X GET -H "Content-Type: application/json" -H "authorization: <api_key>" "https://api.thedog.io/dictionary?$azure=1"
or
curl -X GET -H "Content-Type: application/json" -H "authorization: <api_key>" "https://api.thedog.io/dictionary?%24azure=1"