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

# Ask Your Agent to Integrate

> Start a BULK integration in Codex or Claude Code with the official client and signing libraries.

Build with the official **bulk-client** and **bulk-keychain** libraries. Open a prepared instruction in your coding agent, select your project, review it, and send it. The agent should implement and test the integration—not just explain the API.

Open in Codex
Open in Claude Code

Requires the installed desktop app. Opens a draft; nothing is submitted automatically. Choose your project before sending. No app? Copy the prompt into your preferred coding agent.

## Use the official libraries

> [card] [bulk-client](https://github.com/Bulk-trade/bulk-client)
>
> Rust and Python HTTP/WebSocket clients, plus the Bulk CLI. Prefer supported client methods over rebuilding the transport.

> [card] [bulk-keychain](https://github.com/Bulk-trade/bulk-keychain)
>
> Canonical transaction signing for Rust, Python, Node.js and browsers. Do not hand-roll signing bytes or signature envelopes.

The agent should inspect the current package documentation and your project's dependencies before installing anything. Use `bulk-client` where it supports the required language and endpoint. Use `bulk-keychain` when signing support is needed; do not sign twice if the chosen client already handles it. For an endpoint not covered by the client, add a small transport adapter based on its published API contract.

For TypeScript/JavaScript, `bulk-keychain` provides Node.js signing and `bulk-keychain-wasm` provides browser signing. Reuse your project's HTTP/WebSocket transport unless the current official client documentation provides a supported binding. Read-only integrations do not need a private key or signing dependency.

## Start from a terminal

If Claude Code is installed, run this from your project directory. It opens an interactive session with the integration task; normal permission prompts remain enabled.

```bash Claude Code theme={null}
claude 'Integrate BULK into this project. Read https://docs.bulk.trade/api-reference/agent-integration.md first. Prefer the official bulk-client for supported HTTP/WebSocket operations and bulk-keychain for signing. Verify current package APIs and compatibility. Build and test read-only functionality first. Do not request keys in chat, submit transactions, deploy, commit, or push without my explicit approval.'
```

## Copy and paste into your agent

```text Integration instruction theme={null}
Integrate BULK into this repository using its existing language and conventions.

Start at https://docs.bulk.trade/llms.txt. Read the relevant current API pages
and linked OpenAPI/AsyncAPI specifications before implementing requests.
Do not guess routes, fields, signature formats, response shapes, or units.

Inspect this project first. Preserve unrelated work and reuse its HTTP,
WebSocket, configuration, and testing libraries. Ask me only for choices
that cannot be inferred from the repository, such as the target network.

Prefer these official libraries; inspect their current documentation and
the versions already installed in this repository:
- https://github.com/Bulk-trade/bulk-client: Rust/Python HTTP and WebSocket
  clients and the Bulk CLI. Use supported client methods first.
- https://github.com/Bulk-trade/bulk-keychain: canonical signing, with Rust,
  Python, Node.js (bulk-keychain) and browser (bulk-keychain-wasm) bindings.
Do not hand-roll signing or sign twice when a client already handles it.
Do not invent an unsupported language binding or client method. Use a small
documented transport adapter only for endpoints the client does not cover.
Verify package/network compatibility before changing dependency versions.

Implement a small client with:
1. A public market-data read and an explicit mainnet/testnet configuration.
2. A read-only WebSocket subscription with subscribe acknowledgement,
   snapshot readiness, unsubscribe, reconnect backoff, and resubscription.
3. Optional account queries using a public key supplied through configuration.
   Keep current state, paginated history, and live account events distinct.
4. Historical market funding rates using the Portfolio API, not the trading
   API. Preserve RFC 3339 cursor precision and follow nextAfter until null.
5. Bounded timeouts, rate-limit backoff, and structured error handling.
   Preserve precision for nonces, timestamps, slot numbers and asset values.

Use the documented endpoints:
- Mainnet HTTP: https://mainnet-api1.bulk.trade/api/v1
- Mainnet WS: wss://mainnet-ws1.bulk.trade
- Testnet HTTP: https://exchange-api.bulk.trade/api/v1
- Testnet WS: wss://exchange-ws1.bulk.trade
- Historical market funding: https://portfolio-api.bulk.trade/v1
  GET /markets/{symbol}/funding-rates

Only implement signed trading if I request it. Use the official client's
supported signer or bulk-keychain. Never request a private key in chat, log secrets,
or commit credentials. Do not place/cancel orders, transfer funds, register
agents, or change account settings without my explicit approval.

Add focused tests for parsing, pagination and reconnect/error handling.
Run a bounded read-only smoke test: one market request, a short subscription
that is explicitly closed, and two funding-rate pages with a small limit.
Do not treat a subscription acknowledgement as a data snapshot or HTTP 200
as proof of a successful signed action. Do not invent replay cursors.

Finish with the changed files, commands to run the client/tests, checks that
actually passed, the source pages used, and any remaining blockers. Do not
commit, push, deploy, or leave background connections running.
```

If you are reviewing a documentation preview, replace `https://docs.bulk.trade` in the instruction with that preview's base URL so the agent reads the same version you are reviewing. API hosts remain unchanged.

## Terminal check

This copy-paste command fetches the official documentation index and a small public market response. It does not install software, write credentials, or submit a transaction.

```bash Read-only connectivity check theme={null}
curl --fail --silent --show-error --max-time 15 'https://docs.bulk.trade/llms.txt'
curl --fail --silent --show-error --max-time 15 'https://mainnet-api1.bulk.trade/api/v1/ticker/BTC-USD'
```

## References your agent will need

> [card] [HTTP Account Queries](https://docs.bulk.trade/api-reference/getAccount.md)
>
> Current state, history, pagination and coverage.

> [card] [WebSocket Connection](https://docs.bulk.trade/api-reference/ws-connection.md)
>
> Connection lifecycle, subscriptions and reconnect handling.

> [card] [Historical Funding Rates](https://docs.bulk.trade/api-reference/getHistoricalFundingRates.md)
>
> Portfolio API host, time bounds and cursor pagination.

> [card] [Transaction Signing](https://docs.bulk.trade/api-reference/signing.md)
>
> Official signing libraries and signed-request requirements.

> [card] [Rate Limits](https://docs.bulk.trade/api-reference/rate-limits.md)
>
> Request, action, burst and connection budgets.

> [card] [L2 Order Book Deltas](https://docs.bulk.trade/api-reference/ws-market-data/l2-deltas.md)
>
> Snapshot initialization and atomic delta application.

## What a finished integration should show

* The client runs inside your project, with documented configuration and commands.
* Read-only requests return parsed responses; errors are not silently converted into empty data.
* A WebSocket can subscribe, receive the relevant data, unsubscribe and close cleanly.
* Pagination preserves the API's cursor and termination rules.
* Tests identify what was verified locally versus against a live endpoint.
* Signing and trading remain disabled unless you explicitly requested and approved them.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.