shippingMethods
Retrieve all available shipping methods.
Query Structure
query {
shippingMethods {
id
name
description
price
estimatedDeliveryDays
}
}
Arguments
This query does not accept any arguments.
Argument | Type | Description | Required | Default |
---|---|---|---|---|
— | — | This query does not take any arguments. | No | N/A |
Return Type
[ShippingMethod]
An array of ShippingMethod
objects, each representing an available shipping method.
ShippingMethod Fields
Field | Type | Description |
---|---|---|
id | Int | Unique identifier of the shipping method. |
name | String | Name of the shipping method. |
description | String | Description of the shipping method. |
price | Float | Cost of using this shipping method. |
estimatedDeliveryDays | Int | Estimated number of days for delivery. |
Examples
Basic Query
query {
shippingMethods {
id
name
}
}
Advanced Query
query {
shippingMethods {
id
name
description
price
estimatedDeliveryDays
}
}
Field Selection
query {
shippingMethods {
name
price
}
}
cURL Example
curl -X POST https://www.mystoreurl.com/graphql/0.8.0/ \
-H "Content-Type: application/json" \
-d '{"query":"query { shippingMethods { id name description price estimatedDeliveryDays } }"}'
JavaScript Example
async function fetchShippingMethods() {
const endpoint = "https://www.mystoreurl.com/graphql/0.8.0/";
const query = `
query {
shippingMethods {
id
name
description
price
estimatedDeliveryDays
}
}
`;
try {
const response = await fetch(endpoint, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ query })
});
if (!response.ok) {
throw new Error(`Network error: ${response.status} ${response.statusText}`);
}
const { data, errors } = await response.json();
if (errors) {
console.error("GraphQL errors:", errors);
return null;
}
return data.shippingMethods;
} catch (error) {
console.error("Fetch error:", error);
return null;
}
}
Response Format
{
"data": {
"shippingMethods": [
{
"id": 1,
"name": "Standard Shipping",
"description": "Delivery within 5-7 business days",
"price": 5.99,
"estimatedDeliveryDays": 7
},
{
"id": 2,
"name": "Express Shipping",
"description": "Delivery within 2-3 business days",
"price": 15.99,
"estimatedDeliveryDays": 3
}
]
}
}
Error Handling
Error Code | Description | Handling Recommendation |
---|---|---|
400 Bad Request | The query is malformed or invalid. | Verify the query syntax and field names. |
500 Internal Server Error | Server encountered an unexpected condition. | Retry after some time or contact support. |
GraphQL Errors Array | Contains specific query errors such as unknown fields or invalid types. | Inspect the errors array in the response and adjust the query accordingly. |
Performance Considerations
- The
shippingMethods
query returns all available shipping methods without pagination, so the response size is typically small and fast. - Avoid requesting unnecessary fields to reduce payload size and improve response time.
- Cache the shipping methods response on the client side when appropriate, as shipping methods do not change frequently.
- Rate limiting may apply; handle HTTP 429 responses gracefully by implementing exponential backoff retries.
Authentication
This API currently does not require authentication. However, authentication requirements may be introduced in future versions. Monitor API updates for any changes to authentication requirements.
Related Types
ShippingMethod
Field | Type | Description |
---|---|---|
id | Int | Unique identifier of the shipping method. |
name | String | Name of the shipping method. |
description | String | Description of the shipping method. |
price | Float | Cost of using this shipping method. |
estimatedDeliveryDays | Int | Estimated number of days for delivery. |
Notes
- The
shippingMethods
query provides essential information for checkout and shipping selection flows. - Use the
id
field to uniquely identify shipping methods when integrating with order processing systems. - The
price
field represents the cost in the store’s currency. - The
estimatedDeliveryDays
helps provide customers with delivery expectations.
Last updated on