[Guide] How to start making use of official trade site's REST API
Hello, this is my first time posting so please guide and advice me if this post has any issues.
I've played POE for awhile and started to use a popular trade macro to lookup items in-game. Trade Macro: However, I noticed that it was using poe.trade rather than the official trading site and that's not what I want. So I went on to inspect the AHK code for the trade macro to see how they implemented it and discovered that they basically use a lot "string find" and "regular expression match" functions to lookup data from a bunch of local text files, then parses and stores it as an "item" and "itemData" object for further processing like searching data on poe.trade.
Spoiler
![]() The contributors of the macro really put in a lot of work, especially the advanced features like price prediction. However, I can't help but feel that it all seems a little hard coded. Maybe there is no choice but to hard code, especially when parsing data. I then stumbled upon a 2 year old reddit thread that mentions how I can make my own queries to the official trading site, so I experimented with it a little bit. Reddit Thread: I'm not really good at making guides, and don't know where this post is going, but I'll show you the steps I did to accomplish what I did, and you'll have to decide for yourself what to do with the knowledge gained. I learnt that if you press "CTRL + C" while hovering over an item, you can copy some item data into your clipboard.
Spoiler
![]() ![]() So following some inspirations from the reddit thread, I used a software called Postman to play around with the official trade site's API. Here you can see me setting the HTML method, the URL, and the JSON body that I'm about to POST to the API.
Spoiler
![]() Now you may be wondering where I got these stat ids from, I got them using the steps below, which was mentioned in the reddit thread too.
Spoiler
![]() ![]() After clicking send on the POST request, I get a response as follows:
Spoiler
![]() Using this response and the id, I send a GET request with the following URL to get the result I want.
Spoiler
![]() ![]() and the results can be verified using the short id given in the previous response when using a browser.
Spoiler
![]() Now I still haven't thought about how to proceed moving forward, but I hope some people smarter than me can make use of this knowledge. Please do view the reddit thread for more information and go easy on me. I just want to share some knowledge. Thank you. Last bumped on Dec 24, 2022, 1:28:49 PM
|
![]() |
Usually when a company wants others to use their API, they'll expose a doc with their entry points and it is done automatically with libraries like Swagger(example for java APIs)
The dirty way to proceed with macros is to use auto hotkey to curl it. Last edited by galuf on Dec 30, 2019, 3:23:21 PM
| |
The only problem I could see with sharing this API would be if not everyone could use it.
Tune it so everyone can use it with little prerequisite knowledge of coding or whatnot, and it should be more palatable as a possible official macro for the main trading site. I don't think it' so much a matter of GGG wanting or not wanting others to use their API, but that it's fair, accessible to all, and doesn't eat too much mainframe time rendering search results. [19:36]#Mirror_stacking_clown: try smoke ganja every day for 10 years and do memory game
| |
thank you Xenogenics!
|
![]() |
i am getting an 403 status code
Here is my code: " Could you please tell me what i am doing wrong? | |
Nice job, thanks for sharing!
Since you’re making successful REST calls in Postman, your next steps could involve experimenting with something like JavaScript or Powershell and then “do stuff” with the results (like formatting, listing, logic, etc). Just be wary of the rate limits (don’t spam your script) and whatever the TOS says about using the API (do not automate multiple server-side actions within game). |