> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kicks.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# StockX API with JavaScript

> Collecting products from StockX API using KicksDB and JavaScript

Requesting products from StockX API is straightforward using KicksDB and `fetch` API in JavaScript.

```js theme={null}
const API_KEY = "your-api-key";
const URL = "https://api.kicks.dev/v3/stockx/products";
const params = new URLSearchParams({
  query: "Nike Dunk SB Low Fog",
});

const response = await fetch(`${URL}?${params.toString()}`, {
  headers: {
    Authorization: `Bearer ${API_KEY}`,
  },
});
const data = await response.json();

for (const product of data.data) {
  console.log(`${product.title} - ${product.sku}`);
}
```

It should output something like this:

```log theme={null}
Nike SB Dunk Low Fog - BQ6817-010
Nike SB Dunk Low Black Midnight Fog - 304292-025
Nike SB Dunk Low Obsidian Midnight Fog Black - 304292-403
Nike SB Dunk Low Supreme 94 Ocean Fog - HQ8487-400
Nike Dunk SB Low Krampus - HV1668-001
Nike SB Dunk Low Mummy - DM0774-111
Nike SB Dunk Low Piet Mondrian - 304292-702
...
```

## Recommendations

* Avoid storing API key in your code, use environment variables instead (`process.env`).
* More parameters can be added to the request, see the [API reference](https://api.kicks.dev/docs#tag/stockx/get/v3stockxproducts) for more information.
* Prefer `async/await` over `then/catch` for better readability.
* You might be interested in [OpenAPI Generator](https://openapi-generator.tech/) to generate client libraries for your favorite programming language, it might help you to interact with the API in a more convenient way.
