Skip to main content
GET
/
store
/
customers
/
me
/
addresses
JS SDK
import Medusa from "@medusajs/js-sdk"

let MEDUSA_BACKEND_URL = "http://localhost:9000"

if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
  MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
}

export const sdk = new Medusa({
  baseUrl: MEDUSA_BACKEND_URL,
  debug: process.env.NODE_ENV === "development",
  publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
})

// TODO must be authenticated as the customer to list their addresses
sdk.store.customer.listAddress()
.then(({ addresses, count, offset, limit }) => {
  console.log(addresses)
})
{
  "limit": 123,
  "offset": 123,
  "count": 123,
  "addresses": [
    {
      "id": "<string>",
      "address_name": "<string>",
      "is_default_shipping": true,
      "is_default_billing": true,
      "customer_id": "<string>",
      "company": "<string>",
      "first_name": "<string>",
      "last_name": "<string>",
      "address_1": "<string>",
      "address_2": "<string>",
      "city": "<string>",
      "country_code": "usd",
      "province": "us-ca",
      "postal_code": "<string>",
      "phone": "<string>",
      "metadata": {},
      "created_at": "2023-11-07T05:31:56Z",
      "updated_at": "2023-11-07T05:31:56Z"
    }
  ],
  "estimate_count": 123
}

Authorizations

connect.sid
string
cookie
required

Headers

x-publishable-api-key
string
required

Publishable API Key created in the Medusa Admin.

x-medusa-locale
string

The locale in BCP 47 format to retrieve localized content.

Example:

"en-US"

Query Parameters

city

Filter by the address's city. Filter by a city.

postal_code

Filter by the address's postal code. Filter by a postal code.

country_code

Filter by the address's country code. Filter by a country code.

q
string

Search term to filter the address's searchable properties.

company

Filter addresses by company.

province

Filter addresses by province.

$and
$and · object[]

Join query parameters with an AND condition. Each object's content is the same type as the expected query parameters.

$or
$or · object[]

Join query parameters with an OR condition. Each object's content is the same type as the expected query parameters.

locale
string

The locale in BCP 47 format to retrieve localized content.

Example:

"en-US"

Response

OK

The paginated list of customer addresses.

limit
number
required

The maximum number of items returned.

offset
number
required

The number of items skipped before retrieving the returned items.

count
number
required

The total number of items.

addresses
object[]
required

The list of addresses.

estimate_count
number

The estimated count retrieved from the PostgreSQL query planner, which may be inaccurate.