Browse the API with Postman

Every Prismic repository includes an API browser. If you'd like to browse our REST API with Postman, here is how to do it.

Get the Master Ref

The API ref is required to specify the content version/branch you'd like to query. For public content, you will use the master ref. To get it, you'll have to query the /api endpoint of your repository.

I order to achieve that with Postman, you'll have to run a Pre-Request Script to fetch the master ref before running any API call and to save it in an environment variable.

First create a new GET query in Postman.

Secondly, you'll have to add that script to "Pre-Request Script" tab in your Postman request:

Copy
pm.environment.unset("ref");

// update this variable with your repo name
var repo = "your-repo-name"

pm.environment.set("repo",repo)

var repoEndpoint = "https://" + repo + ".prismic.io/api/v2"

pm.sendRequest(repoEndpoint, function (err, res) {
    if (err) {
        console.log(err);
    } else {
        var response = res.json();
        var ref = response.refs[0].ref;
        pm.environment.set("ref", ref);
    }
});

Set up the master ref as a query parameter

Now that we have the master ref as an environment variable, let's add it to the query parameters.

Go in the "Params" tab of your Postman request and add the following parameter:

Adding the ref to your params

Query the API

Almost everything is set up. You can now add the URI you want to query.

For example if you want to get all the documents of your repo:

Copy
https://{{repo}}.prismic.io/api/v2/documents/search?ref={{ref}}

You can find all the REST API references here.