How to start

The public API is built around Graphql and is the same as the one we use internally at Cycle. Some basic knowledge about Graphql and its paradigms is required to fully understand the schema. The Graphql official documentation is the best starting point.

Endpoint

https://api.product.cycle.app/graphql

It supports introspection so you can query the whole schema. You can use Altair as a GraphQL client to explore the schema.

Queries and mutations

Most queries and mutations require to be authenticated to run them. The token must be placed in the Authorization header prefixed with the Bearer word (refer to the Authentication section).

curl \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <Replace this with your access token>" \
  --data '{ "query": "{ me { id email } }" }' \
  https://api.product.cycle.app/graphql

To access informations available to the authenticated user, you can use the me query.

query me {
    me {
        id
        email
        firstname
        lastname
    }
}

From there, you can explore the whole schema but keep in mind that if you go too deep, you may be complexity limited (see section Limitations).

query me {
    me {
      id
      email
      firstName
      lastName
      products {
        edges {
          node {
            id
            name
          }
        }
      }
    }
}

Triggering a mutation is as simple but you may sometimes need to fetch some piece of information first to populate the needed arguments. This is typically the case when creating a feedback with the createFeedback mutation for which you need at least the productId. The updateMe doesn't require any specific and let you update your user programatically.

mutation updateMe {
  updateMe(firstName: "Super", lastName: "hero") {
    id
    firstName
    lastName
  }
}

Last updated