Skip to content

Data preview service

David Megginson edited this page Mar 16, 2020 · 5 revisions

The HXL Proxy's Data-preview service at /api/data-preview.csv and /api/data-preview.json generates a raw (non-HXL-processed) preview of any tabular data source that the HXL Proxy can read. The service accepts the following GET parameters:

Parameter Is required? Description
url yes URL of the dataset to preview (must be publicly readable)
sheet no The zero-based index of the sheet/tab to preview, if the source is an Excel workbook (defaults to 0 for the first sheet). Note that this does not apply to Google Sheets; use the full URL with the hash to get a specific tab
filename no The download filename (defaults to data-preview.csv or data-preview.json)
rows no The maximum number of rows to return (defaults to -1, for all)
force no If the value is "on", skip caching (defaults to a one-hour cache for both input and output)

The results include a CORS header to allow in-browser Javascript use.

To get a list of all the sheets in a Microsoft Excel workbook, use the Data preview sheets API endpoint.

Examples

Preview a Google Sheet, all rows, and return the results as JSON:

https://proxy.hxlstandard.org/api/data-preview.json?url=https%3A%2F%2Fdocs.google.com%2Fspreadsheets%2Fd%2F1ytPD-f4a8CbNKTfMS3EqZOpBo9LWCk_NDKxJCgmpXA8%2Fedit%23gid%3D1101521524

Same as the above, but with CSV output (UTF-8 character encoding):

https://beta.proxy.hxlstandard.org/api/data-preview.csv?url=https%3A%2F%2Fdocs.google.com%2Fspreadsheets%2Fd%2F1ytPD-f4a8CbNKTfMS3EqZOpBo9LWCk_NDKxJCgmpXA8%2Fedit%23gid%3D1101521524

JSON output, but limited to just the first 2 rows:

https://proxy.hxlstandard.org/api/data-preview.json?rows=2&url=https%3A%2F%2Fdocs.google.com%2Fspreadsheets%2Fd%2F1ytPD-f4a8CbNKTfMS3EqZOpBo9LWCk_NDKxJCgmpXA8%2Fedit%23gid%3D1101521524