List user positions
curl --request GET \
--url https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positionsimport requests
url = "https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions")
.asString();require 'uri'
require 'net/http'
url = URI("https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"data": [
{
"avgEntryPrice": "<string>",
"complete": true,
"entrySize": "<string>",
"exitSize": "<string>",
"fees": "<string>",
"fundingPayment": "<string>",
"marketSymbol": "<string>",
"netPnl": "<string>",
"openKey": {
"eventIndex": 123,
"slot": 123,
"slotIndex": 123
},
"openedAt": "2023-11-07T05:31:56Z",
"peakSize": "<string>",
"positionId": "<string>",
"realizedPnl": "<string>",
"side": "long",
"status": "open",
"subaccountIndex": 123,
"traderPdaIndex": 123,
"userPubkey": "<string>",
"avgExitPrice": "<string>",
"closeKey": {
"eventIndex": 123,
"slot": 123,
"slotIndex": 123
},
"closeReason": "closed",
"closedAt": "2023-11-07T05:31:56Z",
"reversedFrom": "<string>",
"reversedInto": "<string>",
"tradesCursor": "<string>"
}
],
"hasMore": true,
"nextCursor": "<string>",
"prevCursor": "<string>"
}Trader
List user positions
Handles GET /v1/users/{user_pubkey}/positions via get.v1.users.by_user_pubkey.positions.
GET
/
v1
/
users
/
{user_pubkey}
/
positions
List user positions
curl --request GET \
--url https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positionsimport requests
url = "https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions")
.asString();require 'uri'
require 'net/http'
url = URI("https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"data": [
{
"avgEntryPrice": "<string>",
"complete": true,
"entrySize": "<string>",
"exitSize": "<string>",
"fees": "<string>",
"fundingPayment": "<string>",
"marketSymbol": "<string>",
"netPnl": "<string>",
"openKey": {
"eventIndex": 123,
"slot": 123,
"slotIndex": 123
},
"openedAt": "2023-11-07T05:31:56Z",
"peakSize": "<string>",
"positionId": "<string>",
"realizedPnl": "<string>",
"side": "long",
"status": "open",
"subaccountIndex": 123,
"traderPdaIndex": 123,
"userPubkey": "<string>",
"avgExitPrice": "<string>",
"closeKey": {
"eventIndex": 123,
"slot": 123,
"slotIndex": 123
},
"closeReason": "closed",
"closedAt": "2023-11-07T05:31:56Z",
"reversedFrom": "<string>",
"reversedInto": "<string>",
"tradesCursor": "<string>"
}
],
"hasMore": true,
"nextCursor": "<string>",
"prevCursor": "<string>"
}Query Parameters
Response
200 - application/json
Successful response
Generic paginated response wrapper with bidirectional cursor support.
The cursor system supports both forward (newer) and backward (older) pagination:
prev_cursor: Use this cursor to poll for new items (items newer than the current result set)next_cursor: Use this cursor to load more items (items older than the current result set)
The direction is embedded in the cursor itself, so clients just need to pass
the appropriate cursor to the cursor parameter.