# Retrieve information about the Pinnation page on English Wikipedia
$ curl --include https://en.wikipedia.org/w/rest.php/v1/page/Pinnation/bare
HTTP 200
content-type: application/json
etag: W/"917562775"
{
"id": 339742,
"key": "Pinnation",
"title": "Pinnation",
"latest": {
"id": 917562775,
"timestamp": "2019-09-24T11:43:46Z"
},
"content_model": "wikitext",
"license": {
"url": "//creativecommons.org/licenses/by-sa/3.0/",
"title": "Creative Commons Attribution-Share Alike 3.0"
},
"html_url": "https://en.wikipedia.org/w/rest.php/v1/page/Pinnation/html"
}
A conditional request allows you to shortcut subsequent requests for the same resource by comparing the ETag value provided with the If-None-Match header.
If the resource has not changed since the last request, the API returns HTTP status 304 (Not Modified).
If the resource has changed, the API returns HTTP status 200 (OK) with the latest data and a new ETag.
# Conditional request using If-None-Match
curl --include \
--header 'If-None-Match: W/"917562775"' \
https://en.wikipedia.org/w/rest.php/v1/page/Pinnation/bare
# Response: resource unchanged
HTTP 304
content-type: application/json
etag: W/"917562775"
# Response: resource changed
HTTP 200
content-type: application/json
etag: W/"537558444"
{
"id": 339742,
"key": "Pinnation",
"title": "Pinnation",
"latest": {
"id": 537558444,
"timestamp": "2020-01-25T20:03:40Z"
},
"content_model": "wikitext",
"license": {
"url": "//creativecommons.org/licenses/by-sa/3.0/",
"title": "Creative Commons Attribution-Share Alike 3.0"
},
"html_url": "https://en.wikipedia.org/w/rest.php/v1/page/Pinnation/html"
}
Conditional requests with If-Modified-Since
When present, ETags and If-None-Match headers are the preferred method for conditional requests.
However, to improve API efficiency in certain cases, some endpoints don't support ETags.
To make a conditional request to an endpoint that doesn't return an ETag, use the last-modified value with the If-Modified-Since header.
Here's an example of an endpoint that returns only a last-modified value:
# Get the number of edits to the Pinnation page on English Wikipedia
$ curl --include https://en.wikipedia.org/w/rest.php/v1/page/Pinnation/history/counts/edits
HTTP 200
content-type: application/json
last-modified: Tue, 24 Sep 2019 11:43:46 GMT
{"count":115,"limit":false}
To make a conditional request, include the last-modified value with the If-Modified-Since header.
If the resource has not changed since the last request, the API returns HTTP status 304 (Not Modified).
If the resource has changed, the API returns HTTP status 200 (OK) with the latest data and a new last-modified timestamp.
# Conditional request using If-Modified-Since
curl --include \
--header 'If-Modified-Since: Tue, 24 Sep 2019 11:43:46 GMT' \
https://en.wikipedia.org/w/rest.php/v1/page/Pinnation/history/counts/edits
# Response: resource unchanged
HTTP 304
content-type: application/json
last-modified: Tue, 24 Sep 2019 11:43:46 GMT
# Response: resource changed
HTTP 200
content-type: application/json
last-modified: Mon, 11 Jan 2020 06:51:35 GMT
{"count":117,"limit":false}