Saltar al contenido principal

Paginación

Para hacer posible explorar los millones de registros de recursos como transacciones y operaciones, Horizon pagina los datos que devuelve para los puntos finales basados en colecciones.

Cada transacción, operación, ledger, etc. individual se devuelve como un registro, y un grupo de registros se llama una colección. Los registros se devuelven como un array bajo el atributo _embedded.

Para moverte entre páginas de una colección de registros, utiliza los enlaces en los atributos next y prev anidados bajo el atributo _links de nivel superior.

  • ATRIBUTOTIPO DE DATO

    DESCRIPCIÓN

  • _linksarray

    Proporciona enlaces para navegar a otras páginas.

    Mostrar atributos secundarios
  • _links.selfarray

    Una clave href con un enlace a la respuesta misma como valor.

  • _links.nextarray

    Una clave href con un enlace a la siguiente página para este punto final como valor.

  • _links.prevarray

    Una clave href con un enlace a la siguiente página para este punto final como valor.

  • _embeddedarray

    Una clave href con un enlace a la siguiente página para este punto final como valor.

    Mostrar atributos secundarios
  • _embedded.recordsarray

    Devuelve un array de registros.

    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);
    });
    Ejemplo de Respuesta Paginada
    {
    "_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
    }
    ]
    }
    }