Pagination
To make it possible to explore the millions of records for resources like transactions and operations, Horizon paginates the data it returns for collection-based endpoints.
Each individual transaction, operation, ledger, etc. is returned as a record, and a group of records is called a collection. Records are returned as an array under the _embedded attribute.
To move between pages of a collection of records, use the links in the next and prev attributes nested under the top-level _links attribute.
ATTRIBUTEDATA TYPE
DESCRIPTION
_linksarray
Provides links for navigating to other pages.
View _links attributes
_links.selfarray
An href key with a link to the response itself as the value.
_links.nextarray
An href key with a link to the next page for this endpoint as the value.
_links.prevarray
An href key with a link to the next page for this endpoint as the value.
_embeddedarray
An href key with a link to the next page for this endpoint as the value.
View _embedded attributes
_embedded.recordsarray
Returns an array of records.
Larger Queries
For fewer round trips, you can specify the limit parameter up to 200 to receive more items in each response. You can also lower it for calls with a smaller scope. Learn more in the call arguments.
Example Request
- JavaScript
var StellarSdk = require("stellar-sdk");
var server = new StellarSdk.Horizon.Server(
"https://horizon-testnet.stellar.org",
);
server
.transactions()
.call()
.then(function (resp) {
// page 1
console.log(resp);
return resp.next();
})
.then(function (resp) {
// page 2
console.log(resp);
})
.catch(function (err) {
console.error(err);
});
{
"_links": {
"self": {
"href": "https://horizon-testnet.stellar.org/transactions/2a09c3d79027721f2b8a78e2a936cbeda484bfe98a6e34856c1fee743b7e8906/operations?cursor=&limit=5&order=asc"
},
"next": {
"href": "https://horizon-testnet.stellar.org/transactions/2a09c3d79027721f2b8a78e2a936cbeda484bfe98a6e34856c1fee743b7e8906/operations?cursor=113928152169844741&limit=5&order=asc"
},
"prev": {
"href": "https://horizon-testnet.stellar.org/transactions/2a09c3d79027721f2b8a78e2a936cbeda484bfe98a6e34856c1fee743b7e8906/operations?cursor=113928152169844737&limit=5&order=desc"
}
},
"_embedded": {
"records": [
{
"_links": {
"self": {
"href": "https://horizon-testnet.stellar.org/operations/113928152169844737"
},
"transaction": {
"href": "https://horizon-testnet.stellar.org/transactions/2a09c3d79027721f2b8a78e2a936cbeda484bfe98a6e34856c1fee743b7e8906"
},
"effects": {
"href": "https://horizon-testnet.stellar.org/operations/113928152169844737/effects"
}
},
"id": "113928152169844737",
"paging_token": "113928152169844737",
"transaction_successful": true,
"source_account": "GDO2BIMNH7T6MOJVPKEJHWAGMYGOQU5QMK5BKT5XMVWPZKHAGA4JNAQZ",
"type": "manage_buy_offer",
"type_i": 12,
"created_at": "2019-10-28T19:44:09Z",
"transaction_hash": "2a09c3d79027721f2b8a78e2a936cbeda484bfe98a6e34856c1fee743b7e8906",
"amount": "0.0000000",
"price": "0.0001000",
"price_r": {
"n": 1,
"d": 10000
},
"buying_asset_type": "native",
"selling_asset_type": "credit_alphanum4",
"selling_asset_code": "SLT",
"selling_asset_issuer": "GCKA6K5PCQ6PNF5RQBF7PQDJWRHO6UOGFMRLK3DYHDOI244V47XKQ4GP",
"offer_id": 126229445
},
{
"_links": {
"self": {
"href": "https://horizon-testnet.stellar.org/operations/113928152169844738"
},
"transaction": {
"href": "https://horizon-testnet.stellar.org/transactions/2a09c3d79027721f2b8a78e2a936cbeda484bfe98a6e34856c1fee743b7e8906"
},
"effects": {
"href": "https://horizon-testnet.stellar.org/operations/113928152169844738/effects"
},
"succeeds": {
"href": "https://horizon-testnet.stellar.org/effects?order=desc\u0026cursor=113928152169844738"
},
"precedes": {
"href": "https://horizon-testnet.stellar.org/effects?order=asc\u0026cursor=113928152169844738"
}
},
"id": "113928152169844738",
"paging_token": "113928152169844738",
"transaction_successful": true,
"source_account": "GDO2BIMNH7T6MOJVPKEJHWAGMYGOQU5QMK5BKT5XMVWPZKHAGA4JNAQZ",
"type": "manage_buy_offer",
"type_i": 12,
"created_at": "2019-10-28T19:44:09Z",
"transaction_hash": "2a09c3d79027721f2b8a78e2a936cbeda484bfe98a6e34856c1fee743b7e8906",
"amount": "0.0000000",
"price": "0.0001000",
"price_r": {
"n": 1,
"d": 10000
},
"buying_asset_type": "native",
"selling_asset_type": "credit_alphanum4",
"selling_asset_code": "SLT",
"selling_asset_issuer": "GCKA6K5PCQ6PNF5RQBF7PQDJWRHO6UOGFMRLK3DYHDOI244V47XKQ4GP",
"offer_id": 126229446
},
{
"_links": {
"self": {
"href": "https://horizon-testnet.stellar.org/operations/113928152169844739"
},
"transaction": {
"href": "https://horizon-testnet.stellar.org/transactions/2a09c3d79027721f2b8a78e2a936cbeda484bfe98a6e34856c1fee743b7e8906"
},
"effects": {
"href": "https://horizon-testnet.stellar.org/operations/113928152169844739/effects"
},
"succeeds": {
"href": "https://horizon-testnet.stellar.org/effects?order=desc\u0026cursor=113928152169844739"
},
"precedes": {
"href": "https://horizon-testnet.stellar.org/effects?order=asc\u0026cursor=113928152169844739"
}
},
"id": "113928152169844739",
"paging_token": "113928152169844739",
"transaction_successful": true,
"source_account": "GDO2BIMNH7T6MOJVPKEJHWAGMYGOQU5QMK5BKT5XMVWPZKHAGA4JNAQZ",
"type": "manage_buy_offer",
"type_i": 12,
"created_at": "2019-10-28T19:44:09Z",
"transaction_hash": "2a09c3d79027721f2b8a78e2a936cbeda484bfe98a6e34856c1fee743b7e8906",
"amount": "0.0000000",
"price": "0.0001000",
"price_r": {
"n": 1,
"d": 10000
},
"buying_asset_type": "native",
"selling_asset_type": "credit_alphanum4",
"selling_asset_code": "SLT",
"selling_asset_issuer": "GCKA6K5PCQ6PNF5RQBF7PQDJWRHO6UOGFMRLK3DYHDOI244V47XKQ4GP",
"offer_id": 126229447
},
{
"_links": {
"self": {
"href": "https://horizon-testnet.stellar.org/operations/113928152169844740"
},
"transaction": {
"href": "https://horizon-testnet.stellar.org/transactions/2a09c3d79027721f2b8a78e2a936cbeda484bfe98a6e34856c1fee743b7e8906"
},
"effects": {
"href": "https://horizon-testnet.stellar.org/operations/113928152169844740/effects"
},
"succeeds": {
"href": "https://horizon-testnet.stellar.org/effects?order=desc\u0026cursor=113928152169844740"
},
"precedes": {
"href": "https://horizon-testnet.stellar.org/effects?order=asc\u0026cursor=113928152169844740"
}
},
"id": "113928152169844740",
"paging_token": "113928152169844740",
"transaction_successful": true,
"source_account": "GDO2BIMNH7T6MOJVPKEJHWAGMYGOQU5QMK5BKT5XMVWPZKHAGA4JNAQZ",
"type": "manage_buy_offer",
"type_i": 12,
"created_at": "2019-10-28T19:44:09Z",
"transaction_hash": "2a09c3d79027721f2b8a78e2a936cbeda484bfe98a6e34856c1fee743b7e8906",
"amount": "0.0000000",
"price": "0.0001000",
"price_r": {
"n": 1,
"d": 10000
},
"buying_asset_type": "native",
"selling_asset_type": "credit_alphanum4",
"selling_asset_code": "SLT",
"selling_asset_issuer": "GCKA6K5PCQ6PNF5RQBF7PQDJWRHO6UOGFMRLK3DYHDOI244V47XKQ4GP",
"offer_id": 126229448
},
{
"_links": {
"self": {
"href": "https://horizon-testnet.stellar.org/operations/113928152169844741"
},
"transaction": {
"href": "https://horizon-testnet.stellar.org/transactions/2a09c3d79027721f2b8a78e2a936cbeda484bfe98a6e34856c1fee743b7e8906"
},
"effects": {
"href": "https://horizon-testnet.stellar.org/operations/113928152169844741/effects"
},
"succeeds": {
"href": "https://horizon-testnet.stellar.org/effects?order=desc\u0026cursor=113928152169844741"
},
"precedes": {
"href": "https://horizon-testnet.stellar.org/effects?order=asc\u0026cursor=113928152169844741"
}
},
"id": "113928152169844741",
"paging_token": "113928152169844741",
"transaction_successful": true,
"source_account": "GDO2BIMNH7T6MOJVPKEJHWAGMYGOQU5QMK5BKT5XMVWPZKHAGA4JNAQZ",
"type": "manage_buy_offer",
"type_i": 12,
"created_at": "2019-10-28T19:44:09Z",
"transaction_hash": "2a09c3d79027721f2b8a78e2a936cbeda484bfe98a6e34856c1fee743b7e8906",
"amount": "0.0000000",
"price": "0.0001000",
"price_r": {
"n": 1,
"d": 10000
},
"buying_asset_type": "native",
"selling_asset_type": "credit_alphanum4",
"selling_asset_code": "SLT",
"selling_asset_issuer": "GCKA6K5PCQ6PNF5RQBF7PQDJWRHO6UOGFMRLK3DYHDOI244V47XKQ4GP",
"offer_id": 126229449
}
]
}
}