-
Notifications
You must be signed in to change notification settings - Fork 4
API
(For coders)
Computer programs can use the HXL Proxy as if it were an Application programming interface (API).
There are two basic URL patterns available (substitute a different domain if you are using a local copy of the proxy):
https://proxy.hxlstandard.org/data.<ext>
https://proxy.hxlstandard.org/data/download/<basename>.<ext>
The ext portion may be either "csv" for CSV data, or "json" for JSON data. In the second form, you can chose any custom download filename by setting the basename appropriately, e.g. "2016-burundi-3w".
HTTP parameter | Required | Description | Example |
---|---|---|---|
url | yes | URL of the original dataset (see Special URL handling). | http://example.org/data.csv |
sheet | no | Zero-based index of the tab to use from an Excel workbook | 1 |
recipe | no | A [[JSON data recipe | JSON recipes]] for transforming the data. |
force | no | If "on", skip input and output [[caching | Caching]]. |
strip-headers | no | If "on", do not include text headers above the HXL hashtag row. This will ensure that there is only a single row of headers (the hashtags), for database import, etc. | on |
max-rows | no | Maximum number of rows to display/download (0 or more). If not specified, HTML display will be limited to 5,000 rows, and CSV/JSON download will be unlimited. | 1000 |
You may optionally also include the form parameters from the interactive Recipe page if you wish. The HXL Proxy will read the recipe parameter first, then append any form-based filters after it.
All examples in this section use the UNHCR Persons of Concern dataset, which is available with HXL hashtags.
The JSON recipes are included in the URLs without extra whitespace, but formatted for readability below.
In CSV format, downloading as "data.csv":
Embedded recipe:
{
"filter": "with_rows",
"queries": "country+residence=jordan"
}
In CSV format, downloading as "data.csv":
Embedded recipe:
[
{
"filter": "with_rows",
"queries": "country+residence=afghanistan"
},
{
"filter": "with_rows",
"queries": "date>=2001"
}
]
In JSON format, downloading as "ca-refugees-by-year.json":
Embedded recipe:
[
{
"filter": "with_rows",
"queries": "country+residence=canada"
},
{
"filter": "count",
"patterns": "date",
"aggregate_pattern": "affected+refugees"
},
{
"filter": "with_columns",
"whitelist": "date+year,meta+sum"
},
{
"filter": "rename_columns",
"specs": ["meta+sum:Total refugees#affected+refugees"]
}
]
Learn more about the HXL standard at http://hxlstandard.org