TorngenPythonClient
is an autogenerated Python library containing the paths and schemas required to make requests against the Torn API v2 and parse the responses.
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
- Create an implementation of the
HTTPAdapater
to perform API calls and any custom API-related behavior. - 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()
)
- 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.
Copyright 2025 tiksan
This project is licensed under Apache 2.0; see LICENSE.md for more details.
- 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.