{"id":16698884,"url":"https://github.com/commercelayer/commercelayer-sdk","last_synced_at":"2026-03-10T12:05:00.953Z","repository":{"id":36974695,"uuid":"382263397","full_name":"commercelayer/commercelayer-sdk","owner":"commercelayer","description":"The official Commerce Layer JavaScript library wrapper, that makes it quick and easy to interact with Commerce Layer API.","archived":false,"fork":false,"pushed_at":"2026-03-04T12:18:00.000Z","size":14127,"stargazers_count":30,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-03-04T20:10:32.305Z","etag":null,"topics":["commercelayer"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@commercelayer/sdk","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/commercelayer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-07-02T07:15:42.000Z","updated_at":"2026-03-04T12:17:32.000Z","dependencies_parsed_at":"2023-12-13T09:39:19.011Z","dependency_job_id":"d35c1e69-b2af-4416-9fb3-252dcdc14b6a","html_url":"https://github.com/commercelayer/commercelayer-sdk","commit_stats":{"total_commits":467,"total_committers":8,"mean_commits":58.375,"dds":"0.43897216274089934","last_synced_commit":"ef651b9f96dd28d378d7a4dc2cca84de583bfe7b"},"previous_names":[],"tags_count":348,"template":false,"template_full_name":null,"purl":"pkg:github/commercelayer/commercelayer-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commercelayer%2Fcommercelayer-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commercelayer%2Fcommercelayer-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commercelayer%2Fcommercelayer-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commercelayer%2Fcommercelayer-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/commercelayer","download_url":"https://codeload.github.com/commercelayer/commercelayer-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commercelayer%2Fcommercelayer-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30332885,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T05:25:20.737Z","status":"ssl_error","status_checked_at":"2026-03-10T05:25:17.430Z","response_time":106,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["commercelayer"],"created_at":"2024-10-12T18:04:28.231Z","updated_at":"2026-03-10T12:05:00.939Z","avatar_url":"https://github.com/commercelayer.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Commerce Layer JS SDK\n\n[![Version](https://img.shields.io/npm/v/@commercelayer/sdk.svg)](https://npmjs.org/package/@commercelayer/sdk)\n[![Downloads/week](https://img.shields.io/npm/dw/@commercelayer/sdk.svg)](https://npmjs.org/package/@commercelayer/sdk)\n[![License](https://img.shields.io/npm/l/@commercelayer/sdk.svg)](https://github.com/commercelayer/commercelayer-sdk/blob/master/package.json)\n[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)\n[![Release](https://github.com/commercelayer/commercelayer-sdk/actions/workflows/semantic-release.yml/badge.svg)](https://github.com/commercelayer/commercelayer-sdk/actions/workflows/semantic-release.yml)\n[![CodeQL](https://github.com/commercelayer/commercelayer-cli/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/commercelayer/commercelayer-cli/actions/workflows/codeql-analysis.yml)\n[![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript%205-%230074c1.svg)](https://www.typescriptlang.org/)\n\nA JavaScript Library wrapper that makes it quick and easy to interact with the [Commerce Layer API](https://docs.commercelayer.io/developers).\n\n## What is Commerce Layer?\n\n[Commerce Layer](https://commercelayer.io) is a multi-market commerce API and order management system that lets you add global shopping capabilities to any website, mobile app, chatbot, wearable, voice, or IoT device, with ease. Compose your stack with the best-of-breed tools you already mastered and love. Make any experience shoppable, anywhere, through a blazing-fast, enterprise-grade, and secure API.\n\n## Table of contents\n\n- [Getting started](#getting-started)\n- [Installation](#installation)\n- [Authentication](#authentication)\n- [Import](#import)\n- [Options](#options)\n- [SDK usage](#sdk-usage)\n- [Overriding credentials](#overriding-credentials)\n- [Handling validation errors](#handling-validation-errors)\n- [Using interceptors](#using-interceptors)\n- [Refreshing access token](#refreshing-access-token)\n- [Contributors guide](#contributors-guide)\n- [Need help?](#need-help)\n- [License](#license)\n\n---\n\n## Getting started\n\nTo get started with Commerce Layer JS SDK you need to install it, get the credentials that will allow you to perform your API calls, and import the SDK into your application's code. The sections below explain how to achieve this.\n\n\u003e If you want, you can also read [this tutorial](https://commercelayer.io/blog/getting-started-with-commerce-layer-javascript-sdk) from Commerce Layer's blog.\n\n### Installation\n\nCommerce Layer JS SDK is available as an [npm](https://www.npmjs.com/package/@commercelayer/sdk) and [yarn](https://yarnpkg.com/package/@commercelayer/sdk) package that you can install with the command below:\n\n```shell\nnpm install @commercelayer/sdk\n\n// or\n\nyarn add @commercelayer/sdk\n```\n\n### Authentication\n\nAll requests to Commerce Layer API must be authenticated with an [OAuth2](https://oauth.net/2) bearer token. Hence, before starting to use this SDK you need to get a valid access token. Kindly check [our documentation](https://docs.commercelayer.io/developers/authentication) for more information about the available authorization flows.\n\n\u003e Feel free to use [Commerce Layer JS Auth](https://github.com/commercelayer/commercelayer-js-auth), a JavaScript library that helps you wrap our authentication API.\n\n### Import\n\nYou can use the ES6 default import with the SDK like so:\n\n```javascript\nimport CommerceLayer from '@commercelayer/sdk'\n\n/*\n * Organization slug is no longer required as it is taken from the    \n * information included in the access token\n*/\nconst cl = CommerceLayer({\n  accessToken: 'your-access-token'\n})\n```\n\nStarting from version v7.x, in order to enable the tree-shaking feature used by bundlers to reduce the size of the created package, you can import separately the client and the required resources.\nUse `client` to setup the SDK access special features like *interceptors*, *raw response* or *auto token refresh* and use `resources` to interact with the API.\n\n```javascript\nimport CommerceLayer, { orders, skus } from '@commercelayer/sdk'\n\nconst cl = CommerceLayer({ accessToken })\ncl.addRawResponseReader()\n\nconst orderList = await orders.list()\nconst skuList = await skus.list()\n```\n\nYou can still use the old style bundle client importing it directly (together with all the included resources, this will increase your final package size).\n\n```javascript\nimport { CommerceLayer } from '@commercelayer/sdk/bundle'\n\nconst cl = CommerceLayer({ accessToken })\ncl.addRawResponseReader()\n\nconst orderList = await cl.orders.list()\nconst skuList = await cl.skus.list()\n```\n\n### Options\n\nWhen instantiating a new SDK client you can pass some options to initialize it:\n\n```javascript\n{\n  organization?: string       // The organization slug\n  accessToken: string         // A valid API access token\n  timeout?: number            // A custom request timout (\u003c= 15 secs [default])\n  headers?: RequestHeaders    // Custom request headers\n  userAgent?: string          // Custom user-agent useful in certaing contexts but often not allowed by browsers\n  fetch?: Fetch               // A specific fetch implementation \n  refreshToken?: RefreshToken // A function responsible for token refresh\n}\n```\n\nSame options can be changed after SDK initialization or passed at runtime while executing an API call:\n\n```javascript\n  const options = { ... }\n\n  // Instantiate the client using desired options\n  const cl = CommerceLayer(options)\n\n  // Change configuration after client cteation\n  cl.config(options)\n\n  // Use runtime configuration without persisting settings\n  customers.list({}, options)\n```\n\n## SDK usage\n\nThe JavaScript SDK is a wrapper around Commerce Layer API which means you would still be making API requests but with a different syntax. For now, we don't have comprehensive SDK documentation for every single resource our API supports (about 400+ endpoints), hence you will need to rely on our comprehensive [API Reference](https://docs.commercelayer.io/core/v/api-reference) as you go about using this SDK. So for example, if you want to create an order, take a look at the [Order object](https://docs.commercelayer.io/core/v/api-reference/orders/object) or the [Create an order](https://docs.commercelayer.io/core/v/api-reference/orders/create) documentation to see the required attributes and/or relationships. The same goes for every other supported resource.\n\nTo show you how things work, we will use the [SKUs](https://docs.commercelayer.io/core/v/api-reference/skus) and [Shipping Categories](https://docs.commercelayer.io/core/v/api-reference/shipping_categories) resource in the following examples. The code snippets below show how to use the SDK when performing the standard CRUD operations provided by our REST API. Kindly check our [API reference](https://docs.commercelayer.io/core/v/api-reference) for the complete list of available **resources** and their **attributes**.\n\n### Create\n\n\u003cdetails\u003e\n\u003csummary\u003eHow to create an SKU\u003c/summary\u003e\n\u003cbr /\u003e\n\n```javascript\n  // Select the shipping category (it's a required relationship for the SKU resource)\n  const shippingCategories = await shipping_categories.list({ filters: { name_eq: 'Merchandising' } })\n\n  const attributes = {\n    code: 'TSHIRTMM000000FFFFFFXL',\n    name: 'Black Men T-shirt with White Logo (XL)',\n    description: \"A very beautiful and cozy mens t-shirt\",\n    weight: \"500\",\n    unit_of_weight: \"gr\"\n    shipping_category: shipping_categories.relationship(shippingCategories[0].id), // assigns the relationship\n  }\n\n  const newSku = await skus.create(attributes)\n```\n\nℹ️ Check our API reference for more information on how to [create an SKU](https://docs.commercelayer.io/developers/v/api-reference/skus/create).\n\u003c/details\u003e\n\n### Retrieve / List\n\n\u003cdetails\u003e\n\u003csummary\u003eHow to fetch a single SKU\u003c/summary\u003e\n\u003cbr /\u003e\n\n```javascript\n  // Fetch the SKU by ID\n  const sku = await skus.retrieve('BxAkSVqKEn')\n\n  // Fetch all SKUs and filter by code\n  const skuList = await skus.list({ filters: { code_eq: 'TSHIRTMM000000FFFFFFXLXX' } })\n\n  // Fetch the first SKU of the list\n  const skuList = (await skus.list()).first()\n\n  // Fetch the last SKU of the list\n  const skuList = (await skus.list()).last()\n```\n\nℹ️ Check our API reference for more information on how to [retrieve an SKU](https://docs.commercelayer.io/developers/v/api-reference/skus/retrieve).\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eHow to fetch a collection of SKUs\u003c/summary\u003e\n\u003cbr /\u003e\n\n```javascript\n  // Fetch all the SKUs\n  const skuList = await skus.list()\n```\n\nWhen fetching a collection of resources you can leverage the `meta` attribute to get its `meta` information like so:\n\n```javascript\n  const skuList = await skus.list()\n  const meta = skus.meta\n```\n\nℹ️ Check our API reference for more information on how to [list all SKUs](https://docs.commercelayer.io/developers/v/api-reference/skus/list).\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eHow to fetch a collection of SKUs and sort the results\u003c/summary\u003e\n\u003cbr /\u003e\n\n```javascript\n  // Sort the results by creation date in ascending order (default)\n  const skuList = await skus.list({ sort: { created_at: 'asc' } })\n\n  // Sort the results by creation date in descending order\n  const skuList = await skus.list({ sort: { created_at: 'desc' } })\n  ```\n\nℹ️ Check our API reference for more information on how to [sort results](https://docs.commercelayer.io/developers/sorting-results).\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eHow to fetch a collection of SKUs and include associations\u003c/summary\u003e\n\u003cbr /\u003e\n\n```javascript\n  // Include an association (prices)\n  const skuList = await skus.list({ include: [ 'prices' ] })\n\n  // Include an association (stock items)\n  const skuList = await skus.list({ include: [ 'stock_items' ] })\n  ```\n\nℹ️ Check our API reference for more information on how to [include associations](https://docs.commercelayer.io/developers/including-associations).\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eHow to fetch a collection of SKUs and return specific fields (sparse fieldsets)\u003c/summary\u003e\n\u003cbr /\u003e\n\n```javascript\n  // Request the API to return only specific fields\n  const skuList = await skus.list({ fields: { skus: [ 'name', 'metadata' ] } })\n\n  // Request the API to return only specific fields of the included resource\n  const skuList = await skus.list({ include: [ 'prices' ], fields: { prices: [ 'currency_code', 'formatted_amount' ] } })\n  ```\n\nℹ️ Check our API reference for more information on how to [use sparse fieldsets](https://docs.commercelayer.io/developers/sparse-fieldsets).\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eHow to fetch a collection of SKUs and filter data\u003c/summary\u003e\n\u003cbr /\u003e\n\n```javascript\n  // Filter all the SKUs fetching only the ones whose code starts with the string \"TSHIRT\"\n  const skuList = await skus.list({ filters: { code_start: 'TSHIRT' } })\n\n  // Filter all the SKUs fetching only the ones whose code ends with the string \"XLXX\"\n  const skuList = await skus.list({ filters: { code_end: 'XLXX' } })\n\n  // Filter all the SKUs fetching only the ones whose name contains the string \"White Logo\"\n  const skuList = await skus.list({ filters: { name_cont: 'White Logo' } })\n\n  // Filter all the SKUs fetching only the ones created between two specific dates\n  // (filters combined according to the AND logic)\n  const skuList = await skus.list({ filters: { created_at_gt: '2018-01-01', created_at_lt: '2018-01-31'} })\n\n  // Filters all the SKUs fetching only the ones created or updated after a specific date\n  // (attributes combined according to the OR logic)\n  const skuList = await skus.list({ filters: { updated_at_or_created_at_gt: '2019-10-10' } })\n\n  // Filters all the SKUs fetching only the ones whose name contains the string \"Black\"\n  // and whose shipping category name starts with the string \"MERCH\"\n  const skuList = await skus.list({ filters: { name_cont: 'Black', shipping_category_name_start: 'MERCH'} })\n  ```\n\nℹ️ Check our API reference for more information on how to [filter data](https://docs.commercelayer.io/developers/filtering-data).\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eHow to paginate a collection of SKUs\u003c/summary\u003e\n\u003cbr /\u003e\n\nWhen you fetch a collection of resources, you get paginated results. You can request specific pages or items in a page like so:\n\n```javascript\n  // Fetch the SKUs, setting the page number to 3 and the page size to 5\n  const skuList = await skus.list({ pageNumber: 3, pageSize: 5 })\n\n  // Get the total number of SKUs in the collection\n  const skuCount = skus.meta.recordCount\n\n  // Get the total number of pages\n  const pageCount = skus.meta.pageCount\n```\n\n\u003e PS: the default page number is **1**, the default page size is **10**, and the maximum page size allowed is **25**.\n\nℹ️ Check our API reference for more information on how [pagination](https://docs.commercelayer.io/developers/pagination) works.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eHow to iterate through a collection of SKUs\u003c/summary\u003e\n\u003cbr /\u003e\n\nTo execute a function for every item of a collection, use the `map()` method like so:\n\n```javascript\n  // Fetch the whole list of SKUs (1st page) and print their names and codes to console\n  const skuList = await skus.list()\n  skus.map(p =\u003e console.log('Product: ' + p.name + ' - Code: ' + p.code))\n```\n\n\u003c/details\u003e\n\n\u003c!-- \u003cdetails\u003e\n\u003csummary\u003eHow to build complex queries\u003c/summary\u003e\n\u003cbr /\u003e\n\nComing soon...\n\u003c/details\u003e --\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eHow to fetch resource relationships\u003c/summary\u003e\n\u003cbr /\u003e\n\nMany resources have relationships with other resources and instead of including these associations as seen above, you can fetch them directly. This way, in the case of 1-to-N relationships, you can filter or sort the resulting collection as standard resources.\n\n```javascript\n// Fetch 1-to-1 related resource: billing address of an order\nconst billingAddress = await orders.billing_address('xYZkjABcde')\n\n// Fetch 1-to-N related resources: orders associated to a customer\nconst orders = await customers.orders('XyzKjAbCDe', { fields: ['status', 'number'] })\n```\n\nIn general:\n\n- An API endpoint like `/api/customers` or `/api/customers/\u003ccustomerId\u003e` translates to `cl.customers` or `cl.customers('\u003ccustomerId\u003e')` with the SDK.\n- 1-to-1 relationship API endpoints like `/api/orders/\u003corderId\u003e/shipping_address` translates to `cl.orders('\u003corderId\u003e', { include: ['shipping_address'] }}` with the SDK.\n- 1-to-N relationship API endpoints like  `/api/customers/\u003ccustomerId\u003e?include=orders` or `/api/customers/\u003ccustomerId\u003e/orders` translates to `cl.customers.retrieve('\u003ccustomerId\u003e', { include: ['orders'] })` or `cl.customers.orders('\u003ccustomerId\u003e')` with the SDK.\n\nℹ️ Check our API reference for more information on how to [fetch relationships](https://docs.commercelayer.io/core/fetching-relationships).\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eHow to count resources\u003c/summary\u003e\n\u003cbr /\u003e\n\nMany times you simply need to count how many resources exist with\ncertain characteristics. You can then call the special `count`\nfunction passing a filter to get as result the total number of\nresources.\n\n```javascript\n// Get the total number of placed orders\nconst placedOrders = await cl.orders.count({ filters: { status_eq: 'placed' } })\n\n```\n\n\u003c/details\u003e\n\n### Update\n\n\u003cdetails\u003e\n\u003csummary\u003eHow to update an existing SKU\u003c/summary\u003e\n\u003cbr /\u003e\n\n```javascript\n  const sku = {\n    id: 'xYZkjABcde',\n    description: 'Updated description...',\n    imageUrl: 'https://img.yourdomain.com/skus/new-image.png'\n  }\n\n  skus.update(sku) // updates the SKU on the server\n```\n\nℹ️ Check our API reference for more information on how to [update an SKU](https://docs.commercelayer.io/developers/v/api-reference/skus/update).\n\u003c/details\u003e\n\n### Delete\n\n\u003cdetails\u003e\n\u003csummary\u003eHow to delete an existing SKU\u003c/summary\u003e\n\u003cbr /\u003e\n\n```javascript\n  skus.delete('xYZkjABcde') // persisted deletion\n```\n\nℹ️ Check our API reference for more information on how to [delete an SKU](https://docs.commercelayer.io/developers/v/api-reference/skus/delete).\n\u003c/details\u003e\n\n## Overriding credentials\n\nIf needed, Commerce Layer JS SDK lets you change the client configuration and set it at a request level. To do that, just use the `config()` method or pass the `options` parameter and authenticate the API call with the desired credentials:\n\n```javascript\n  // Permanently change configuration at client level\n  cl.config({ organization: 'you-organization-slug', accessToken: 'your-access-token' })\n  const skuList = await skus.list()\n\n  or\n\n  // Use configuration at request level\n  skus.list({}, { organization: 'you-organization-slug', accessToken: 'your-access-token' })\n```\n\n## Handling validation errors\n\nCommerce Layer API returns specific errors (with extra information) on each attribute of a single resource. You can inspect them to properly handle validation errors (if any). To do that, use the `errors` attribute of the catched error:\n\n```javascript\n  // Log error messages to console:\n  const attributes = { code: 'TSHIRTMM000000FFFFFFXL', name: '' }\n\n  const newSku = await skus.create(attributes).catch(error =\u003e console.log(error.errors))\n\n  // Logged errors\n  /*\n  [\n    {\n      title: \"can't be blank\",\n      detail: \"name - can't be blank\",\n      code: 'VALIDATION_ERROR',\n      source: { pointer: '/data/attributes/name' },\n      status: '422',\n      meta: { error: 'blank' }\n    },\n    {\n      title: 'has already been taken',\n      detail: 'code - has already been taken',\n      code: 'VALIDATION_ERROR',\n      source: { pointer: '/data/attributes/code' },\n      status: '422',\n      meta: { error: 'taken', value: 'TSHIRTMM000000FFFFFFXL' }\n    },\n    {\n      title: \"can't be blank\",\n      detail: \"shipping_category - can't be blank\",\n      code: 'VALIDATION_ERROR',\n      source: { pointer: '/data/relationships/shipping_category' },\n      status: '422',\n      meta: { error: 'blank' }\n    }\n  ]\n  */\n\n```\n\nℹ️ Check our API reference for more information about the [errors](https://docs.commercelayer.io/developers/handling-errors) returned by the API.\n\n## Using interceptors\n\nYou can use interceptors to intercept SDK messages and modify them on the fly before the request is sent to the API or before the response is parsed and returned by the client. You can also access the error object before it is thrown by the SDK.\n\nInterceptors are special functions that are able to handle SDK messages and return a (eventually) modified version of them for use by the client.\n\n```javascript\n  const requestInterceptor = (request: RequestObj): RequestObj =\u003e {\n    console.log(request)\n    return request\n  }\n\n  const responseInterceptor = (response: ResponseObj): ResponseObj =\u003e {\n    console.log(response)\n    return response\n  }\n\n  const errorInterceptor = (error: ErrorObj): ErrorObj =\u003e {\n    console.log(error)\n    return error\n  }\n```\n\nHere an example of how to use them:\n\n```javascript\n  // Add the interceptors (only one or all if needed)\n  cl.addRequestInterceptor(requestInterceptor)\n  cl.addResponseInterceptor(responseInterceptor, errorInterceptor)\n\n  const customerList = await customers.list()\n\n  // Remove interceptors\n  // Tt is possible to remove only a specific interceptor: cl.removeInterceptor('request')\n  cl.removeInterceptors()\n```\n\n#### Raw Response Reader\n\nThe *RawResponseReader* is a special interceptor that allows to catch the original message coming frome the API before it is parsed and translated in SDK objects.\n\n```javascript\n  // Add a RawResponseReader capable of capturing also response headers\n  const rrr = cl.addRawResponseReader({ headers: true })\n  \n  const customerList = await customers.list()\n\n  cl.removeRawResponseReader()\n\n  console.log(rrr.rawResponse)\n  console.log(rrr.headers)\n```\n\n## Refreshing access token\n\nIt is possible that you are using an access token that is about to expire especially if it has been used for many API calls.\nIn this case you can define a special function that takes care of refreshing the token when a call fails because it has expired.\n\n```javascript\n  async function myRefreshTokenFunction(espiredToken: string): Promise\u003cstring\u003e {\n    // Get a new access token using for example our js-auth library\n    return (await getAccessToken()).accessToken\n  }\n\n  cl.config({ refreshToken: myRefreshTokenFunction })\n\n  // If needed you can later retrieve the new access token\n  const newToken = cl.currentAccessToken\n```\n\n## Contributors guide\n\n1. Fork [this repository](https://github.com/commercelayer/commercelayer-sdk) (learn how to do this [by reading the GitHub documentation](https://help.github.com/articles/fork-a-repo)).\n\n2. Clone the forked repository like so:\n\n    ```shell\n    git clone https://github.com/\u003cyour username\u003e/commercelayer-sdk.git \u0026\u0026 cd commercelayer-sdk\n    ```\n\n3. Make your changes and create a pull request ([learn how to do this](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request)).\n\n4. Someone will attend to your pull request and provide some feedback.\n\n## Need help?\n\n- Join [Commerce Layer's Discord community](https://discord.gg/commercelayer).\n- Ping us on [Bluesky](https://bsky.app/profile/commercelayer.io), [X (formerly Twitter)](https://x.com/commercelayer), or [LinkedIn](https://www.linkedin.com/company/commerce-layer).\n- Is there a bug? Create an [issue](https://github.com/commercelayer/commercelayer-sdk/issues) on this repository.\n\n## License\n\nThis repository is published under the [MIT](LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommercelayer%2Fcommercelayer-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcommercelayer%2Fcommercelayer-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommercelayer%2Fcommercelayer-sdk/lists"}