Query by ID or UID with the REST API

This page gives examples of how to query for a document either by its ID or its UID with the prismic.io predicates.

Querying by Language

Note that if you are trying to query a document that isn't in the master language of your repository, you will need to specify the language code or wildcard language value. You can read how to do this on the Query by Language page.

Query by ID

Let's see what all you need to query a document by an ID.

The predicate

In order to do this query we will use the at predicate. It will look like this.

Copy
[at(document.id, "{id}")]

Example

This is an example showing how to query the document with the id WAjgAygAAN3B0a-a.

Here is the required parameter for this query:

query by id

q=[[at(document.id,"WAjgAygAAN3B0a-a")]]

Query by UID

Let's see what all you need to query a document by an UID.

The predicate

In order to do this query we will use the at predicate. It will look like this.

Copy
[at(my.{custom-type}.uid, "{uid}")]

{custom-type}

The API-ID of the custom type

{uid}

The UID of the target document

Example

This is an example showing how to query the document of the type page by its uid about-us.

Here is the required parameter for this query:

query by id

q=[[at(my.page.uid,"about-us")]]