Get Single Currency
About
The currency query retrieves a single currency by ID with support for detailed field access. This query is essential for:
- Fetching specific currency details for price formatting
- Retrieving currency symbol and position for display
- Getting formatting details (decimal places, separators)
- Validating currency existence before operations
- Building currency detail pages
- Configuring currency-specific price formatting
The query allows you to fetch a specific currency with all its properties.
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
id | ID! | Yes | The unique identifier of the currency. Can be either numeric ID or IRI format (/api/shop/currencies/{id}). |
Possible Returns
| Field | Type | Description |
|---|---|---|
currency | Currency | The requested currency object, or null if not found. |
Currency Fields
| Field | Type | Description |
|---|---|---|
id | String! | Unique identifier in format /api/shop/currencies/{id} |
_id | Int! | Numeric identifier for the currency |
code | String! | ISO 4217 currency code (e.g., "USD", "EUR", "INR") |
name | String! | Display name of the currency (e.g., "US Dollar", "Euro") |
symbol | String! | Currency symbol (e.g., "$", "€", "₹") |
decimal | String | Number of decimal places for the currency (e.g., "2") |
groupSeparator | String | Thousands group separator character (e.g., ",") |
decimalSeparator | String | Decimal separator character (e.g., ".") |
currencyPosition | String | Position of currency symbol relative to the amount: "left", "left_with_space", "right", "right_with_space", or null (use system default) |
Common Use Cases
Get Currency Details by IRI ID
graphql
query GetCurrencyByIRI($id: ID!) {
currency(id: $id) {
id
_id
code
name
symbol
currencyPosition
}
}Variables:
json
{
"id": "/api/shop/currencies/1"
}Get Currency Formatting Details
graphql
query GetCurrencyFormatting($id: ID!) {
currency(id: $id) {
code
symbol
decimal
groupSeparator
decimalSeparator
currencyPosition
}
}Get Currency Symbol and Position
graphql
query GetCurrencyDisplay($id: ID!) {
currency(id: $id) {
code
name
symbol
currencyPosition
}
}Validate Currency Existence
graphql
query ValidateCurrency($id: ID!) {
currency(id: $id) {
id
code
}
}Error Handling
Currency Not Found
json
{
"data": {
"currency": null
}
}Missing Required ID Parameter
json
{
"errors": [
{
"message": "Field \"currency\" argument \"id\" of type \"ID!\" is required but not provided."
}
]
}Invalid ID Format
json
{
"errors": [
{
"message": "Invalid ID format. Expected IRI format like \"/api/shop/currencies/1\" or numeric ID"
}
]
}Best Practices
- Always Provide ID - The ID parameter is required for this query
- Check for Null - Handle the case when currency is not found (returns null)
- Use Formatting Fields - Always use
decimal,groupSeparator,decimalSeparator, andcurrencyPositionfor correct price display - Cache Results - Currencies change infrequently; implement caching
- Validate Before Using - Verify currency exists before using in operations
- Use Variables - Use GraphQL variables for dynamic currency queries
- Request Needed Fields - Only request fields you'll actually use
- Display Symbol Correctly - Use
currencyPositionto place symbol on the correct side
Related Resources
- Get Currencies - Retrieve all currencies with pagination
- Get Channel - Channel includes base currency and supported currencies
- Pagination Guide - Cursor pagination documentation
- Shop API Overview - Overview of Shop API resources

