Get position trades
curl --request GET \
--url https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions/{position_id}/tradesimport requests
url = "https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions/{position_id}/trades"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions/{position_id}/trades', 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}/trades",
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}/trades"
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}/trades")
.asString();require 'uri'
require 'net/http'
url = URI("https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions/{position_id}/trades")
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": [
{
"action": "open",
"eventIndex": 123,
"fees": "<string>",
"funding": "<string>",
"instructionType": "<string>",
"liquidity": "maker",
"price": "<string>",
"realizedPnl": "<string>",
"size": "<string>",
"sizeAfter": "<string>",
"slot": 123,
"slotIndex": 123,
"timestamp": "2023-11-07T05:31:56Z",
"tradeType": "limit",
"value": "<string>",
"tpsl": "takeProfit"
}
],
"hasMore": true,
"nextCursor": "<string>",
"prevCursor": "<string>"
}Trader
Get position trades
Handles GET /v1/users/{user_pubkey}/positions/{position_id}/trades via get.v1.users.by_user_pubkey.positions.by_position_id.trades.
GET
/
v1
/
users
/
{user_pubkey}
/
positions
/
{position_id}
/
trades
Get position trades
curl --request GET \
--url https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions/{position_id}/tradesimport requests
url = "https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions/{position_id}/trades"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions/{position_id}/trades', 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}/trades",
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}/trades"
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}/trades")
.asString();require 'uri'
require 'net/http'
url = URI("https://perp-api.phoenix.trade/v1/users/{user_pubkey}/positions/{position_id}/trades")
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": [
{
"action": "open",
"eventIndex": 123,
"fees": "<string>",
"funding": "<string>",
"instructionType": "<string>",
"liquidity": "maker",
"price": "<string>",
"realizedPnl": "<string>",
"size": "<string>",
"sizeAfter": "<string>",
"slot": 123,
"slotIndex": 123,
"timestamp": "2023-11-07T05:31:56Z",
"tradeType": "limit",
"value": "<string>",
"tpsl": "takeProfit"
}
],
"hasMore": true,
"nextCursor": "<string>",
"prevCursor": "<string>"
}Path Parameters
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.