# Use the API

Create an API key in Workspace settings, Keys, and read your accounts, contracts, orders, listings, purchases and sales from https://api.goldmine.to/v1.

The API lets your own tools read your workspace: a spreadsheet of profit, a dashboard, an alert when something sells. Every endpoint is described in one OpenAPI document, so you can load it into Postman, generate a client, or hand it to an AI assistant.

## 1. Create a key

Open **Workspace settings**, **Keys** and choose **Create key**. Give the key a name that says what uses it, such as "Profit sheet", and choose its **Policies**: what the key may read. You confirm with your second sign-in step, and the key appears in the list ready to copy. Copy it then and keep it somewhere safe.

A key belongs to its workspace and can read only that workspace. If your role does not include API keys, the page says so, and the workspace owner can give you access.

## 2. Send it with each request

Send the key in the `Authorization` header of every request:

```shell title="List your contracts"
curl https://api.goldmine.to/v1/contracts \
  -H "Authorization: Bearer <your key>"
```

## 3. Read the OpenAPI document

The whole API is described at [https://api.goldmine.to/v1/openapi.json](https://api.goldmine.to/v1/openapi.json), with every endpoint, parameter and field. It needs no key.

## What you can read

* `GET /v1/steam-accounts`: your Steam accounts
* `GET /v1/contracts` and `GET /v1/contracts/{id}`: your contracts
* `GET /v1/contracts/{id}/targets`: the items and max prices a contract is buying
* `GET /v1/orders`: your buy orders on the markets
* `GET /v1/listings`: what you have listed for sale
* `GET /v1/purchases`: what you have bought
* `GET /v1/sales`: what you have sold

## How answers look

* **Money** is an exact decimal string with its currency: `{"amount": "12.34", "currency": "USD"}`.
* **Ids** start with what they are, such as `ctr_` for a contract or `pur_` for a purchase.
* **Lists** return `data`, `has_more` and `next_cursor`. Ask for up to 100 at a time with `limit` (25 when you leave it out), and pass `next_cursor` back as `cursor` for the next page.
* **Times** are RFC 3339 in UTC.
* **Errors** return an `error` object with a `type`, a `code` that never changes meaning, a plain `message` and the `request_id`. Every answer also carries an `X-Request-Id` header. Quote it if you ask us about a request.

## Limits

Each key can make 100 calls a minute. Over that, the API answers `429` with a `Retry-After` header saying how many seconds to wait.

## Look after your keys

* **Rotate** gives a key a new value. Choose whether the old value stops now, in 1 hour or in 24 hours, so you have time to update what uses it.
* **Revoke** stops a key for good.
* Changes to a key's policies apply from its next request.

## Common questions

### Will my code break when the API changes?

No. `/v1` only grows: new fields, parameters and endpoints are added, and nothing is renamed or removed.

### Can I use one key for two workspaces?

No. Each key reads only the workspace it was created in. Create a key in each workspace you want to read.

### Can the API buy or sell for me?

No. The API only reads. Buying and selling are set up with [contracts](https://goldmine.to/guides/buying-contract) in the app, and the API shows what they do.
