Skip to main content

An asynchronous Python API wrapper for TruckersMP.

Project description

An asynchronous Python API wrapper for TruckersMP.

Features

  • 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).

Usage

Install

Install via pip using either of these methods:

pip install async-truckersmp
pip install git+https://github.com/SamNuttall/Async-TruckersMP.git

Quickstart

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

Resources & Support

Licence

Released under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

async-truckersmp-0.2.5.tar.gz (16.5 kB view details)

Uploaded Source

File details

Details for the file async-truckersmp-0.2.5.tar.gz.

File metadata

  • Download URL: async-truckersmp-0.2.5.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.9

File hashes

Hashes for async-truckersmp-0.2.5.tar.gz
Algorithm Hash digest
SHA256 10bfd219477a6f84662a7bc29b2eb399f922fc833ec9a501e5e9f3342d12c995
MD5 0bb25b62311ff00f80bda80e778a8e59
BLAKE2b-256 906b25d02fdc00a42d1bacfb890a5604b817e312836f390aee8763d0c63af919

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page