Activities & Events
Get Events
Poll for real-time account events
GET
/
accounts
/
{account_id}
/
events
Get Events
curl --request GET \
--url https://api.example.com/accounts/{account_id}/eventsimport requests
url = "https://api.example.com/accounts/{account_id}/events"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/accounts/{account_id}/events', 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://api.example.com/accounts/{account_id}/events",
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://api.example.com/accounts/{account_id}/events"
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://api.example.com/accounts/{account_id}/events")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/accounts/{account_id}/events")
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_bodyGet Events
Returns events for a sub-account. Supports long-polling for real-time updates — the request will hang until new events arrive or the timeout is reached.Request
GET /accounts/:account_id/events
GET /accounts/:account_id/events?since=1706900000&poll=true
Path parameters
| Parameter | Type | Description |
|---|---|---|
account_id | string | The sub-account ID |
Query parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
since | integer | none | Only return events after this cursor value |
poll | boolean | false | If true, long-poll until new events arrive (up to ~30s) |
Examples
# Get all events
curl https://prime-api.legend.xyz/accounts/acc_2o0yiljtp378/events \
-H "Authorization: Bearer $LEGEND_QUERY_KEY"
# Long-poll for new events after cursor 1706900000
curl "https://prime-api.legend.xyz/accounts/acc_2o0yiljtp378/events?since=1706900000&poll=true" \
-H "Authorization: Bearer $LEGEND_QUERY_KEY"
// Get all events
const { events, cursor } = await client.accounts.events("acc_2o0yiljtp378");
// Long-poll for new events
const result = await client.accounts.events("acc_2o0yiljtp378", {
since: cursor,
poll: true,
});
# Get all events
result = await client.accounts.events("acc_2o0yiljtp378")
cursor = result["cursor"]
# Long-poll for new events
result = await client.accounts.events(
"acc_2o0yiljtp378",
since=cursor,
poll=True,
)
let events = client.accounts.events("acc_2o0yiljtp378", Some(0), Some(true)).await?;
Response
{
"events": [
{
"event_type": "activity_updated",
"data": {
"activity_id": 1,
"activity_type": "quark_operation_executed",
"activity_status": "confirmed"
},
"timestamp": 1706900001
}
],
"cursor": 1706900001
}
Response fields
| Field | Type | Description |
|---|---|---|
events | array | List of event objects |
events[].event_type | string | Type of event |
events[].data | object | Event-specific data |
events[].timestamp | integer | Unix timestamp of the event |
cursor | integer | Cursor value — pass as since in the next request |
Long-polling pattern
For real-time monitoring, use a long-polling loop:let cursor = 0;
while (true) {
const { events, cursor: newCursor } = await client.accounts.events(
"acc_2o0yiljtp378",
{ since: cursor, poll: true }
);
for (const event of events) {
console.log(event.event_type, event.data);
}
cursor = newCursor;
}
cursor = 0
while True:
result = await client.accounts.events(
"acc_2o0yiljtp378",
since=cursor,
poll=True,
)
for event in result["events"]:
print(event["event_type"], event["data"])
cursor = result["cursor"]
let mut cursor = 0;
loop {
let result = client.accounts.events("acc_2o0yiljtp378", Some(cursor), Some(true)).await?;
for event in &result.events {
println!("{}: {:?}", event.event_type, event.data);
}
cursor = result.cursor;
}
Errors
| Status | Code | Description |
|---|---|---|
| 404 | account_not_found | Account doesn’t exist |
⌘I
Get Events
curl --request GET \
--url https://api.example.com/accounts/{account_id}/eventsimport requests
url = "https://api.example.com/accounts/{account_id}/events"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/accounts/{account_id}/events', 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://api.example.com/accounts/{account_id}/events",
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://api.example.com/accounts/{account_id}/events"
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://api.example.com/accounts/{account_id}/events")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/accounts/{account_id}/events")
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