Get user position
curl --request GET \
--url https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions/{position_id}import requests
url = "https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions/{position_id}"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions/{position_id}', 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/{position_id}",
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/{position_id}"
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/{position_id}")
.asString();require 'uri'
require 'net/http'
url = URI("https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions/{position_id}")
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{
"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>"
}Trader
Get user position
Handles GET /v1/users/{user_pubkey}/positions/{position_id} via get.v1.users.by_user_pubkey.positions.by_position_id.
GET
/
v1
/
users
/
{user_pubkey}
/
positions
/
{position_id}
Get user position
curl --request GET \
--url https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions/{position_id}import requests
url = "https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions/{position_id}"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions/{position_id}', 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/{position_id}",
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/{position_id}"
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/{position_id}")
.asString();require 'uri'
require 'net/http'
url = URI("https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions/{position_id}")
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{
"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>"
}Path Parameters
Query Parameters
Response
200 - application/json
Successful response
One position of one subaccount: from the trade that left the market flat (or reversed the previous position) to the trade that next made it flat or reversed it.
Size amounts are in base units and money amounts in USD, as decimal
strings. PnL terms are signed; fees is what the trader paid, negative
for net rebates; netPnl = realizedPnl + fundingPayment - fees. For an
open position every amount covers the trades so far and excludes
unrealized PnL.