Swap History
GET /swaps | Auth: Required
Retrieve a paginated list of your past swaps. Optionally filter by status.
Request
Query Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
status | string | No | -- | Filter by swap status: "submitted", "pending", "completed", or "failed" |
limit | integer | No | 20 | Number of results per page (max 100) |
offset | integer | No | 0 | Number of results to skip for pagination |
Example Request
GET /swaps?status=completed&limit=10&offset=0
Response
| Field | Type | Description |
|---|---|---|
success | boolean | Whether the request succeeded |
swaps | array | List of swap objects |
pagination | object | Pagination metadata |
Swap Object
| Field | Type | Description | |
|---|---|---|---|
swap_id | integer | Unique swap identifier | |
status | string | "submitted", "pending", "completed", or "failed" | |
tx_hash | string \ | null | Transaction hash |
from_token | string | Source token symbol | |
to_token | string | Destination token symbol |
Pagination Object
| Field | Type | Description |
|---|---|---|
total | integer | Total number of matching swaps |
limit | integer | Current page size |
offset | integer | Current offset |
has_more | boolean | Whether more results exist beyond this page |
Example Response
{
"hl-key">"success": true,
"hl-key">"swaps": [
{
"hl-key">"swap_id": 4821,
"hl-key">"status": "completed",
"hl-key">"tx_hash": "0x8a3c...f29e",
"hl-key">"from_token": "ETH",
"hl-key">"to_token": "USDC"
},
{
"hl-key">"swap_id": 4755,
"hl-key">"status": "failed",
"hl-key">"tx_hash": "0x91b7...a3c2",
"hl-key">"from_token": "USDC",
"hl-key">"to_token": "DAI"
}
],
"hl-key">"pagination": {
"hl-key">"total": 42,
"hl-key">"limit": 10,
"hl-key">"offset": 0,
"hl-key">"has_more": true
}
}
Errors
| Status | Error | Cause |
|---|---|---|
| 400 | "Invalid status filter" | The status value is not one of the accepted statuses |
| 400 | "limit must be between 1 and 100" | The limit parameter is out of range |
| 401 | "Unauthorized" | Missing or invalid API key |
Code Examples
curl
-kw">curl -str">"https://api.suwappu.bot/v1/agent/swaps?status=completed&limit=10&offset=0" \
-H -str">"Authorization: Bearer suwappu_sk_your_api_key"
Python
import requests
response = requests.get(
class="hl-str">"https:class="hl-commentclass="hl-str">">//api.suwappu.bot/v1/agent/swaps",
headers={class="hl-str">"Authorization": class="hl-str">"Bearer suwappu_sk_your_api_key"},
params={class="hl-str">"status": class="hl-str">"completed", class="hl-str">"limit": 10, class="hl-str">"offset": 0},
)
data = response.json()
if data[class="hl-str">"success"]:
for swap in data[class="hl-str">"swaps"]:
print(fclass="hl-str">"Swap {swap[class="hl-str">'swap_id']}: {swap[class="hl-str">'from_token']} → {swap[class="hl-str">'to_token']} ({swap[class="hl-str">'status']})")
if data[class="hl-str">"pagination"][class="hl-str">"has_more"]:
print(fclass="hl-str">"More results available (total: {data[class="hl-str">'pagination'][class="hl-str">'total']})")
TypeScript
const params = new URLSearchParams({
status: class="hl-str">"completed",
limit: class="hl-str">"10",
offset: class="hl-str">"0",
});
const response = await fetch(
https:class=class="hl-str">"hl-comment">//api.suwappu.bot/v1/agent/swaps?${params},
{
headers: {
Authorization: class="hl-str">"Bearer suwappu_sk_your_api_key",
},
}
);
const data = await response.json();
if (data.success) {
for (const swap of data.swaps) {
console.log(
Swap ${swap.swap_id}: ${swap.from_token} → ${swap.to_token} (${swap.status})
);
}
if (data.pagination.has_more) {
console.log(More results available (total: ${data.pagination.total}));
}
}