For the complete documentation index, see llms.txt. This page is also available as Markdown.

Fetching resources

How to fetch single resources or collections

You can fetch either single resources or collections by sending GET requests to the resource endpoints.

Authentication

Examples

Fetching a single SKU

The following request fetches a single SKU, the one identified by the ID "xYZkjABcde":

curl -g -X GET \
  'https://yourdomain.commercelayer.io/api/skus/xYZkjABcde' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' 

On success, the API responds with a 200 OK status code, returning a single resource object:

{
  "data": {
    "id": "xYZkjABcde",
    "type": "skus",
    "links": { ... },
    "attributes": {
      "code": "TSHIRTMM000000FFFFFFXLXX",
      "name": "Men's Black T-shirt with White Logo (XL)",
      "description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
      "image_url": "https://img.yourdomain.com/skus/xYZkjABcde.png",
      "tag_names": "Men, Black, XL",
      "pieces_per_pack": 6,
      "weight": 300.0,
      "unit_of_weight": "gr",
      "hs_tariff_number": null,
      "do_not_ship": false,
      "do_not_track": false,
      "inventory": {
        "available": true,
        "quantity": 10,
        "levels": [
          {
            "quantity": 4,
            "delivery_lead_times": [
              {
                "shipping_method": {
                  "name": "Standard Shipping",
                  "reference": null,
                  "price_amount_cents": 700,
                  "free_over_amount_cents": 9900,
                  "formatted_price_amount": "€7,00",
                  "formatted_free_over_amount": "€99,00"
                },
                "min": {
                  "hours": 72,
                  "days": 3
                },
                "max": {
                  "hours": 120,
                  "days": 5
                }
              },
              {
                "shipping_method": {
                  "name": "Express Delivery",
                  "reference": null,
                  "price_amount_cents": 1200,
                  "free_over_amount_cents": null,
                  "formatted_price_amount": "€12,00",
                  "formatted_free_over_amount": null
                },
                "min": {
                  "hours": 48,
                  "days": 2
                },
                "max": {
                  "hours": 72,
                  "days": 3
                }
              }
            ]
          },
          {
            "quantity": 6,
            "delivery_lead_times": [
              {
                "shipping_method": {
                  "name": "Standard Shipping",
                  "reference": null,
                  "price_amount_cents": 700,
                  "free_over_amount_cents": 9900,
                  "formatted_price_amount": "€7,00",
                  "formatted_free_over_amount": "€99,00"
                },
                "min": {
                  "hours": 96,
                  "days": 4
                },
                "max": {
                  "hours": 144,
                  "days": 6
                }
              },
              {
                "shipping_method": {
                  "name": "Express Delivery",
                  "reference": null,
                  "price_amount_cents": 1200,
                  "free_over_amount_cents": null,
                  "formatted_price_amount": "€12,00",
                  "formatted_free_over_amount": null
                },
                "min": {
                  "hours": 72,
                  "days": 3
                },
                "max": {
                  "hours": 96,
                  "days": 4
                }
              }
            ]
          }
        ]
      },
      "created_at": "2018-01-01T12:00:00.000Z",
      "updated_at": "2018-01-01T12:00:00.000Z",
      "reference": "ANYREFEFERNCE",
      "metadata": {
        "foo": "bar"
      }
    },
    "relationships": {
      "shipping_category": {
        "links": { ... }
      },
      "prices": {
        "links": { ... }
      },
      "stock_items": {
        "links": { ... }
      },
      "delivery_lead_times": {
        "links": { ... }
      },
      "sku_options": {
        "links": { ... }
      }
    },
    "meta": {
      "created_with_version": "2017-08"
    }
  },
  "meta": {
    "api_version": "2017-08",
    "api_versions": [ "2017-08", "2026-05" ],
    "mode": "test",
    "organization_id": "NqYgBkHmEe",
    "trace_id": "4a7c9e3b1d5f8a2c6e0b4d7f1a5c3e9b7d2f6a0c4e8b1d3f7a9c5e2b6d0f4a8c"
  }
}

Fetching a collection of SKUs

The following request fetches a collection of SKUs:

curl -g -X GET \
  'https://yourdomain.commercelayer.io/api/skus' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' 

On success, the API responds with a 200 OK status code, returning a paginated collection of the resource objects:

{
  "data": [
    {
      "id": "xYZkjABcde",
      "type": "skus",
      "links": { ... },
      "attributes": {
        "code": "TSHIRTMM000000FFFFFFXLXX",
        "name": "Men's Black T-shirt with White Logo (XL)",
        "description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
        "image_url": "https://img.yourdomain.com/skus/xYZkjABcde.png",
        "tag_names": "Men, Black, XL",
        "pieces_per_pack": 6,
        "weight": 300.0,
        "unit_of_weight": "gr",
        "hs_tariff_number": null,
        "do_not_ship": false,
        "do_not_track": false,
        "created_at": "2018-01-01T12:00:00.000Z",
        "updated_at": "2018-01-01T12:00:00.000Z",
        "reference": "ANYREFEFERNCE",
        "metadata": {
          "foo": "bar"
        }
      },
      "relationships": {
        "shipping_category": {
          "links": { ... }
        },
        "prices": {
          "links": { ... }
        },
        "stock_items": {
          "links": { ... }
        },
        "delivery_lead_times": {
          "links": { ... }
        },
        "sku_options": {
          "links": { ... }
        }
      },
      "meta": {
        "created_with_version": "2017-08"
      }
    },
    {
      "other": "... 9 skus (first page)"
    }
  ],
  "meta": {
    "api_version": "2017-08",
    "api_versions": [ "2017-08", "2026-05" ],
    "record_count": 140,
    "page_count": 14,
    "page_number": 1,
    "page_size": 10,
    "mode": "test",
    "organization_id": "NqYgBkHmEe",
    "trace_id": "e9b5d2f8a4c0e7b3d6f1a8c4e2b9d5f3a7c1e4b8d0f6a2c7e3b1d9f5a6c2e0b8"
  },
  "links": {
    "first": "https://yourdomain.commercelayer.io/api/skus?page[number]=1&page[size]=10",
    "next": "https://yourdomain.commercelayer.io/api/skus?page[number]=2&page[size]=10",
    "last": "https://yourdomain.commercelayer.io/api/skus?page[number]=14&page[size]=10"
  }
}
Pagination

When fetching SKUs with a market in scope only the SKUs that are sellable in that market are returned. To be sellable in a market an SKU must have a price in the market's price list and at least one stock item in one of the market's stock locations, regardless of its quantity.

Last updated