Skip to content
Wikimedia Enterprise
Documentation menu

Identifiers

View as Markdown (opens in a new tab)

An identifier is the value that addresses one resource in the Wikimedia Enterprise API. It is the most reused parameter in the API: almost every path ends in /{identifier}, and the format it expects depends on what you are addressing. A snapshot identifier looks nothing like a language identifier, for instance. This page is the reference for all of them.

Identifier by resource

Every row is an endpoint that takes an {identifier} path parameter.

ResourceIdentifier looks likeWhere the value comes from
Full Snapshot bundleenwiki_namespace_0Snapshots Available, or the recipe below
Structured Contents snapshot (Beta)dewiki_namespace_0Same recipe, limited to the beta projects
Snapshot chunkdewiki_namespace_0_chunk_0, or the chunk indexThe chunks array in Snapshot Info
Hourly batchafwiki_namespace_0Hourly Batch Files Available for that date and hour
Wikidata snapshotitems or propertiesRestricted to two options, Wikidata Snapshots Available lists both
Wikidata snapshot chunkwikidata_items_chunk_0Restricted to one value in the chunks array in Wikidata Snapshot Info
Wikidata hourly batchitems or propertiesRestricted to two options, scoped by the date and hour in the path of Wikidata Hourly Batch File Info
ProjectenwikiProjects Available
LanguageenLanguages Available
Project codewikiProject Codes Available
Namespace0, an integerNamespaces Available
Wikidata itemQ42The QID on Wikidata
Wikidata propertyP31The PID on Wikidata
Wikidata labelQ42 or P31Either a QID or a PID
On-demand articleSquirrelthe article name

How a snapshot identifier is built

Snapshot bundles, Structured Contents snapshots, and hourly batch files all share one recipe:

<language><project_code>_namespace_<number>
IdentifierLanguageProject codeNamespaceContains
enwiki_namespace_0enwiki0 (Main)Articles from en.wikipedia.org
dewiki_namespace_14dewiki14 (Category)Categories from de.wikipedia.org
frwikivoyage_namespace_10frwikivoyage10 (Template)Templates from fr.wikivoyage.org
nlwikibooks_namespace_6nlwikibooks6 (Files)Media files from nl.wikibooks.org

The language and project code together are the project identifier, also found in the identifier field of the Projects Available endpoint, e.g. eswikivoyage. It's safer to read the identifier value rather than assembling the string yourself. Language codes do not all follow one standard and can be two or three characters (e.g. chy for Cheyenne), and not every project has a predictable project code (e.g. Wikidata's project identifier is wikidatawiki).

Chunk identifiers extend the same value with _chunk_<number>, so dewiki_namespace_0 chunks are dewiki_namespace_0_chunk_0, dewiki_namespace_0_chunk_1, and so on. Take them from the chunks array of a Snapshot Info response. The number of chunks varies per snapshot bundle.

Wikidata is the exception to the recipe. Its snapshots and hourly batches are addressed by items or properties, the bundles report wikidata_items and wikidata_properties as their identifier, and their chunks are wikidata_items_chunk_0 and up. See Wikidata snapshots.

Wikimedia Enterprise serves namespaces 0 (Main), 6 (File), 10 (Template), and 14 (Category). See Namespaces for info on what data each Namespace contains.

Structured Contents is a subset

Structured Contents snapshots use the same identifier format, but are restricted to a smaller subset of projects that have been thoroughly tested and released in beta. Structured Contents snapshots currently cover the following projects: enwiki_namespace_0, dewiki_namespace_0, frwiki_namespace_0, eswiki_namespace_0, ptwiki_namespace_0, itwiki_namespace_0, nlwiki_namespace_0, cywiki_namespace_0, and idwiki_namespace_0.

How to find a valid identifier

Discover identifiers by:

  1. Requesting metadata endpoints Snapshots Available returns every available snapshot bundle, Hourly Batch Files Available does the same per date and hour, and Snapshot Info lists a bundle's chunk identifiers. Wikidata Snapshot Info lists identifiers and metadata for the two Wikidata bundles.
  2. Building identifiers from multiple metadata fields Call the utility endpoints in order (codes, languages, projects, namespaces) to confirm each part before you compose it. That reference data changes rarely, so cache it instead of requesting it on every run.

The recommended way to discover project snapshot identifiers is to request the Snapshots Available endpoint using the fields request body parameter to pass the identifier field. See the example request below.

curl --location 'https://api.enterprise.wikimedia.com/v2/snapshots' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--data '{ "fields": ["identifier"] }'
[
{ "identifier": "abwiki_namespace_0" },
{ "identifier": "abwiki_namespace_6" },
{ "identifier": "abwiki_namespace_10" }
]

A request with a well-formed but nonexistent identifier returns 404, not a validation error, so a typo and an unavailable bundle look the same from the outside.

Article names

The On-demand API addresses articles by name, which aren't unique identifiers: /v2/articles/{name} and /v2/structured-contents/{name} both take the article title as it appears on the wiki. Names are case sensitive, and spaces are passed as underscores (Josephine_Baker) or percent-encoded (Josephine%20Baker).

A name is not unique across Wikimedia projects. An unfiltered lookup returns a match from every project that has an article by that name, so filter on is_part_of.identifier for a project or in_language.identifier for a language to pin the result to one wiki. See Fields, Filters, and Limit for the syntax.

Identifiers inside a payload

Response bodies use identifier as a field name too, at several levels of the same object. They are not interchangeable with the path identifiers above.

FieldTypeIdentifiesExample
identifiernumberThe article's MediaWiki page ID28492
version.identifiernumberThe revision, not the article1041549311
is_part_of.identifierstringThe projectenwiki
in_language.identifierstringThe languageen
namespace.identifiernumberThe namespace0
main_entity.identifierstringThe Wikidata item for the articleQ42

An article identifier is a page ID, which is not the same as the article name. Page IDs can't be used as input to the On-demand API. The version.identifier is a revision ID that changes with every edit. Find definitions for all of the identifiers above in the article model.

See also

  • Metadata - the utility endpoints that supply every part of an identifier.
  • Snapshot API - download entire projects as compressed NDJSON tarballs.
  • Realtime API - hourly batches reuse the snapshot identifier format.
  • On-demand API - article lookups by name.
  • Data Model - how the objects in a payload fit together.