An asynchronous Python API wrapper for TruckersMP.
Warning
This project is no longer maintained and the repository has been archived.
There will be no further features or bug fixes. The code remains available for reference or forking.
- Rate limiting - Pre-emptive rate limiting so you'll never hit a 429.
- Caching - Automatic caching of responses so you don't have to.
- Configurable - Several configuration options on initialisation.
- Documented - Full docs with examples included for reference.
- Data models - API responses are parsed into objects (Python classes).
Install via pip using either of these methods:
pip install async-truckersmp
pip install git+https://github.com/SamNuttall/Async-TruckersMP.git
Let's write a script to print all the server names.
from truckersmp import TruckersMP # Import the library
loop = asyncio.get_event_loop() # Get the asyncio event loop
async def main():
truckersmp = TruckersMP() # Initalise the TruckersMP class
servers = await truckersmp.get_servers() # Call the get_servers method
for server in servers: # Loop through each server
print(server.name) # Get the name of the server and print it
loop.run_until_complete(main()) # Run the main function- Documentation.
- Github Repository.
- If you need further help, feel free to contact Sam#9210 on Discord or open a new issue.
Released under the MIT License.