currencies
Retrieve all enabled currencies available in the store.
Query Structure
query {
currencies {
code
name
symbol
enabled
}
}
Arguments
This query does not accept any arguments.
Argument | Type | Description | Required | Default |
---|---|---|---|---|
— | — | This query has no arguments | No | N/A |
Return Type
[Currency]
- Currency object fields:
code
(String): The ISO currency code (e.g., “USD”, “EUR”).name
(String): The full name of the currency (e.g., “United States Dollar”).symbol
(String): The currency symbol (e.g., ”$”, ”€”).enabled
(Boolean): Indicates if the currency is currently enabled in the store.
Examples
Basic Query
query {
currencies {
code
name
}
}
Advanced Query
query {
currencies {
code
name
symbol
enabled
}
}
Field Selection
query {
currencies {
code
symbol
}
}
cURL Example
curl -X POST https://www.mystoreurl.com/graphql/0.8.0/ \
-H "Content-Type: application/json" \
-d '{"query":"query { currencies { code name symbol enabled } }"}'
JavaScript Example
async function fetchCurrencies() {
const endpoint = "https://www.mystoreurl.com/graphql/0.8.0/";
const query = `
query {
currencies {
code
name
symbol
enabled
}
}
`;
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.currencies;
} catch (error) {
console.error("Fetch error:", error);
return null;
}
}
Response Format
The response returns a JSON object with a currencies
array containing currency objects:
{
"data": {
"currencies": [
{
"code": "USD",
"name": "United States Dollar",
"symbol": "$",
"enabled": true
},
{
"code": "EUR",
"name": "Euro",
"symbol": "€",
"enabled": true
}
]
}
}
Error Handling
Possible error scenarios include:
Error Code | Description | Handling Recommendation |
---|---|---|
400 | Bad Request - malformed query | Verify query syntax and structure |
500 | Internal Server Error | Retry after some time or contact support |
GraphQL Errors | Validation or execution errors returned in errors field | Inspect errors array for details and adjust query accordingly |
Performance Considerations
- This query returns all enabled currencies without pagination; the dataset is typically small and performant.
- Avoid requesting unnecessary fields to reduce response size.
- Cache results client-side when possible, as currency data changes infrequently.
- Rate limiting may apply; implement exponential backoff on repeated failures.
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
Currency
Field | Type | Description |
---|---|---|
code | String | ISO currency code |
name | String | Full currency name |
symbol | String | Currency symbol |
enabled | Boolean | Whether the currency is enabled |
Notes
- The
enabled
field indicates if the currency is currently active in the store. - Use this query to dynamically populate currency options in your storefront or admin tools.
- Since no arguments are accepted, the query always returns all enabled currencies.
Last updated on