Get started with the Prepr GraphQL API

This guide explains how to get started with receiving data from the Prepr GraphQL API.

Step 1: Sign up for a Prepr account

Go to signup.prepr.io, answer a few questions, and you can start exploring Prepr. You will create a project with a default environment during the onboarding process. Choose to use demo data to help you get going.

Step 2: Get your API URL

Once you’ve signed up for a Prepr account, you can get the API endpoint URL and access token.

By default, there are two API endpoints per environment – Preview and Published. Each API URL has a unique access token with the relevant permission scope.

You can find the API URLs under Settings > Access tokens.

Step 3: Send your first API request

To try out the API endpoint, you can send a basic request with the API Explorer, an interface where you can test your API requests before integrating them into production.

Let’s retrieve all published content items available in the demo data by calling the GraphQL Published API URL.

Navigate to Settings > Access tokens, click to open the GraphQL Published access token details. Under the API URL field, click Open in API Explorer.

Published access token

You’ll be redirected to the API Explorer interface. The GraphQL Published API URL will be registered in the API Explorer automatically.

API Explorer

Copy and paste the following query to the Operation pane and click Run.

Once your request is processed, check out the response. You will get a list of all published articles with their identifiers and titles.

query {
Posts {
 items {
   _id
   title
   }
  }
}
{
"data": {
  "Posts": {
    "items": [
      {
        "_id": "74ca82e9-85cc-4d13-a931-d1a40e90c5fd",
        "title": "Poland’s Chopin Institute marks 20 years"
      },
      {
        "_id": "9e261d71-b7c2-4ca3-abe2-31879843915f",
        "title": "Government announces major review of National Parks & Wildlife Service"
      },
      {
        "_id": "3e2d4b43-46e4-4aa1-8f48-137ab6bbf74f",
        "title": "Scientific research taking FL into the future"
      },
      {
        "_id": "15ad199d-fd65-4628-a4f8-371edfbecb30",
        "title": "Australian of the Year 2021 Grace Tame’s powerful message on Q&A"
      },
      {
        "_id": "9a11ee97-0e07-4684-b467-e01510bca574",
        "title": "Best study tips you will read this year"
      }
    ]
  }
}
}

That’s it. You’ve made your first call to the Prepr GraphQL API.

What's next?

You can try out your GraphQL queries using the Apollo Explorer tool.

To learn more about the Prepr GraphQL API, check out the following resources:

Tip