Find something... ⌘K

Command line and agents / Agents

Agent quick start

The calls an AI agent makes to buy BTC, in order, over plain HTTP or with the command line's --json. An order is typed data the agent's wallet signs, so no person needs to click anything, and the API key cannot move funds. Everything here runs in the sandbox, where nothing real moves.

#CallGives
1POST /sandbox/keysA test key, with no sign-up. Once: keep it
2GET /priceWhat an amount gets now. Nothing reserved
3GET /quoteThe order for this wallet and address, with steps. Valid for 60 seconds
4Sign each signature step, then POST /ordersThe orderId
5GET /status?orderId=…state, until it ends

Get a key once

One IP address can get five test keys an hour, so an agent should get one and reuse it, not get one per run.

curl Copy
export BASE=https://openapi.maxy.co/v1 export MAXY_API_KEY=$(curl -s -X POST "$BASE/sandbox/keys" | jq -r .secretKey)

Price, quote, sign, status

The agent pays with USDC on Base: it signs and sends no transaction. The wallet is a throwaway one here; live, it is the agent's own. The Bitcoin address is a public test address, for a test key only.

curlPython
Copy
H="x-maxy-key: $MAXY_API_KEY" TEST_WALLET_KEY=$(cast wallet new --json | jq -r '.[0].private_key') WALLET=$(cast wallet address --private-key "$TEST_WALLET_KEY") curl -sG -H "$H" "$BASE/price" --data-urlencode "from=USDC on base" -d to=BTC -d amount=20 | jq -c '{toAmount, liquidityAvailable}' curl -sG -H "$H" "$BASE/quote" --data-urlencode "from=USDC on base" -d to=BTC -d amount=20 \ -d fromAddress="$WALLET" -d toAddress=bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 > quote.json jq -e '.sandbox == true' quote.json > /dev/null || { echo 'This sample is for a test key (mxk_test_…).' >&2; exit 1; } jq -c '{quoteId, issues}' quote.json SIGS='{}' for ID in $(jq -r '.steps[]? | select(.kind == "signature") | .id' quote.json); do SIG=$(cast wallet sign --private-key "$TEST_WALLET_KEY" --data "$(jq -c --arg id "$ID" '.steps[] | select(.id == $id) | .typedData' quote.json)") SIGS=$(echo "$SIGS" | jq -c --arg id "$ID" --arg sig "$SIG" '. + {($id): $sig}') done ORDER_ID=$(curl -s -X POST "$BASE/orders" -H "$H" -H "content-type: application/json" \ -d "$(jq -c --argjson sigs "$SIGS" '{order: .order, signatures: $sigs}' quote.json)" | jq -r .orderId) until curl -s -H "$H" "$BASE/status?orderId=$ORDER_ID&chainId=8453" > status.json && jq -e '.isComplete or .state == "refundable" or .error' status.json > /dev/null; do sleep 2 done jq -c '{state, btcTxId, error}' status.json

In the sandbox the order reads pending, then in_progress, then completed, in about 20 seconds. Paying with ETH adds one escrow transaction and POST /orders/submit: Place the order.

With the command line

The same order with npx -p maxy-labs maxy, once the SDK is installed (Command line). MAXY_WALLET_KEY gives the command line a wallet without storing it: here a throwaway one; live, the agent's own. With --json every command prints one JSON object (order watch: one line per change): swap prints it once the order is placed, with orderId and next, the command that follows the order.

curl Copy
export MAXY_WALLET_KEY=$(cast wallet new --json | jq -r '.[0].private_key') npx -p maxy-labs maxy price 20 usdc base --json ORDER_ID=$(npx -p maxy-labs maxy swap 20 usdc base to btc --from MAXY_WALLET_KEY \ --to bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 --yes --json | jq -r .orderId) npx -p maxy-labs maxy order watch "$ORDER_ID" --json

What each answer means

The agent readsIt meansThe agent does
state: pending or in_progressA solver is committing or payingPoll again in 2 seconds
state: completedThe BTC is sent: btcTxIdRecord btcTxId, and stop
state: refundableNo solver filled in timeGET /orders/{id}/refund, and send its transaction from the wallet
state: cancelled, expired, refundedEnded, nothing paid outStop. Quote again if still wanted
state: failedSee rawStatusStop, and send Maxy the orderId and requestId
issues.orderCap, order_cap_exceededOver the key's capOrder less
liquidityAvailable: falseCannot fill this size nowA smaller amount, or later
quote_expiredOver 60 seconds since the quoteQuote again, sign again
429, rate_limitedOver the rate limitWait Retry-After seconds
retryable: trueThe same call may work laterRetry it as is: the same signed order returns the same orderId

Which key an agent gets, and what each can do: For AI agents.