Developer Resources

Everything you need to build with NormaTrack API

API Overview

GraphQL API

Modern, flexible API for querying and mutating data with a single endpoint.

POST /api/graphqlLearn more →

Type Definitions

Strongly typed schema including Company, Product, Variant, Material, and more.

• Company

• Product

• Material

View schema →

Database Integration

Seamlessly integrated with Prisma ORM and SQLite database.

• Auto-generated types

• Type-safe queries

• Built-in migrations

Details →

Code Examples

JavaScript / TypeScript

fetch
const query = `{
  getStatistics {
    totalProducts
    totalVariants
    averageSustainabilityScore
  }
}`;

const response = await fetch('/api/graphql', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ query })
});

const data = await response.json();
console.log(data);

Python

requests
import requests
import json

query = """{
  products(take: 10) {
    id
    name
    brand
    sustainabilityScore
  }
}"""

response = requests.post(
  'http://localhost:3000/api/graphql',
  json={"query": query},
  headers={"Content-Type": "application/json"}
)

data = response.json()
print(json.dumps(data, indent=2))

cURL

cli
curl -X POST http://localhost:3000/api/graphql \
  -H "Content-Type: application/json" \
  -d '{
    "query": "{ materials(take: 5) { id name supplier carbonFootprint } }"
  }'

Best Practices

  • Use pagination with `skip` and `take` parameters for large datasets
  • Request only fields you need to reduce payload size
  • Use fragments for reusable query parts
  • Handle errors gracefully in your client code
  • Cache results on the client side when appropriate