Skip to main content

A Python library for interacting with the Torn API

Project description

TornAPI

TornAPI is a Python library for interacting with the Torn API. This library provides easy access to Torn's various API endpoints, including user, city, and faction endpoints. It supports rate limiting and allows users to set custom API keys.

  • Easy-to-use API client.
  • Rate limiting to avoid exceeding the API request limits.
  • Custom exceptions for error handling.
  • Comprehensive support for user selection endpoints.

Features

  • Access to multiple Torn API endpoints
  • Rate limiting to prevent exceeding API request limits
  • Customizable API key and rate limit settings
  • Optional user ID parameter for user-related endpoints
  • Exception handling for API errors
  • Deprecation warnings for deprecated functions

Installation

To install TornAPI, simply use pip:

pip install tornapi

Usage

Here's an example of how to use the TornAPI library:

from tornapi import TornAPI

# Initialize the API client
api = TornAPI('your-api-key', rate_limit=100)

# Fetch basic user data
user_data = api.user.basic()
print(user_data)

# Fetch user icons
icons_data = api.user.icons()
print(icons_data)

# Fetch your profile
profile_data = api.user.profile()
print(profile_data)

# Fetch another user's profile by user ID
profile_data = api.user.profile(user_id=123456)
print(profile_data)

# Fetch stock data
stock_data = api.torn.stocks()
print(stock_data)

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

tornapi-0.2.0.tar.gz (6.4 kB view hashes)

Uploaded Source

Built Distribution

tornapi-0.2.0-py3-none-any.whl (7.3 kB view hashes)

Uploaded Python 3

Supported by

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