For a while now I'm trying to figure out how to get all offers for a particular Asset (or pair). As an example, StellarExpert lists all offers of MOBI on the following page: https://stellar.expert/explorer/public/asset/MOBI-GA6HCMBLTZS5VYYBCATRBRZ3BZJMAFUDKYYF6AH6MVCMGWMRDNSWJPIH?filter=offers

I have checked the REST API docs and the JavaScript SDK docs but thus far I only found a way to query offers for an account, nothing about an asset.

I was hoping that the orderbook would give me some options but it does not.

Any pointers would be greatly appreciated.


2 Answers 2


You could query the stellar-core database, offers are located in the offers table. Unfortunately assets are stored in XDR representation, so you have to figure that out in javascript first:

console.log( asset.toXDRObject().toXDR('base64') );

// outputs: AAAAAU5hQ2wAAAAApAXP7+jJZeISoiFWoK7BMn2Uq4bwEZwRIVhMrWS2C24=

DB query:

select * from offers where sellingasset='AAA...WS2C24=' or buyingasset='AAA...WS2C24=';
  • I was actually going into this direction. I have setup a watcher node and I see the offers table in the PG database. When running the node it does catch up but the offer table remains empty. I have to investigate this more, to be honest. Now with your answer I'm pretty sure with a watcher node it does not include that info. Or should it still fill up the offer table?
    – CodeR70
    Jul 16, 2019 at 22:08
  • The catchup takes a lot longer so I moved my node to a machine that is up 24/7. Then I'll see what happens after the catchup has finished. Looking at the table structure it should provide the info I need. I will keep you posted of any progress.
    – CodeR70
    Jul 17, 2019 at 14:04
  • 1
    I would expect watcher nodes to track offers, too. My basic validators without full catchup have them and I can't imagine why a synced watcher should not.
    – sui
    Jul 17, 2019 at 20:04
  • Yeah, the db tables are filling up. It's gonna take a while until the node catches up, the machine is not the fastest. But I'm sure it will get there and I will then be able to get the info I wanted. Thanks so much!
    – CodeR70
    Jul 18, 2019 at 13:01

Horizon provides an orderbook endpoint that takes buying and selling assets as arguments. You can use this to get all offers for any asset pair.

Is there something I'm misunderstanding about your question?

  • The orderbook endpoint aggregates the offers. It does not provide individual offers.
    – CodeR70
    Jul 16, 2019 at 22:04
  • Nothing is aggregated. For example: horizon.stellar.org/… corresponds exactly to stellar.expert/explorer/public/asset/… Jul 16, 2019 at 23:17
  • @CodeR70 the link you posted in your OP points to operations related to offers (when they were created, updated etc), not to the current offers themselves. Compare to the stellar expert link I posted in the previous comment. Perhaps that is the source of confusion here? Jul 16, 2019 at 23:19
  • Ok, just to be clear. I would like to have individual offers, not an aggregation which the orderbook endpoint does generate (which is what you expect from an orderbook). The offers tab in stellar expert actually shows the offers with a reference to the operations. Still, if you look at the details column, it includes the offer IDs themselves. Anyway, sorry for the confusion. I just tried to give an example with the stellar expert link. I'm currently running a node myself and see if the info can be queried in the Postgress database. It's still catching up though.
    – CodeR70
    Jul 17, 2019 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.