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.
Conditional requests are opt-in, per request. Without the Lanewise-ETag header, the API never answers 304, so clients that don't keep previous responses never receive an empty one.
How it works
- Send
Lanewise-ETag: truewith aGETrequest. The response carries anETagheader: the version of that response. - Keep the response body together with its
ETag. - Next time, send the same request with
Lanewise-ETag: trueandIf-None-Matchset to theETagyou kept. - If nothing changed, you get a
304 Not Modifiedwith no body: reuse the response you kept. If something changed, you get a normal200with the new data and a newETagto 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
trueto use conditional requests on this request.
- Name
If-None-Match- Type
- header
- Description
The
ETagyou 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
304in 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
304that counts goes through the usual limits, including the per-minute burst cap, and can be rejected with a429like any other request. See plans and limits. - A
200always counts, as does any request withoutLanewise-ETag.
Where it works
Every GET endpoint of the API supports conditional requests, except GET /v1/info, whose usage figures change with every request:
- POIs: list, filters and retrieve.
- Attributes and categories: list and retrieve.
- Geolocation: countries, cities and zip codes.
- Imports: list and retrieve.
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.