Skip to content

Get Currencies

About

The currencies query retrieves currency information from your store with support for pagination and detailed field access. This query is essential for:

  • Displaying available currency options for store visitors
  • Building currency selector/switcher interfaces
  • Retrieving currency formatting details (symbol, position, separators)
  • Managing multi-currency pricing configurations
  • Formatting prices correctly based on currency settings

The query supports cursor-based pagination and allows you to fetch all currencies with full field access.

Arguments

ArgumentTypeRequiredDescription
firstIntNoNumber of currencies to retrieve from the start (forward pagination). Max: 100.
afterStringNoCursor to start after for forward pagination.
lastIntNoNumber of currencies to retrieve from the end (backward pagination). Max: 100.
beforeStringNoCursor to start before for backward pagination.

Possible Returns

FieldTypeDescription
edges[CurrencyEdge!]!Array of currency edges containing currencies and cursors.
edges.nodeCurrency!The actual currency object with id, code, name, symbol, and other fields.
edges.cursorString!Pagination cursor for this currency. Use with after or before arguments.
pageInfoPageInfo!Pagination metadata object.
pageInfo.hasNextPageBoolean!Whether more currencies exist after the current page.
pageInfo.hasPreviousPageBoolean!Whether currencies exist before the current page.
pageInfo.startCursorStringCursor of the first currency on the current page.
pageInfo.endCursorStringCursor of the last currency on the current page.
totalCountInt!Total number of currencies available.

Currency Fields

FieldTypeDescription
idString!Unique identifier in format /api/shop/currencies/{id}
_idInt!Numeric identifier for the currency
codeString!ISO 4217 currency code (e.g., "USD", "EUR", "INR")
nameString!Display name of the currency (e.g., "US Dollar", "Euro")
symbolString!Currency symbol (e.g., "$", "€", "₹")
decimalStringNumber of decimal places for the currency (e.g., "2")
groupSeparatorStringThousands group separator character (e.g., ",")
decimalSeparatorStringDecimal separator character (e.g., ".")
currencyPositionStringPosition of currency symbol relative to the amount: "left", "left_with_space", "right", "right_with_space", or null (use system default)

Common Use Cases

Display All Available Currencies

graphql
query GetAllCurrencies {
  currencies {
    edges {
      node {
        id
        code
        name
        symbol
      }
    }
  }
}

Build Currency Selector

graphql
query GetCurrenciesForSelector {
  currencies {
    edges {
      node {
        code
        name
        symbol
        currencyPosition
      }
    }
  }
}

Get Currency Formatting Details

graphql
query GetCurrencyFormatting {
  currencies {
    edges {
      node {
        code
        symbol
        decimal
        groupSeparator
        decimalSeparator
        currencyPosition
      }
    }
    totalCount
  }
}

Get Currencies with Pagination

graphql
query GetCurrenciesWithPagination($first: Int!) {
  currencies(first: $first) {
    edges {
      cursor
      node {
        id
        code
        name
        symbol
      }
    }
    pageInfo {
      hasNextPage
      hasPreviousPage
      startCursor
      endCursor
    }
    totalCount
  }
}

Error Handling

Missing Currencies Configuration

json
{
  "data": {
    "currencies": {
      "edges": [],
      "pageInfo": {
        "hasNextPage": false,
        "hasPreviousPage": false,
        "startCursor": null,
        "endCursor": null
      },
      "totalCount": 0
    }
  }
}

Invalid Pagination Parameters

json
{
  "errors": [
    {
      "message": "Argument \"first\" must be between 1 and 100"
    }
  ]
}

Invalid Cursor

json
{
  "errors": [
    {
      "message": "Invalid cursor provided"
    }
  ]
}

Best Practices

  1. Cache Currencies - Currencies change infrequently; implement client-side caching
  2. Use Formatting Fields - Always use decimal, groupSeparator, decimalSeparator, and currencyPosition for correct price formatting
  3. Request Only Needed Fields - Reduce payload by selecting specific fields
  4. Display Symbol Correctly - Use currencyPosition to place symbol on the correct side of the amount
  5. Paginate When Needed - For systems with many currencies, use pagination
  6. Use Variables - Use GraphQL variables for dynamic currency queries

Released under the MIT License.