For AI agents: an LLM-friendly Markdown version of every page is available by appending .md to its URL or by sending an Accept: text/markdown request header. The full documentation index is at https://www.ankr.com/docs/llms.txt
Skip to main content

Stellar — Ledgers, Liquidity pools (2/2)

API reference for Stellar. All methods ->

Part 2 of 2: 1 · 2

Liquidity pools

Liquidity pools provide a simple, non-interactive way to trade large amounts of capital and enable high volumes of trading.

GET /liquidity_pools

Lists all liquidity pools.

This endpoint lists all available liquidity pools.

Parameters

  • reserves (any; query): a comma-separated list of assets in canonical form (Code:IssuerAccountID), to only include liquidity pools which have reserves matching all listed assets.
  • account (any; query): a Stellar account ID, to only include liquidity pools in which this account is participating in (i.e. holds pool shares to).
  • cursor (integer; query): a number that points to a specific location in a collection of responses and is pulled from the paging_token value of a record.
  • order (string; query): a designation of the order in which records should appear. Options include asc (ascending) or desc (descending). If this argument isn’t set, it defaults to asc.
  • limit (integer; query): the maximum number of records returned. The limit can range from 1 to 200 - an upper limit that is hardcoded in Horizon for performance reasons. If this argument isn’t designated, it defaults to 10.

Returns

{
"_links": {
"self": {
"href": "string",
"templated": true
},
"next": {
"href": "string",
"templated": true
},
"prev": {
"href": "string",
"templated": true
}
},
"_embedded": {
"records": [
{
"id": "string",
"paging_token": "string",
"fee_bp": 0,
"type": "string",
"total_trustlines": "string",
"total_shares": "string",
"reserves": {
"asset": "string",
"amount": "string"
},
"last_modified_ledger": "string",
"last_modified_time": "string"
}
]
}
}

Request example

curl https://rpc.ankr.com/http/stellar_horizon/liquidity_pools{?reserves,account,curson,order,limit}

Response example

{
"_links": {
"self": {
"href": "https://rpc.ankr.com/liquidity_pools?cursor=\u0026limit=1\u0026order=asc"
},
"next": {
"href": "https://rpc.ankr.com/liquidity_pools?cursor=0000a8198b5e25994c1ca5b0556faeb27325ac746296944144e0a7406d501e8a\u0026limit=1\u0026order=asc"
},
"prev": {
"href": "https://rpc.ankr.com/liquidity_pools?cursor=0000a8198b5e25994c1ca5b0556faeb27325ac746296944144e0a7406d501e8a\u0026limit=1\u0026order=desc"
}
},
"_embedded": {
"records": [
{
"_links": {
"self": {
"href": "https://rpc.ankr.com/liquidity_pools/0000a8198b5e25994c1ca5b0556faeb27325ac746296944144e0a7406d501e8a"
},
"transactions": {
"href": "https://rpc.ankr.com/liquidity_pools/0000a8198b5e25994c1ca5b0556faeb27325ac746296944144e0a7406d501e8a/transactions{?cursor,limit,order}",
"templated": true
},
"operations": {
"href": "https://rpc.ankr.com/liquidity_pools/0000a8198b5e25994c1ca5b0556faeb27325ac746296944144e0a7406d501e8a/operations{?cursor,limit,order}",
"templated": true
}
},
"id": "0000a8198b5e25994c1ca5b0556faeb27325ac746296944144e0a7406d501e8a",
"paging_token": "0000a8198b5e25994c1ca5b0556faeb27325ac746296944144e0a7406d501e8a",
"fee_bp": 30,
"type": "constant_product",
"total_trustlines": "1",
"total_shares": "5494.2144063",
"reserves": [
{
"asset": "native",
"amount": "6.3915888"
},
{
"asset": "GOLDBANK001:GDEUQ2MX3YXMITFOTC3CO3GW5V3XE3IVG7JKLZZAOZ7WFYIN256INDUS",
"amount": "6259562.9445306"
}
],
"last_modified_ledger": 49899809,
"last_modified_time": "2024-01-13T13:23:26Z"
}
]
}
}

GET /liquidity_pools/{liquidity_pool_id}

Retrieves a particular liquidity pool.

The single liquidity pool endpoint provides information on a liquidity pool.

Parameters

  • liquidity_pool_id (any; path; required): a unique identifier for this liquidity pool.

Returns

{
"_links": {
"self": {
"href": "string",
"templated": true
},
"transactions": {
"href": "string",
"templated": true
},
"operations": {
"href": "string",
"templated": true
}
},
"id": "string",
"paging_token": "string",
"fee_bp": 0,
"type": "string",
"total_trustlines": "string",
"total_shares": "string",
"reserves": {
"asset": "string",
"amount": "string"
},
"last_modified_ledger": "string",
"last_modified_time": "string"
}

Request example

curl https://rpc.ankr.com/http/stellar_horizon/liquidity_pools/{liquidity_pool_id}

Response example

{
"_links": {
"self": {
"href": "https://rpc.ankr.com/liquidity_pools/67260c4c1807b262ff851b0a3fe141194936bb0215b2f77447f1df11998eabb9"
},
"effects": {
"href": "https://rpc.ankr.com/liquidity_pools/67260c4c1807b262ff851b0a3fe141194936bb0215b2f77447f1df11998eabb9/effects{?cursor,limit,order}",
"templated": true
},
"operations": {
"href": "https://rpc.ankr.com/liquidity_pools/67260c4c1807b262ff851b0a3fe141194936bb0215b2f77447f1df11998eabb9/operations{?cursor,limit,order}",
"templated": true
},
"transactions": {
"href": "https://rpc.ankr.com/liquidity_pools/67260c4c1807b262ff851b0a3fe141194936bb0215b2f77447f1df11998eabb9/transactions{?cursor,limit,order}",
"templated": true
}
},
"id": "67260c4c1807b262ff851b0a3fe141194936bb0215b2f77447f1df11998eabb9",
"paging_token": "113725249324879873",
"fee_bp": 30,
"type": "constant_product",
"total_trustlines": "300",
"total_shares": "5000",
"reserves": [
{
"amount": "1000.0000005",
"asset": "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S"
},
{
"amount": "2000.0000000",
"asset": "PHP:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S"
}
]
}

GET /liquidity_pools/{liquidity_pool_id}/effects

Retrieves effects of a particular liquidity pool.

This endpoint represents effects referencing a given liquidity pool and can be used in streaming mode. Streaming mode allows you to listen for new effects referencing this liquidity pool as they are added to the Stellar ledger. If called in streaming mode, Horizon will start at the earliest known effect unless a cursor is set, in which case it will start from that cursor. By setting the cursor value to now, you can stream effects created since your request time.

Parameters

  • liquidity_pool_id (any; path; required): a unique identifier for this liquidity pool.
  • cursor (integer; query): a number that points to a specific location in a collection of responses and is pulled from the paging_token value of a record.
  • order (string; query): a designation of the order in which records should appear. Options include asc (ascending) or desc (descending). If this argument isn’t set, it defaults to asc.
  • limit (integer; query): the maximum number of records returned. The limit can range from 1 to 200 - an upper limit that is hardcoded in Horizon for performance reasons. If this argument isn’t designated, it defaults to 10.

Returns

{
"_links": {
"self": {
"href": "string",
"templated": true
},
"next": {
"href": "string",
"templated": true
},
"prev": {
"href": "string",
"templated": true
}
},
"_embedded": {
"records": [
{
"_links": {
"operation": {
"href": "string",
"templated": true
},
"succeeds": {
"href": "string",
"templated": true
},
"precedes": {
"href": "string",
"templated": true
}
},
"id": "string",
"paging_token": "string",
"account": "string",
"type": "Account Created",
"type_i": 1,
"created_at": "string"
}
]
}
}

Request example

curl https://rpc.ankr.com/http/stellar_horizon/liquidity_pools/{liquidity_pool_id}/effects{?cursor,order,limit}

Response example

{
"_links": {
"self": {
"href": "https://rpc.ankr.com/liquidity_pools/67260c4c1807b262ff851b0a3fe141194936bb0215b2f77447f1df11998eabb9/effects?cursor=&order=asc"
},
"next": {
"href": "https://rpc.ankr.com/liquidity_pools/67260c4c1807b262ff851b0a3fe141194936bb0215b2f77447f1df11998eabb9/effects?cursor=120192370561220608&order=asc"
},
"prev": {
"href": "https://rpc.ankr.com/liquidity_pools/67260c4c1807b262ff851b0a3fe141194936bb0215b2f77447f1df11998eabb9/effects?cursor=120192344791343104&order=desc"
}
},
"_embedded": {
"records": [
{
"_links": {
"operation": {
"href": "https://rpc.ankr.com/operations/3849085266190337"
},
"succeeds": {
"href": "https://rpc.ankr.com/effects?order=desc&cursor=3849085266190337-1"
},
"precedes": {
"href": "https://rpc.ankr.com/effects?order=asc&cursor=3849085266190337-1"
}
},
"id": "0000000012884905986-0000000001",
"paging_token": "12884905986-2",
"account": "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7",
"type": "liquidity_pool_deposited",
"type_i": 81,
"created_at": "2021-11-18T03:15:54Z",
"liquidity_pool": {
"id": "67260c4c1807b262ff851b0a3fe141194936bb0215b2f77447f1df11998eabb9",
"fee_bp": 30,
"type": "constant_product",
"total_trustlines": "300",
"total_shares": "5000",
"reserves": [
{
"amount": "1000.0000005",
"asset": "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S"
},
{
"amount": "2000.0000000",
"asset": "PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP"
}
]
},
"reserves_deposited": [
{
"asset": "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S",
"amount": "2378.0000005"
},
{
"asset": "PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP",
"amount": "983.0000005"
}
],
"shares_received": "1000"
}
]
}
}

GET /liquidity_pools/{liquidity_pool_id}/trades

Retrieves trades of a particular liquidity pool.

This endpoint represents successful trades fulfilled by the given liquidity pool and can be used in streaming mode. Streaming mode allows you to listen for new trades referencing this liquidity pool as they are added to the Stellar ledger. If called in streaming mode, Horizon will start at the earliest known trade unless a cursor is set, in which case it will start from that cursor. By setting the cursor value to now, you can stream trade created since your request time.

Parameters

  • liquidity_pool_id (any; path; required): a unique identifier for this liquidity pool.
  • cursor (integer; query): a number that points to a specific location in a collection of responses and is pulled from the paging_token value of a record.
  • order (string; query): a designation of the order in which records should appear. Options include asc (ascending) or desc (descending). If this argument isn’t set, it defaults to asc.
  • limit (integer; query): the maximum number of records returned. The limit can range from 1 to 200 - an upper limit that is hardcoded in Horizon for performance reasons. If this argument isn’t designated, it defaults to 10.

Returns

{
"_links": {
"self": {
"href": "string",
"templated": true
},
"next": {
"href": "string",
"templated": true
},
"prev": {
"href": "string",
"templated": true
}
},
"_embedded": {
"records": [
{
"_links": {
"self": {
"href": "string",
"templated": true
},
"base": {
"href": "string",
"templated": true
},
"counter": {
"href": "string",
"templated": true
},
"operation": {
"href": "string",
"templated": true
}
},
"id": "string",
"paging_token": "string",
"ledger_close_time": "string",
"offer_id": "string",
"trade_type": "string",
"liquidity_pool_fee_bp": 0,
"base_liquidity_pool_id": "string",
"base_offer_id": "string",
"base_account": "string",
"base_amount": "string",
"base_asset_type": "string",
"base_asset_code": "string",
"base_asset_issuer": "string",
"counter_liquidity_pool_id": "string",
"counter_offer_id": "string",
"counter_account": "string",
"counter_amount": "string",
"counter_asset_type": "string",
"counter_asset_code": "string",
"counter_asset_issuer": "string",
"base_is_seller": true,
"price": {
"n": "string",
"d": "string"
}
}
]
}
}

Request example

curl https://rpc.ankr.com/http/stellar_horizon/liquidity_pools/{liquidity_pool_id}/trades{?cursor,order,limit}

Response example

{
"_links": {
"self": {
"href": "https://rpc.ankr.com/liquidity_pools/3b476aff8a406a6ec3b61d5c038009cef85f2ddfaf616822dc4fec92845149b4/trades?cursor=\u0026limit=1\u0026order=asc"
},
"next": {
"href": "https://rpc.ankr.com/liquidity_pools/3b476aff8a406a6ec3b61d5c038009cef85f2ddfaf616822dc4fec92845149b4/trades?cursor=212026605370699777-0\u0026limit=1\u0026order=asc"
},
"prev": {
"href": "https://rpc.ankr.com/liquidity_pools/3b476aff8a406a6ec3b61d5c038009cef85f2ddfaf616822dc4fec92845149b4/trades?cursor=212026605370699777-0\u0026limit=1\u0026order=desc"
}
},
"_embedded": {
"records": [
{
"_links": {
"self": {
"href": ""
},
"base": {
"href": "https://rpc.ankr.com/accounts/GBEI3CDPMFUKZCJ3EFJNGO7UNQSFTKGGCFH6HUXGHLMJ4ML3H7P4Y7R6"
},
"counter": {
"href": "https://rpc.ankr.com/liquidity_pools/3b476aff8a406a6ec3b61d5c038009cef85f2ddfaf616822dc4fec92845149b4"
},
"operation": {
"href": "https://rpc.ankr.com/operations/212026605370699777"
}
},
"id": "212026605370699777-0",
"paging_token": "212026605370699777-0",
"ledger_close_time": "2023-12-08T09:16:26Z",
"trade_type": "liquidity_pool",
"liquidity_pool_fee_bp": 30,
"base_offer_id": "4823712623798087681",
"base_account": "GBEI3CDPMFUKZCJ3EFJNGO7UNQSFTKGGCFH6HUXGHLMJ4ML3H7P4Y7R6",
"base_amount": "9.9125000",
"base_asset_type": "native",
"counter_liquidity_pool_id": "3b476aff8a406a6ec3b61d5c038009cef85f2ddfaf616822dc4fec92845149b4",
"counter_amount": "1701.5904043",
"counter_asset_type": "credit_alphanum4",
"counter_asset_code": "VZT",
"counter_asset_issuer": "GBENYXZDFFR2J4F4DB3YPBBAM244TXYOTIOOUQI5DBT3OKUU4ZJ2M7NO",
"base_is_seller": false,
"price": {
"n": "17015904043",
"d": "99125000"
}
}
]
}
}