Conditional requests

When you poll the same data again and again, you can ask Lanewise whether it changed instead of downloading it every time. Unchanged data comes back as an empty 304 Not Modified, which is faster for you and costs a tenth of a request. Conditional requests are available on paid plans.

How it works

  1. Send Lanewise-ETag: true with a GET request. The response carries an ETag header: the version of that response.
  2. Keep the response body together with its ETag.
  3. Next time, send the same request with Lanewise-ETag: true and If-None-Match set to the ETag you kept.
  4. If nothing changed, you get a 304 Not Modified with no body: reuse the response you kept. If something changed, you get a normal 200 with the new data and a new ETag to keep instead.

Any change to your team's POIs, attributes, categories or imports gives every response a new ETag, including changes made by other API keys, the dashboard, imports and address lookups. The ETag also depends on the exact request (path and query parameters, in any order) and on the API key, so keep one per request and key.

  • Name
    Lanewise-ETag
    Type
    header
    Description

    Send true to use conditional requests on this request.

  • Name
    If-None-Match
    Type
    header
    Description

    The ETag you kept for this request. Weak ETags (W/"…") and lists of ETags are accepted.


First request

Opt in with Lanewise-ETag: true. The response is a normal 200 with an extra ETag header. Store the body and the ETag.

Request

curl -i https://api.lanewise.app/v1/pois \
  -H "X-API-KEY: {YOUR_API_KEY}" \
  -H "Lanewise-ETag: true"

Response

HTTP/2 200
etag: "55fa60bb65d317d49209d54fe44d0453"
cache-control: no-cache, private
x-ratelimit-remaining: 998

{ "data": [ ... ], "next": null }

Revalidating

Send the stored ETag in If-None-Match. While the data is unchanged, you get an empty 304: reuse the body you stored.

Only one 304 in every ten counts towards your hourly quota, so most revalidations leave your remaining requests untouched, like this one. See rate limits below.

Request

curl -i https://api.lanewise.app/v1/pois \
  -H "X-API-KEY: {YOUR_API_KEY}" \
  -H "Lanewise-ETag: true" \
  -H 'If-None-Match: "55fa60bb65d317d49209d54fe44d0453"'

Unchanged

HTTP/2 304
etag: "55fa60bb65d317d49209d54fe44d0453"
x-ratelimit-remaining: 998

Rate limits

  • One 304 in every ten counts as a request, starting with the first one of each hour. The other nine don't count towards your hourly quota.
  • A 304 that counts goes through the usual limits, including the per-minute burst cap, and can be rejected with a 429 like any other request. See plans and limits.
  • A 200 always counts, as does any request without Lanewise-ETag.

Where it works

Every GET endpoint of the API supports conditional requests, except GET /v1/info, whose usage figures change with every request:

Errors never carry an ETag. On the free plan, Lanewise-ETag is ignored: responses have no ETag and requests never get a 304.

Browsers

In a browser, the ETag header is readable from JavaScript (it's exposed through CORS). Responses are marked Cache-Control: no-cache, private, so shared caches never store them and your client always revalidates.