API:REST API/Conditional requests

Most MediaWiki REST API endpoints support conditional GET requests using ETags. ETags, short for entity tags, are unique identifiers assigned to different versions of a resource. You can use ETags to optimize your API calls when accessing the same resource multiple times.

Making a conditional request using an ETag
To make a conditional request, provide the value of the  response header in an If-None-Match request 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.

To detect a matching resource, use the If-Match request header. If no match is found or an evaluation error occurs, the API returns a HTTP status 412 (Precondition Failed).

Making a conditional request without an ETag
When present, ETags are the preferred method for conditional requests. However, to improve API efficiency, some endpoints do not support ETags. To make a conditional request to an endpoint that doesn't return an ETag, supply the value of the last-modified response header in an If-Modified-Since or If-Unmodified-Since request header.