PhoenixPerpetualsDocs API v1
Get an API key

Cookbook

Cookbook⁠.

Twelve complete programs in all seven languages, from listing your accounts to a webhook receiver: copy one and run it.

View as Markdown

Twelve complete programs, each in all seven languages, every one compiled against its SDK before a release. Each runs as it is against the sandbox.

RecipeWhat it does
Your key and accountsWho you are (the key, its access and limits) and your accounts.
Markets and a quoteThe markets and their rules, then a quote (bid, ask, last) from the market stream.
Live market dataLive market data: prices for two markets and the trades of one, until 20 frames came.
Place and cancel a limit orderA limit order far from the market, found again by your own id, then canceled.
A market order with exitsA market order with its exits: a take profit 1% away and a stop loss 0.5% away, placed by the API the moment it fills and kept on its servers.
Trailing stop and break-evenA position whose stop loss trails the price by 0.5% and moves to break-even once the price has gone 0.5% your way, all on the API's servers.
What an order would doWhat an order would do now, without placing it: fill or rest, the price, the fee, the margin, the position after.
A live copy of your accountsA live copy of your accounts' positions and working orders: the snapshot first, then every event applied once.
Account historyAn account's history: the equity curve by day, the result of each trading day, closed positions and fills.
Candles to a CSV fileThe last 100 closed one-minute candles of a market and the one forming (final false), written to candles.csv.
A webhook receiverReceive webhooks: every delivery is checked (its signature and its time) before it is trusted.
Handling errorsWhat failures look like: each has a class by family, the API's code, the request id to quote to support, and details.

Running one#

LanguageWhat it needs
TypeScriptNode 22 or later: npm install https://github.com/phoenixperps/sdk/releases/download/v1.0.0/phoenixperps-sdk-1.0.0.tgz, then node accounts.mts
PythonPython 3.10 or later: pip install https://github.com/phoenixperps/sdk/releases/download/v1.0.0/phoenixperps-1.0.0-py3-none-any.whl, then python accounts.py
GoGo 1.23 or later: go mod init bot && go get github.com/phoenixperps/sdk/go, the program as main.go, then go run .
C#.NET 10: once, dotnet nuget add source https://phoenixperps.github.io/sdk/nuget/index.json --name phoenixperps; each program is a file-based app whose #:package line brings the SDK: dotnet run accounts.cs
JavaJava 17 or later, with maven("https://phoenixperps.github.io/sdk/maven") in your repositories and com.phoenixperpsfunding:phoenixperps-sdk:1.0.0 in your dependencies
RustRust 1.85 or later: cargo add phoenixperps --git https://github.com/phoenixperps/sdk --tag v1.0.0, cargo add futures-util serde_json, cargo add uuid --features v4, cargo add tokio --features macros,rt-multi-thread,time, the program as src/main.rs, then cargo run
PHPPHP 8.2 or later: composer config repositories.phoenixperps composer https://phoenixperps.github.io/sdk/composer, composer require phoenixperps/sdk, then php accounts.php

Guides, endpoints, fields and error codes.