1. Home
  2. Docs
  3. Hub API
  4. Guides and Tutorials
  5. Finding the product ID for a SKU

Finding the product ID for a SKU

The GET /products endpoint can be used to find a product ID for a known SKU with the text filter. To search for a list of products by SKU, make a GET request to /products with a query string of text=<SKU you are searching for>. For example, if you were looking for the SKU SKU-ABC123 you should make a GET request to /products?text=SKU-ABC123. This will return all products with a matching SKU or name.

Hub will also return partial matches for products, so if there are products with SKUs SKU-ABC123, SKU-ABC456 and SKU-ABC789 a search for SKU-ABC will return all three products.

The returned object from Hub will be an array of matching products, even if only a single product is matched (or an empty array if no products are matched) For example a call to /products?text=SKU-ABC123 may return:

[
  {
    "id": 1,
    "name": "A New Phone",
    "product_code": "SKU-ABC123"
    // Object shortened for brevity
  }
]

The id field of the desired object can then be used as the product in the basket and order endpoints.

Alternatively, if you already know the full SKU of the product that you wish to order, when adding line items to an order or basket you can instead specify product_code with the SKU that you wish to purchase in place of the product. If both product_code and product are specified in a line item, the product will take precedence as documented here: https://developer.siphonnetworks.com/hub-api-specification/#operation/postBasket

Caching

The product ID to SKU mapping is generated at the time the product is created in Hub and rarely changes. As such, we strongly advise caching the product ID mapping in your own app. Theoretically the mapping may change in future, so your application should allow the cache to be refreshed if needed.

Was this article helpful to you? Yes No

How can we help?