# Cookbook & Starter Kits

This page provides ready-to-use tools and code examples to help you start using the Arkham API quickly. Whether you prefer a visual interface or copy-paste code snippets, we have options for different workflows.

**What's here:**

- **Postman Collection** — Import into Postman and start making requests immediately, no coding required
- **Code Snippets** — Minimal Python and curl examples you can copy directly into your projects

All tools come pre-configured with example addresses and sensible defaults so you can test the API right away.

## Postman Collection

[Postman](https://www.postman.com/) is a free API client that lets you explore and test APIs without writing code. It's the fastest way to start making requests — add your key in the **Variables** tab and click Send.

**What you get:** every endpoint in the public API, grouped by API resource, each pre-filled with a working example and a sample response

::: warning WebSocket Streaming
This collection covers the HTTP endpoints, including the stream-management calls (`POST /ws/v2/streams`, etc.). Postman does support WebSocket requests, but live transfer streaming needs a session created first — the [Python snippet](#websocket-v2-stream-real-time-transfers-recommended) below handles the full connect-and-stream flow.
:::

### Get the collection

**[Open the Arkham Intel API collection on Postman ↗](https://documenter.getpostman.com/view/56855106/2sBY4SLy6F)** — fork it into your own workspace to get an editable copy.

Prefer a file? [**Download Collection JSON ↓**](/cookbook/postman/Arkham-API-Complete.postman_collection.json) — it also imports into Insomnia, Bruno and other API clients, or drop it straight into CI.

### Setup Instructions

1\. Fork the collection above, or download the JSON

2\. If you downloaded, open Postman and click **Import**, then select the file — a fork is already in your workspace

3\. Select the collection in the sidebar and open its **Variables** tab

4\. In the `apiKey` row, paste your API key into the **Value** column

5\. Start exploring endpoints in the **Collections** sidebar

![Postman setup — the numbered markers match the steps above](/cookbook/postman-setup.png)

The collection defines `baseUrl` and `apiKey` on itself, so it sends requests without an environment file.

::: tip Keeping your copy up to date
The published collection tracks the API. Your own copy doesn't follow it automatically: in a fork, open the collection's **⋯** menu and choose **Pull changes** to bring it in line. A downloaded file is a point-in-time snapshot — download it again to refresh.
:::

## Quick Code Examples

### REST: Get Address Intelligence

**Python:**

```python
import requests

API_KEY = "your-api-key"
address = "0x28C6c06298d514Db089934071355E5743bf21d60"  # Binance

response = requests.get(
    f"https://api.arkm.com/intelligence/address/{address}",
    headers={"API-Key": API_KEY}
)
print(response.json())
```

**curl:**

```bash
curl -H "API-Key: YOUR_KEY" \
  "https://api.arkm.com/intelligence/address/0x28C6c06298d514Db089934071355E5743bf21d60"
```

### REST: Get Recent Transfers

**Python:**

```python
import requests

API_KEY = "your-api-key"

response = requests.get(
    "https://api.arkm.com/transfers",
    headers={"API-Key": API_KEY},
    params={
        "base": "0x28C6c06298d514Db089934071355E5743bf21d60",  # Binance
        "timeLast": "1h",
        "limit": 10
    }
)
print(response.json())
```

**curl:**

```bash
curl -H "API-Key: YOUR_KEY" \
  "https://api.arkm.com/transfers?base=0x28C6c06298d514Db089934071355E5743bf21d60&timeLast=1h&limit=10"
```

### REST: Follow a Transfer Across a Bridge

A transaction that paid into a bridge lists the bridge with the chain and address it paid out to. See [Tracking Funds Through Bridges](/concepts/bridges).

**Python:**

```python
import requests

API_KEY = "your-api-key"

response = requests.get(
    "https://api.arkm.com/tx/0xca6eb0b70f50f6626538ce425b2758bfb1fe78f74420b3612d2dfbce937bff71",
    headers={"API-Key": API_KEY},
)
for tx in response.json().values():
    for bridge in tx.get("bridges", []):
        dest = bridge.get("destination", {})
        print(bridge["protocolName"], bridge["status"], dest.get("chain"), dest.get("address"))
```

**curl:**

```bash
curl -H "API-Key: YOUR_KEY" \
  "https://api.arkm.com/tx/0xca6eb0b70f50f6626538ce425b2758bfb1fe78f74420b3612d2dfbce937bff71"
```

### WebSocket v2: Stream Real-Time Transfers

You create a stream with your filter via REST, then connect via WebSocket to receive matching transfers.

::: tip Stream Filters
WebSocket streams take the address, token and value filters of `GET /transfers` (`base`, `from`, `to`, `chains`, `tokens`, `usdGte`, `usdLte`, `valueGte`, `valueLte`). The difference is that `POST /ws/v2/streams` accepts them as a **JSON request body** with arrays, while `GET /transfers` uses query parameters.
:::

::: tip Filter Requirement
Streams require at least one of: `base`, `from`, `to`, `tokens`, or `usdGte >= 250,000`.
:::

**Step 1: Create a stream with your filter (JSON body)**

```python
import requests

API_KEY = "your-api-key"

# Create a stream that monitors CEX withdrawals >= $10k
response = requests.post(
    "https://api.arkm.com/ws/v2/streams",
    headers={"API-Key": API_KEY},
    json={"from": ["type:cex"], "usdGte": "10000"}
)
print(response.json())

# {"streamId": "e561dd5b-a24d-4669-bbba-9e5cf37d5125", "id": 1, "createdAt": "..."}
```

**Step 2: Connect and receive transfers**

```python
import asyncio
import json

import websockets  # requires websockets>=13; older versions use extra_headers

API_KEY = "your-api-key"
STREAM_ID = "e561dd5b-a24d-4669-bbba-9e5cf37d5125"  # the streamId returned by POST /ws/v2/streams in step 1

async def stream_transfers():
    url = f"wss://api.arkm.com/ws/v2/transfers?stream_id={STREAM_ID}"
    headers = {"API-Key": API_KEY}

    # Reconnecting reuses the same stream — you do not need to create a new one.
    while True:
        try:
            async with websockets.connect(url, additional_headers=headers) as ws:
                # Transfers are delivered automatically — no subscribe message needed.
                # Each message is an envelope: {"type": "transfer", "payload": {"transfer": {...}, "alertId": N}}
                async for message in ws:
                    data = json.loads(message)
                    if data.get("type") == "transfer":
                        transfer = data["payload"]["transfer"]
                        print(transfer)
        except (websockets.WebSocketException, OSError):
            print("connection lost, reconnecting...")
            await asyncio.sleep(1)

asyncio.run(stream_transfers())
```

**Managing streams:**

```python
import requests

API_KEY = "your-api-key"
STREAM_ID = "e561dd5b-a24d-4669-bbba-9e5cf37d5125"
headers = {"API-Key": API_KEY}

# List your streams
print(requests.get("https://api.arkm.com/ws/v2/streams", headers=headers).json())

# Delete a stream
print(requests.delete(f"https://api.arkm.com/ws/v2/streams/{STREAM_ID}", headers=headers).json())
```

::: info Reconnection
Streams stay active for 10 minutes after disconnection. Reconnecting within that window reactivates the stream and delivers any transfers that occurred while you were disconnected. After 10 minutes the stream is cleaned up and you need to create a new one.
:::

::: info Stream limit
By default, each user can have 10 active streams, shared across all their API keys. An organization’s limit applies separately to each member. Streams count while active within the last 10 minutes. Contact [api@arkm.com](mailto:api@arkm.com) for higher limits.
:::

## WebSocket Filter Reference

WebSocket stream filters are sent as a JSON request body on `POST /ws/v2/streams`.

- `base` (string[]) — Entity names or wallet addresses to monitor (sender or receiver)
- `from` (string[]) — Source addresses, entities, or special syntax (`type:cex`, `deposit:binance`)
- `to` (string[]) — Destination addresses, entities, or special syntax
- `tokens` (string[]) — Token IDs (e.g. `ethereum`, `usd-coin`) or contract addresses. Ticker symbols like `USDC` are not accepted
- `chains` (string[]) — Blockchains to filter by (e.g. `ethereum`, `solana`)
- `usdGte` / `usdLte` (number) — USD value range
- `valueGte` / `valueLte` (number) — Raw token amount range

**Filter Requirements:**
You must include at least one of:

- `base`, `from`, `to`, or `tokens` filter, **OR**
- `usdGte >= 250,000`

## Troubleshooting

### Common Errors

| Error                      | Solution                                                              |
| -------------------------- | --------------------------------------------------------------------- |
| Error validating API key   | Check your key is correct. Use `API-Key` header, not `Authorization`. |
| Filter requirement not met | WebSocket needs `base`, `from`, `to`, `tokens`, or `usdGte` ≥ 250K    |
| HTTP 401 Unauthorized      | Invalid or expired API key                                            |
| HTTP 429 Too Many Requests | Rate limited — back off and retry. See the [Rate Limits](/usage/rate-limits) guide for per-plan limits. |

## More Resources

- **API Reference:** [API Reference](#api-reference)
- **Request API Access:** [arkm.com/api](https://arkm.com/api)
- **Support:** [api@arkm.com](mailto:api@arkm.com)
