Skip to content

Tornium/torngen_python_client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TorngenPythonClient

TorngenPythonClient is an autogenerated Python library containing the paths and schemas required to make requests against the Torn API v2 and parse the responses.

Installation

This library is intended to be installed from GitHub to allow developers to update the generated OpenAPI-related code regardless of the maintenance of projects depending upon this library.

For example, this can be done using pip:

pip3 install git+https://github.com/Tornium/torngen_python_client.git

Basic Usage

  1. Create an implementation of the HTTPAdapater to perform API calls and any custom API-related behavior.
  2. Perform the query:
    • Select a resource from the path documentation.
    • Determine the selections to use.
    • Determine the parameters to use for those selections.

Example:

from torngen.path import User

response = (
    User()
    .key("{{ API KEY }}")
    .select(User.attacks, User.bounties)
    .limit(10)
    .get(adapter=CustomHTTPClient)
    .parse()
)
  1. Access query response: After being parsed, each selection's parsed response can be selected by accessing the response dictionary by the selection name.

Example:

for attack in response.attacks:
    print(f"{attack.defender.name} was attacked")

Consult the documentation (and the path documentation) for information on available endpoints and parameters. For detailed API usage and available endpoints, refer to the Torn API Swagger documentation and the generated source code in this repository.

License

Copyright 2025 tiksan

This project is licensed under Apache 2.0; see LICENSE.md for more details.

Troubleshooting & Contributing

  • If you encounter issues, please ensure you have the latest version of the library.
  • Contributions are welcome! Open a pull request or submit an issue on GitHub if you have suggestions or bug reports.
  • If you have any questions, please use the Tornium Discord server.

About

Python Torn APIv2 client

Resources

License

Stars

Watchers

Forks