Getting started with the pyck GraphQL API
Audience Programmer
Since pyck v0.27.0
Introduction
Section titled “Introduction”This guide shows how to make your first query and understand the response format.
Prerequisites
Section titled “Prerequisites”Before you begin, you’ll need:
- A pyck account with API access
- Authentication credentials (JWT token or PAT)
- A GraphQL client or HTTP client
Making your first query
Section titled “Making your first query”This query returns the current user:
query { me { UserID Username Email }}This query requests the user ID, username, and email of the authenticated user.
Using curl
Section titled “Using curl”curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_TOKEN" \ --data '{"query": "query { me { UserID Username Email } }"}' \ https://eu.pyck.cloud/graphqlUsing JavaScript
Section titled “Using JavaScript”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;}Understanding the response
Section titled “Understanding the response”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}Basic query examples
Section titled “Basic query examples”Listing inventory items
Section titled “Listing inventory items”query { inventoryItems(first: 10) { edges { node { id sku } } }}Creating an inventory item
Section titled “Creating an inventory item”mutation { createInventoryItem(input: { sku: "TP-001" data: { weight: 1.5, color: "blue" } }) { inventoryItem { id sku createdAt } }}Using variables
Section titled “Using variables”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"}Next steps
Section titled “Next steps”After your first queries, you can:
- Explore the Schema Overview to understand available operations
- Learn about Authentication for secure API access
- Read Error Handling to handle API errors
- Read the documentation for specific queries and mutations
Tools and resources
Section titled “Tools and resources”- 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