Skip to content
TORNLIFE More

[TornAPI v2] Python Torn API Wrapper (Async/Sync)

Started by AfricanChild [3157295] on in Tools & Userscripts.

37 replies · 1.4k views · thread synced · 3 days ago · View on torn.com
About this thread

Posts archived: 38 / 38 posts (100%) · the total is Torn's reply count + the opening post at the last fetch

Counted by TornLife from the archived posts.

Archived posts
38
Discussion span
→
Authority score
38 / 100
Historical score
37 / 100
Story score
52 / 100
Engagement score
72 / 100

People posting, likes and official posts are not counted for this thread yet: on threads longer than one page they come from a periodic pass over the archive, which has not covered it.

Most-liked replies

AfricanChild [3157295]

[image: i.imgur.com]

[image: camo.githubusercontent.com] [image: camo.githubusercontent.com] [image: camo.githubusercontent.com] [image: camo.githubusercontent.com]



Hello everyone,

A random advertisement on YouTube and my passion for programming has brought me here today, to create an open-source Python wrapper for the Tom API and my newfound enjoyment for Torn.


 

TornAPIWrapper

TornAPIWrapper is an open-source Python library for interacting with the Torn City API v2, offering access to Torn City data. It covers all available Torn API v2 endpoints and is kept current with the latest updates to the API.

 

It provides sync and async support, built-in API error handling, and a modern API wrapper - all you need to build Discord bots, tools, trackers, dashboards, and websites, while TornAPIWrapper takes care of the rest.

 

 

Instructions

 

  • How to Install Python: YouTube
  • Visit the repository and install TornAPIWrapper: GitHub



 

Sync Code Example

 

from TornAPIWrapper import TornAPIWrapper
 
torn = TornAPIWrapper(api_key="1aBcDeFgH2iJkLmN")
 
print(torn.user.get_profile())

 

 

Thank you


Links to checkout:

Sync/Async Code Examples

GitHub Repository
README.md
TornAPIWrapper (PyPi)

Torn API v2

If you create a project using TornAPIWrapper, let me know! I’d love to see what people create. I wouldn’t mind starting a list of projects built with TornAPIWrapper!

Auxxfire [1705062]
I can't say enoough yessssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
AfricanChild [3157295]

My first forum response! 

I'm so glad I could create something you can use! Please let me know if you need any help or have questions :D

I'd love to know what projects you'll create, with TornAPIWrapper. Let me know! :)

Thank you Auxxfire, hope you enjoy!!

AfricanChild [3157295]
BritishBenji!

Thank you! Let me know how it goes! Would love to see what you'll create, hope you like it :D

if you have any questions let me know!
Llyfr [2531272]
Very nice, It would be cool if for example selections were in some type of enum so you know what options are available for each section. Also check out this site, it documents the API (way better that the official documentation) and could be useful in adding new features. https://tornapi.tornplayground.eu/
AfricanChild [3157295]
Llyfr! Thank you!

I appreciate the suggestion, I looked a little into it, I might implement this in the future, but I'm not quite sure if it'll over complicate it or not. I want anyone to be able to use TornAPIWrapper, but I also really like the idea of being able to see everything you are able to select in your IDE. I'm also not quite sure how much Torn API updates. If it updates quite often, I do not want to release multiple packages because of selection changes. I think leaving the selections as a list of any strings might have an advantage to save time and have less redundancy with updates, as users can use the new selection feature without having to wait for a new update.

I also appreciate the link to the TornPlayground.eu docs, I have actually added this to the README.md file on GitHub for people to check out, its a useful resource that has helped me create this wrapper. I also added it for people to see what they can select in a more detailed and clear interface.

Thank you for your post, I'll look deeper into it, and see how everything goes overtime; might implement.


EDIT: Oh also thank you so much for giving the repository a star! Much appreciated :D
AfricanChild [3157295]
Terekhov!

Yes! Of course, I had to add examples for people to check out! Hope you enjoy the wrapper! Let me know if you need any help, would be more than happy too help!

Thank you for the comment :D
AfricanChild [3157295]
No way!

I enjoy making Discord bots! Be on the look out for my next project, i might release another one soon for Discord bots depending how well this one goes.

Nice project, let me know how it goes! Hope there are no issues with the wrapper, let me know if there are any problems with it :D Enjoy!
AfroBoy [2822838]
R+
Gave you a star as Mathangwane on GitHub, dear African child ? I'm amused by that I call myself AfroBoy (African boy) and used AI to generate my profile picture and you call yourself AfricanChild and seem to have also done the same with your pp. We might get accused of being multis.
AfricanChild [3157295]

Dude!

No way, I just checked out your GitHub repositories and you also have some type of WiFi exfil that you created aswell!

Are you my past reincarnation?

AfricanChild [3157295]

Updated to support Torn API v2 (Swagger) and modern Python standards. The old v1 version had design limitations that made it harder to maintain and extend.

 

What’s new in V2:

  • Full support for Torn API v2
  • Modular, endpoint-based structure (User, Faction, Market, Forum, Racing, Property, Key, Torn)
  • Clear, well-typed method signatures
  • Automatic parameter handling with error management
  • Session-based requests
  • A cleaner, more flexible foundation for future updates
AfricanChild [3157295]

Added async support.

 

What's new:

  • Add async endpoints
  • Add async client class
  • Add timeout support to async client
  • Add async usage examples
  • Add aiohttp dependency for async support
  • Export TornAPIWrapperAsync in __init__.py
  • Misc updates: dynamic __version__ in request headers, rename torn_api_wrapper to client, edit example comments, and fix comment in builders.py etc.
AfricanChild [3157295]

Updated to patch 19.02.2026.

What's new:

  • [API-v2] Added new selection 'user' -> 'organizedcrimes' (Minimal access key). This selection only shows organized crimes with Recruiting status, and only contains empty slots.
AfricanChild [3157295]

Updated to patch 23.02.2026.

What's new:

  • Access All Torn stocks.
  • Access Torn specific stocks with chart history.
  • Access User stocks.