Introduction
Openfront provides a powerful GraphQL API that gives you complete access to the platform’s e-commerce capabilities. The API is built on KeystoneJS 6 and provides a flexible, type-safe way to query and mutate your commerce data.API Endpoint
The GraphQL API is available at:GraphQL Playground
Openfront includes an interactive GraphQL Playground for exploring the API during development. Access it at:The GraphQL Playground is only available in development mode. In production, you’ll need to use a GraphQL client or tools like Postman, Insomnia, or Apollo Client.
Basic Query Structure
All GraphQL requests are sent as POST requests to the/api/graphql endpoint. Here’s a basic example:
Example: Fetching Products
Example: Creating a Cart
Using cURL
You can also interact with the API using cURL:Response Format
GraphQL responses follow a standard format:Error Handling
When errors occur, they’re returned in theerrors array:
Key Features
Type Safety
The GraphQL API provides full type introspection. You can query the schema to discover available types, fields, and operations:Flexible Queries
Request only the fields you need, reducing payload size and improving performance:Filtering and Pagination
The API supports powerful filtering and pagination:Custom Mutations and Queries
Openfront extends the base KeystoneJS schema with custom operations for e-commerce workflows:Cart Operations
activeCart- Get cart by IDupdateActiveCart- Update cart detailsaddDiscountToActiveCart- Apply discount codescompleteActiveCart- Convert cart to order
Order Operations
getCustomerOrder- Retrieve order detailsgetCustomerOrders- List customer orders
Analytics
getAnalytics- Fetch business analytics data
Shipping Operations
getRatesForOrder- Get shipping ratesvalidateShippingAddress- Validate addressestrackShipment- Track shipment status
Invoice Operations (B2B)
createInvoiceFromLineItems- Generate invoicespayInvoice- Process invoice paymentsgetCustomerPaidInvoices- Retrieve payment history
Schema Documentation
For a complete list of available queries, mutations, and types, explore the GraphQL Playground’s documentation panel (accessible via the “Docs” button in the playground interface).Next Steps
Authentication
Learn how to authenticate your API requests
Rate Limiting
Understand API rate limits and best practices