Skip to content
Pyck docs

Getting started with the pyck GraphQL API

Audience Programmer

Since pyck v0.27.0

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

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 Schema Overview to understand available operations
  2. Learn about Authentication for secure API access
  3. Read Error Handling to handle API errors
  4. Read the documentation for specific queries and mutations
  • GraphQL endpoint: https://eu.pyck.cloud/graphql
  • Apollo Client: Popular GraphQL client for JavaScript
  • Insomnia: API client with GraphQL support
  • Postman: API testing tool with GraphQL support