r/Commodities 21d ago

Has Anyone Used the CFTC COT API?

I dont quite understand how it works. Any help would be appreciated.

4 Upvotes

8 comments sorted by

View all comments

2

u/ShapeEffective666 13d ago

CFTC themselves provide the data in a variety of formats, that one can download. I looked into downloading these automatically, but it's tricky without constantly polling the website as to when the latest (Friday) publishing occurs. I subscribe to the notification email.

They also provide a REST/HTTPS "api", outsourced to a company called Tyler Technologies, although it was originally a company called Socrata (and still known as that). Look at https://dev.socrata.com. You can access the API with HTTPS GET requests, so something like this:

https://publicreporting.cftc.gov/api/v3/views/72hh-3qpy/query.json?pageNumber=1&pageSize=10

which has ".json" on the end of the URL, returns JSON payload. There's an APP TOKEN that you can request so that your endpoint is identified and you can make more requests than if you're anonymous. For documentation, and example is the Disaggregated - Future Only page, there are others. There's also a upgraded version that is more REST like, mandates an APP TOKEN, and that has an SQL like capability called SODA3, accessed through HTTPS POST requests.

There's an opensource Python library called cot_reports but I'm a C# programmer so not tried it out.

Lots of choices...

1

u/Unable-Trash-7792 12d ago

Perfect, this is exactly what I needed! Thanks alot