Docs / Options
Response Format
Choose how Gurdx encodes the response: JSON, XML, CSV or plain newline-separated values.
The format parameter#
Add format to any request. The value is case-insensitive and defaults to JSON.
| Value | Content type | Typical use |
|---|---|---|
JSON |
application/json |
Applications and APIs (default). |
XML |
application/xml |
Legacy systems. |
CSV |
text/csv |
Spreadsheets and quick exports. |
Newline |
text/plain |
Shell scripts; one value per line. |
An unsupported value returns error 108 invalid_format.
JSON#
curl "https://gurdx.cretip.com/api/lookup/country?key=YOUR_API_KEY&countryCode=SA"
{
"data": { "countryCode": "SA" },
"status": "success",
"executionTime": 4
}
XML#
curl "https://gurdx.cretip.com/api/lookup/country?key=YOUR_API_KEY&countryCode=SA&format=XML"
<?xml version="1.0" encoding="UTF-8"?>
<response>
<data>
<countryCode>SA</countryCode>
</data>
<status>success</status>
<executionTime>4</executionTime>
</response>
Lists become repeated <item> elements, and keys that would be invalid XML names are sanitized (a leading digit gets an underscore).
CSV#
The response has two lines: a header row with flattened key names and one row of values. Nested keys use dot notation.
data.countryCode,status,executionTime
SA,success,4
Newline#
Only the values, one per line, in the same order as the flattened keys.
SA
success
4
Booleans are written as true / false, and null values as an empty string.
Errors in other formats#
An error is encoded in the requested format, so a CSV client receives a CSV error:
status,code,type,description
error,101,invalid_key,The API Key is missing or invalid.
HTTP status is still 200. See Error codes.
Related#
- JSONP callback works only with JSON (otherwise error 109).
- Every response also carries an
X-Gurdx-Execution-Timeheader with the processing time in milliseconds.
Found a mistake? Tell us on the contact page. Contact