AI Commerce GraphQL User Guide for Partners
Learn how to leverage AI Commerce with your partners using GraphQL.
What is GraphQL and why is it used in the AICommerce environment?
GraphQL is a flexible and powerful interface solution that enables highly customized database queries . Unlike traditional REST APIs, GraphQL gives partners the freedom to define what data they need , reducing unnecessary data transfer and speeding up request processing.
How does GraphQL work in AI Commerce environment?
AI Commerce uses the Apollo GraphQL server , which receives requests and returns only the requested data. Partners can use GraphQL to retrieve products, countries, and other data from AI Commerce platform.
GraphQL requests are made as an HTTP POST request , and each request includes the necessary identifying information in the header field .
How to make a GraphQL request in AI Commerce ?
GraphQL requests are made in JSON format using the load balancer address , which is obtained from the environment variable APP_LOAD_BALANCER_URL .
📌 Example: Retrieving 5 products (POST request)
{
"query": "{
products(limit: 5, offset: 0) {
id
name
price
}
}"
}
🔗 Postman / Curl example
curl -X POST -H "Content-Type: application/json" \
-H "X-GraphQL-Secret: "" \
-H "X-Tenant-Id: boeing" \
-H "X-Tenant-Secret: your-secret" \
--data '{"query":"{ products(limit: 5, offset: 0) { id name price } }"}' \
https://api.aicommerce.fi/graphql
✅ The request returns the following JSON response:
{
"data": {
"products": [
{ "id": "632", "name": "721H", "price": 89.9 },
{ "id": "637", "name": "TC7092", "price": 49.9 },
{ "id": "697", "name": "JERONE50EUR", "price": 50 },
{ "id": "698", "name": "JERONE100EU", "price": 100 },
{ "id": "699", "name": "JERONE200EU", "price": 200 }
]
}
}
Required headers in each request
Every GraphQL request requires the following headers:
Header | Description |
---|---|
X-GraphQL-Secret
|
AI Commerce security key (request from info@petrosoft.fi ) |
X-Tenant-Id
|
Store alias (main domain without domain suffix, e.g. boeing and not adboeing.com ) |
X-Tenant-Secret
|
Tenant API key (request from info@petrosoft.fi ) |
Content-Type
|
application/json (GraphQL only supports JSON-formatted requests) |
We recommend using AI Commerce Lambda environment
AI Commerce recommends that in a Lambda environment, you always use the load balancer address , which can be found in the environment variable:
APP_LOAD_BALANCER_URL
✅ This way you stay within AI Commerce 's internal network , which speeds up request processing and improves data security .
GraphQL vs. REST API – What’s the difference?
Feature | GraphQL | REST API |
---|---|---|
Number of requests | One request is enough. | Multiple requests required |
Data to be restored | The partner specifies exactly what is being sought | The API returns a fixed data model |
Flexibility | Very flexible, supports complex queries | Fixedly defined |
Performance | Reduces unnecessary database calls | May import too much or too little data |
✅ GraphQL enables the development of custom database queries with partners.
AI Commerce GraphQL - Rate Limiting
Our GraphQL server limits the number of requests to avoid overload. Rate limiting is enabled:
- Maximum 100 requests / 5 minutes per tenant
- If the limit is exceeded, a 429 Too Many Requests is returned.
✅ Rate Limiting Management:
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
{
"error": "Too many requests, please try again later."
}
✅ Fix the errors and try again!
Summary
- GraphQL is a powerful and flexible way to retrieve information from AI Commerce platform.
- Requests require the correct headers (
X-Tenant-ID
,X-Tenant-Secret
,X-GraphQL-Secret
) . - Always use AI Commerce 's Lambda load balancer (
APP_LOAD_BALANCER_URL
) for improved security. - Rate limiting protects the service and limits the number of requests.
- Error management is important → Investigate error codes and fix requests .
Where is the more detailed GraphQL API documentation?
This article is a general guide, but AI Commerce provides separate GraphQL API documentation with more detailed query formats and additional features.
📩 Contact us: info@petrosoft.fi for full API documentation!
🚀 Now you are ready to use AICommerce GraphQL effectively! 🚀