Skip to main content
Skip to main content

AdminCurrenciesResource

This class is used to send requests to Admin Currency API Routes. All its method are available in the JS Client under the medusa.admin.currencies property.

All methods in this class require user authentication.

A store can use unlimited currencies, and each region must be associated with at least one currency. Currencies are defined within the Medusa backend. The methods in this class allow admins to list and update currencies.

Related Guide: How to manage currencies.

Methods

list

Retrieve a list of currencies. The currencies can be filtered by fields such as code. The currencies can also be sorted or paginated.

Example

To list currencies:

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.currencies.list()
.then(({ currencies, count, offset, limit }) => {
console.log(currencies.length);
})

By default, only the first 20 records are retrieved. You can control pagination by specifying the limit and offset properties:

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.currencies.list({
limit,
offset
})
.then(({ currencies, count, offset, limit }) => {
console.log(currencies.length);
})

Parameters

customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Filters and pagination configurations to apply on retrieved currencies.

Returns

ResponsePromiseResponsePromise<AdminCurrenciesListRes>Required
Resolves to the list of currencies with pagination fields.

update

Update a Currency's details.

Example

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.currencies.update(code, {
includes_tax: true
})
.then(({ currency }) => {
console.log(currency.code);
})

Parameters

codestringRequired
The code of the currency to update.
The attributes to update in the currency.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminCurrenciesRes>Required
Resolves to the currency's details.
Was this section helpful?