# Make your first API request
Create a read-only API key, check that it works, and list your products with curl, JavaScript or Ruby.
This quickstart takes about five minutes. You create a key that can only read, check that it works, and list the products in your store. Nothing in your store changes.
## Before you start
- You can sign in to your Crate dashboard as the owner, or as a teammate who can manage settings.
- Your email address is confirmed. Crate won't create API keys until it is.
- You have a terminal with `curl`, or Node.js 18 or later, or Ruby.
## Step 1: Create a read-only key
1. Open **Settings**, then choose **API keys** under **Developer**.
2. Click **Create API key**.
3. Enter a **Name**, such as "First request".
4. Under **Permissions**, choose **Read Only**.
5. Leave **Expiration** on **Never**, or choose **30 days** for a key you only need today.
6. Click **Create API key**.
```screenshot developers/api-quickstart/01-create-read-only
alt: The Create new API key window with the name First request and Read Only selected
caption: A Read Only key can look at your store but can't change it.
```
## Step 2: Copy the key
The **API key created** window shows the key once. Click **Copy**, then **Done**. Keys start with `crate_pat_`.
```screenshot developers/api-quickstart/02-key-created
alt: The API key created window with the key blurred and the Copy and Done buttons
caption: Copy the key before you click Done.
```
Save the key in a shell variable so it stays out of your commands:
```bash
export CRATE_API_KEY="crate_pat_your_key_here"
```
> [!NOTE]
> In the examples below, replace `https://<crate-address>` with the address you use to sign in to your dashboard. Every API path starts with `/api/v1`.
## Step 3: Check that the key works
The account endpoint needs no permission beyond a valid key. It is the quickest way to test one.
```bash
curl https://<crate-address>/api/v1/account \
  -H "Authorization: Bearer $CRATE_API_KEY"
```
A working key returns your store and the key's details:
```json
{
  "account": {
    "store": { "id": 12, "name": "Harbour & Hearth", "code": "harbour-hearth", "url": "…", "currency": "USD" },
    "token": { "type": "personal_access_token", "name": "First request", "scopes": ["read_products", "read_orders", "…"], "last_used_at": "…" },
    "api_version": "v1"
  }
}
```
`scopes` lists what the key may do. A **Read Only** key holds a `read_` scope for every group.
## Step 4: List your products
Ask for the first three products. `limit` sets how many come back.
### curl
```bash
curl "https://<crate-address>/api/v1/products?limit=3" \
  -H "Authorization: Bearer $CRATE_API_KEY"
```
### JavaScript
```js
const res = await fetch("https://<crate-address>/api/v1/products?limit=3", {
  headers: { Authorization: `Bearer ${process.env.CRATE_API_KEY}` },
});
if (!res.ok) throw new Error(`Crate API ${res.status}: ${await res.text()}`);
const { products } = await res.json();
console.log(products.map((p) => `${p.name} ${p.price} ${p.currency}`));
```
### Ruby
```ruby
require "net/http"
require "json"
uri = URI("https://<crate-address>/api/v1/products?limit=3")
req = Net::HTTP::Get.new(uri, "Authorization" => "Bearer #{ENV.fetch('CRATE_API_KEY')}")
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }
raise "Crate API #{res.code}: #{res.body}" unless res.is_a?(Net::HTTPSuccess)
JSON.parse(res.body)["products"].each { |p| puts "#{p['name']} #{p['price']} #{p['currency']}" }
```
The response is a JSON object with a `products` list. Each product has fields such as `id`, `name`, `slug`, `status`, `price`, `currency`, `sku`, `stock`, `collections` and `images`. `price` is a decimal string when a price is available in the store currency, such as USD. When that price is unavailable, `price` is JSON `null`; `currency` still identifies the expected currency of the store your API key belongs to. A price in another currency is not relabeled as store money.
To get the next page, follow the `Link` response header. [Pagination](/docs/developers/pagination) shows how.
## If something goes wrong
- **401 with "Missing bearer token"**: the `Authorization` header didn't arrive. Check that it reads `Bearer`, a space, then the key.
- **401 with "Invalid or expired access token"**: the key is wrong, expired or revoked. Create a new one.
- **403 with "Token is missing the 'read_products' scope"**: the key can't read products. Edit the key and tick **Read** for **Products**.
[Errors](/docs/developers/errors) lists every status code.
## What's next
Keep the key, or revoke it from its menu on the **API keys** page if you were only trying things out. For a real integration, create a key with only the permissions it needs.
Before you build anything that runs on its own, read [Errors](/docs/developers/errors) and [Rate limits](/docs/developers/rate-limits).
