_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.
Example Request
var StellarSdk = require("@stellar/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);
});
from stellar_sdk import Server
server = Server("https://horizon-testnet.stellar.org")
transactions = server.transactions()
# page 1
print(transactions.call())
# page 2: `next()` follows the `next` link of the page fetched last
print(transactions.next())
package main
import (
"fmt"
"log"
"github.com/stellar/go-stellar-sdk/clients/horizonclient"
)
func main() {
server := horizonclient.DefaultTestNetClient
// page 1
page, err := server.Transactions(horizonclient.TransactionRequest{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)
// page 2: `NextTransactionsPage` follows the `next` link of page 1
page, err = server.NextTransactionsPage(page)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)
}
import org.stellar.sdk.Server;
import org.stellar.sdk.responses.Page;
import org.stellar.sdk.responses.TransactionResponse;
public final class Pagination {
public static void main(String[] args) {
Server server = new Server("https://horizon-testnet.stellar.org");
// page 1
Page<TransactionResponse> page = server.transactions().execute();
System.out.println(page.getRecords());
// page 2: `getNextPage` follows the `next` link of page 1
page = page.getNextPage(server.getHttpClient());
System.out.println(page.getRecords());
}
}
Example Response
Example Paginated Response
{
"_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
}
]
}
}