Paging on daily metric series

API

View as Markdown

What's new

limit and before now work on a daily metric series. Until now the API accepted both and applied neither, so a daily request always returned the whole series.

limit returns the most recent N points. Send limit=30 for the last thirty days instead of the full history.

before is an exclusive cursor on timestamp_ms. It returns points older than the value you send, so you can walk backwards a page at a time.

A before that is not a positive timestamp comes back as a 400 rather than being ignored. Ignoring it would return the whole series to someone who asked for a narrow slice, which is the opposite of what they wanted.

Both parameters narrow a time series, so a few metrics are not affected: a response with no single time axis, such as a table of values keyed by venue, comes back whole and both parameters are ignored.

Send neither and nothing changes: a daily request returns the full series exactly as it did before. There is no default page size on a daily response, so existing calls keep the body they already parse.

How to

Ask for the most recent 30 daily points:

```

GET /api/v2/metrics/{chart_slug}/{metric_name}?limit=30&api_token=YOUR_TOKEN

```

Read X-Newhedge-Next-Before from that response and send it as before for the next 30 older points. The Link header carries the same next-page URL. That URL leaves out api_token, so add your own token before you call it.

Both parameters only narrow a response. Neither reaches further back than the history your plan already returns.

API documentation