Skip to content
Pyck docs

You are reading the Dev docs (main @ e991a08). They can differ from the released product.Dev docs, not the release

Switch to LatestLatest

Getting started with the Pyck GraphQL API

Audience Developer

This guide shows how to make your first query and understand the response format.

Before you begin, you’ll need:

  • A Pyck account with API access
  • Authentication credentials (JWT token or PAT)
  • A GraphQL client or HTTP client

Pyck has two environments for customers, each with its own GraphQL endpoint:

  • https://eu.pyck.cloud/graphql: the production environment.
  • https://demo.pyck.cloud/graphql: the demo environment.

The examples in this guide use the production endpoint. To use the demo environment, replace the host in the examples. Each environment also names its GraphQL endpoint in endpoints.graphql.url of its discovery document at /.well-known/pyck-configuration, see Client discovery document.

This query returns the current user:

query {
me {
UserID
Username
Email
}
}

This query requests the user ID, username, and email of the authenticated user.

Terminal window
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
--data '{"query": "query { me { UserID Username Email } }"}' \
https://eu.pyck.cloud/graphql
async function fetchCurrentUser() {
const response = await fetch('https://eu.pyck.cloud/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
query: `
query {
me {
UserID
Username
Email
}
}
`
})
});
const result = await response.json();
return result.data.me;
}

GraphQL responses always follow the same structure:

{
"data": {
"me": {
"UserID": "0190a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a5b",
"Username": "john.doe",
"Email": "john.doe@example.com"
}
}
}

If there are errors, they’ll be returned in an errors array:

{
"errors": [
{
"message": "You are not authenticated",
"locations": [{ "line": 2, "column": 3 }],
"path": ["me"]
}
],
"data": null
}
query {
inventoryItems(first: 10) {
edges {
node {
id
sku
}
}
}
}
mutation {
createInventoryItem(input: {
sku: "TP-001"
data: { weight: 1.5, color: "blue" }
}) {
inventoryItem {
id
sku
createdAt
}
}
}

GraphQL allows you to use variables for dynamic values:

query GetItem($id: ID!) {
nodeInventory(id: $id) {
... on InventoryItem {
id
sku
}
}
}

With variables:

{
"id": "item-123"
}

After your first queries, you can:

  1. Explore the API reference to understand available operations
  2. Learn about Authentication for secure API access
  3. Read Error Handling to handle API errors
  4. Read API conventions for pagination and request limits
  5. Read the documentation for specific queries and mutations