### Install TornAPIWrapper Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Install the library using pip. ```bash pip install tornapiwrapper ``` -------------------------------- ### Fetch User Profile (Sync) Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch a player's profile using the sync client. Omit user_id to get the authenticated user's profile. Use striptags=True to remove HTML tags from text fields. ```python from TornAPIWrapper import TornAPIWrapper torn = TornAPIWrapper(api_key="YOUR_API_KEY") # Own profile (no user_id) my_profile = torn.user.get_profile() # Another player's profile profile = torn.user.get_profile(user_id=2561334, striptags=True) print(profile["name"]) # 'Chedburn' print(profile["level"]) # 100 print(profile["faction"]) # {'faction_id': ..., 'faction_name': ...} print(profile["status"]) # {'description': 'Okay', 'state': 'Okay', ...} ``` -------------------------------- ### User Endpoints - Get Basic Info Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Retrieves minimal player data, accepting either a user ID or Discord ID. This endpoint requires a Public-access key. ```APIDOC ## user.get_basic() ### Description Returns minimal player data. Accepts a user ID or Discord ID. Requires a Public-access key. ### Method `torn.user.get_basic(user_id: int | None = None, discord_id: int | None = None)` ### Parameters #### Query Parameters - **user_id** (int) - Optional - The ID of the user. - **discord_id** (int) - Optional - The Discord ID of the user. ### Request Example ```python basic = torn.user.get_basic(user_id=1) print(basic["name"], basic["level"]) ``` ### Response #### Success Response (200) - **name** (str) - The player's name. - **level** (int) - The player's level. ``` -------------------------------- ### User Endpoints - Get Profile Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetches the full profile data for a specified player or the authenticated user. Requires a Public-access key or higher. ```APIDOC ## user.get_profile() ### Description Returns full profile data for the authenticated user or any public user. Requires a Public-access key or higher. ### Method `torn.user.get_profile(user_id: int | None = None, striptags: bool | None = None)` ### Parameters #### Query Parameters - **user_id** (int) - Optional - The ID of the user whose profile to fetch. If not provided, fetches the profile of the authenticated user. - **striptags** (bool) - Optional - If true, HTML tags will be stripped from the response. ### Request Example ```python from TornAPIWrapper import TornAPIWrapper torn = TornAPIWrapper(api_key="YOUR_API_KEY") # Own profile (no user_id) my_profile = torn.user.get_profile() # Another player's profile profile = torn.user.get_profile(user_id=2561334, striptags=True) print(profile["name"]) print(profile["level"]) print(profile["faction"]) print(profile["status"]) ``` ### Response #### Success Response (200) - **name** (str) - The player's name. - **level** (int) - The player's level. - **faction** (dict) - Information about the player's faction. - **status** (dict) - Information about the player's current status. ``` -------------------------------- ### racing.get_races() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Returns a paginated list of races ordered by start time. Filterable by category. Requires a Public-access key. ```APIDOC ## racing.get_races() ### Description Returns a paginated list of races ordered by start time. Can be filtered by category. ### Access Requires a Public-access key. ### Parameters #### Query Parameters - **limit** (int) - Optional - The maximum number of races to return. - **sort** (string) - Optional - The order to sort races by (e.g., "DESC"). - **race_category** (string) - Optional - Filter races by category (e.g., "official"). ### Usage ```python # All recent races races = torn.racing.get_races(limit=100, sort="DESC") # Official races only official = torn.racing.get_races(race_category="official") for race in official["races"]: print(race["title"], race["track_id"], race["status"]) ``` ``` -------------------------------- ### Fetch Racing List Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Retrieves a paginated list of races, ordered by start time and filterable by category. Requires a Public-access API key. ```python # All recent races races = torn.racing.get_races(limit=100, sort="DESC") ``` ```python # Official races only official = torn.racing.get_races(race_category="official") for race in official["races"]: print(race["title"], race["track_id"], race["status"]) ``` -------------------------------- ### Fetch Basic User Info (Sync) Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch minimal player data using the sync client. Accepts a user ID or Discord ID and requires a Public-access key. ```python basic = torn.user.get_basic(user_id=1) print(basic["name"], basic["level"]) ``` -------------------------------- ### Instantiate Sync Client Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Instantiate the synchronous TornAPIWrapper with an API key. Custom timeouts can be provided as a single float or a tuple of connect and read timeouts. ```python from TornAPIWrapper import TornAPIWrapper # Basic instantiation torn = TornAPIWrapper(api_key="YOUR_API_KEY") # With custom timeout (seconds): single float or (connect_timeout, read_timeout) tuple torn = TornAPIWrapper(api_key="YOUR_API_KEY", request_timeout=25) torn = TornAPIWrapper(api_key="YOUR_API_KEY", request_timeout=(10, 35)) data = torn.user.get_profile(user_id=2561334) print(data) # {'name': 'Chedburn', 'level': 100, 'faction': {...}, 'status': {...}, ...} ``` -------------------------------- ### user.get_inventory() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch inventory by category. Returns paginated inventory items for the specified category. Requires a Limited-access key. ```APIDOC ## user.get_inventory() ### Description Fetch inventory by category. Returns paginated inventory items for the specified category. Requires a Limited-access key. ### Method GET ### Endpoint /user/get_inventory ### Parameters #### Query Parameters - **inventory_category** (string) - Required - The category of inventory to fetch (e.g., "Primary", "Melee", "Medical"). - **limit** (integer) - Optional - Maximum number of items to return (default 20). - **offset** (integer) - Optional - Number of items to skip for pagination (default 0). ### Request Example ```python # Valid categories: "Melee", "Primary", "Secondary", "Medical", "Drug", "Clothing", etc. inventory = torn.user.get_inventory(inventory_category="Primary", limit=20, offset=0) ``` ### Response #### Success Response (200) - **inventory** (array) - List of inventory items. - **name** (string) - The name of the item. - **quantity** (integer) - The quantity of the item. ``` -------------------------------- ### user.get_money() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch current wealth. Returns wallet, vault, bank, Cayman, and other wealth figures. Requires a Public-access key. ```APIDOC ## user.get_money() ### Description Fetch current wealth. Returns wallet, vault, bank, Cayman, and other wealth figures. Requires a Public-access key. ### Method GET ### Endpoint /user/get_money ### Response #### Success Response (200) - **wallet_balance** (integer) - Amount of money in the wallet. - **vault_amount** (integer) - Amount of money in the vault. - **bank_amount** (integer) - Amount of money in the bank. - **cayman_amount** (integer) - Amount of money in the Cayman account. ### Request Example ```python money = torn.user.get_money() ``` ### Response Example ```json { "wallet_balance": 1000000, "vault_amount": 5000000, "bank_amount": 10000000, "cayman_amount": 2000000 } ``` ``` -------------------------------- ### user.get_battlestats() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch battle statistics. Returns strength, defense, speed, and dexterity. Requires a Public-access key. ```APIDOC ## user.get_battlestats() ### Description Fetch battle statistics. Returns strength, defense, speed, and dexterity. Requires a Public-access key. ### Method GET ### Endpoint /user/get_battlestats ### Response #### Success Response (200) - **strength** (integer) - Current strength level. - **defense** (integer) - Current defense level. - **speed** (integer) - Current speed level. - **dexterity** (integer) - Current dexterity level. ### Request Example ```python stats = torn.user.get_battlestats() ``` ### Response Example ```json { "strength": 10000, "defense": 10000, "speed": 10000, "dexterity": 10000 } ``` ``` -------------------------------- ### Fetch current wealth Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Returns wallet, vault, bank, Cayman, and other wealth figures. Requires a Public-access key. ```python money = torn.user.get_money() print(money["wallet_balance"], money["vault_amount"]) ``` -------------------------------- ### Fetch battle statistics Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Returns strength, defense, speed, and dexterity. Requires a Public-access key. ```python stats = torn.user.get_battlestats() print(stats["strength"], stats["defense"], stats["speed"], stats["dexterity"]) ``` -------------------------------- ### company.get_stock() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch your company's current stock inventory. Requires a Limited-access key. ```APIDOC ## company.get_stock() ### Description Fetch your company's current stock inventory. ### Access Requires a Limited-access key. ### Usage ```python stock = torn.company.get_stock() ``` ``` -------------------------------- ### market.get_bazaar() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch bazaar directory. Returns the weekly bazaar directory or a specialized category bazaar. Requires a Public-access key. ```APIDOC ## market.get_bazaar() ### Description Fetch bazaar directory. Returns the weekly bazaar directory or a specialized category bazaar. Requires a Public-access key. ### Method GET (Assumed) ### Endpoint /market/get_bazaar ### Parameters #### Query Parameters - **bazaar_category** (string) - Optional - Filters the bazaar by a specific category (e.g., "Drug"). - **item_id** (int) - Optional - Filters the bazaar for a specific item ID. ### Request Example ```python # Weekly bazaar weekly = torn.market.get_bazaar() # Specialized category bazaar drugs_bazaar = torn.market.get_bazaar(bazaar_category="Drug") # Bazaar for specific item item_bazaar = torn.market.get_bazaar(item_id=180) ``` ### Response #### Success Response (200) - **bazaar** (object) - Contains bazaar directory information. ``` -------------------------------- ### faction.get_basic() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch faction profile. Returns basic faction details. Publicly accessible with any API key. ```APIDOC ## faction.get_basic() ### Description Fetch faction profile. Returns basic faction details. Publicly accessible with any API key. ### Method GET ### Endpoint /faction/get_basic ### Parameters #### Query Parameters - **faction_id** (integer) - Optional - The ID of the faction to fetch details for (defaults to the user's faction). ### Request Example ```python my_faction = torn.faction.get_basic() other_faction = torn.faction.get_basic(faction_id=7835) ``` ### Response #### Success Response (200) - **name** (string) - The name of the faction. - **respect** (integer) - The faction's respect. - **members** (integer) - The number of members in the faction. ``` -------------------------------- ### Fetch inventory by category Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Returns paginated inventory items for a specified category. Requires a Limited-access key. ```python # Valid categories: "Melee", "Primary", "Secondary", "Medical", "Drug", "Clothing", etc. inventory = torn.user.get_inventory(inventory_category="Primary", limit=20, offset=0) for item in inventory["inventory"]: print(item["name"], item["quantity"]) ``` -------------------------------- ### user.get_log() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch detailed activity logs. Returns up to 20 log entries filtered by log IDs or a log category ID. Requires a Full-access key. ```APIDOC ## user.get_log() ### Description Fetch detailed activity logs. Returns up to 20 log entries filtered by log IDs or a log category ID. Requires a Full-access key. ### Method GET ### Endpoint /user/get_log ### Parameters #### Query Parameters - **log_category_id** (integer) - Optional - Filter logs by category ID. - **log_id** (array) - Optional - Filter logs by specific log IDs. - **target_id** (integer) - Optional - Filter logs involving a specific player ID. - **limit** (integer) - Optional - Maximum number of log entries to return (default 20). ### Request Example ```python # By log category logs = torn.user.get_log(log_category_id=5, limit=20) # By specific log IDs logs = torn.user.get_log(log_id=[1001, 1002, 1050]) # Logs involving a specific player logs = torn.user.get_log(target_id=2561334) ``` ### Response #### Success Response (200) - **logs** (array) - List of log entries. ``` -------------------------------- ### Fetch detailed activity logs Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Returns up to 20 log entries filtered by log IDs or a log category ID. Requires a Full-access key. ```python # By log category logs = torn.user.get_log(log_category_id=5, limit=20) ``` ```python # By specific log IDs logs = torn.user.get_log(log_id=[1001, 1002, 1050]) ``` ```python # Logs involving a specific player logs = torn.user.get_log(target_id=2561334) ``` -------------------------------- ### Fetch faction member list Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Returns a list of all faction members. Extended data available with Limited+ keys. Requires a Public-access key. ```python members = torn.faction.get_members(striptags=True) for uid, member in members["members"].items(): print(uid, member["name"], member["status"]["state"]) ``` -------------------------------- ### Fetch Faction Wars and Pacts Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Retrieves active wars and pact details. Requires a Public-access key. ```python wars = torn.faction.get_wars() print(wars["wars"], wars["pacts"]) ``` -------------------------------- ### faction.get_wars() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch wars and pacts. Returns active wars and pact details. Requires a Public-access key. ```APIDOC ## faction.get_wars() ### Description Fetch wars and pacts. Returns active wars and pact details. Requires a Public-access key. ### Method GET (Assumed) ### Endpoint /faction/get_wars ### Parameters None ### Request Example ```python wars = torn.faction.get_wars() print(wars["wars"], wars["pacts"]) ``` ### Response #### Success Response (200) - **wars** (list) - A list of active wars. - **pacts** (list) - A list of pact details. ``` -------------------------------- ### key.get_info() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Returns the access level and other metadata about the current API key. Requires a Public-access key. ```APIDOC ## key.get_info() ### Description Fetches metadata about the current API key, including its access level and type. ### Access Requires a Public-access key. ### Usage ```python info = torn.key.get_info() print(info["access_level"], info["access_type"]) # access_level: 1=Public, 2=Minimal, 3=Limited, 4=Full, 0=Custom ``` ``` -------------------------------- ### Fetch faction profile Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Returns basic faction details. Publicly accessible with any API key. ```python my_faction = torn.faction.get_basic() other_faction = torn.faction.get_basic(faction_id=7835) print(other_faction["name"], other_faction["respect"], other_faction["members"]) ``` -------------------------------- ### Async Client with Context Manager Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Use the asynchronous TornAPIWrapperAsync within an async context manager for recommended lifecycle management. ```python import asyncio from TornAPIWrapper import TornAPIWrapperAsync async def main(): async with TornAPIWrapperAsync(api_key="YOUR_API_KEY") as torn: data = await torn.user.get_profile(user_id=2561334) print(data) asyncio.run(main()) ``` -------------------------------- ### user.get_attacksfull() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch simplified attack history. Returns up to 1,000 simplified attack records. Same filters as get_attacks. Requires a Limited-access key. ```APIDOC ## user.get_attacksfull() ### Description Fetch simplified attack history. Returns up to 1,000 simplified attack records. Same filters as `get_attacks`. Requires a Limited-access key. ### Method GET ### Endpoint /user/get_attacksfull ### Parameters #### Query Parameters - **limit** (integer) - Optional - Maximum number of records to return (default 1000). - **sort** (string) - Optional - Sort order (e.g., "DESC", "ASC"). ### Request Example ```python data = torn.user.get_attacksfull(limit=1000, sort="ASC") ``` ### Response #### Success Response (200) - **attacks** (array) - List of simplified attack records. ``` -------------------------------- ### faction.get_members() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch faction member list. Returns a list of all faction members. Extended data available with Limited+ keys. Requires a Public-access key. ```APIDOC ## faction.get_members() ### Description Fetch faction member list. Returns a list of all faction members. Extended data available with Limited+ keys. Requires a Public-access key. ### Method GET ### Endpoint /faction/get_members ### Parameters #### Query Parameters - **striptags** (boolean) - Optional - Whether to strip HTML tags from member names. ### Request Example ```python members = torn.faction.get_members(striptags=True) ``` ### Response #### Success Response (200) - **members** (object) - An object where keys are member IDs and values are member details. - **name** (string) - The name of the member. - **status** (object) - The status of the member. - **state** (string) - The current state of the member (e.g., "Active", "Away"). ``` -------------------------------- ### market.get_properties() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch property market listings. Returns paginated property listings for sale by property type. Requires a Public-access key. ```APIDOC ## market.get_properties() ### Description Fetch property market listings. Returns paginated property listings for sale by property type. Requires a Public-access key. ### Method GET (Assumed) ### Endpoint /market/get_properties ### Parameters #### Query Parameters - **property_type_id** (int) - Required - The ID of the property type to filter by. - **limit** (int) - Optional - The number of property listings to return per page (default 20). - **offset** (int) - Optional - The starting offset for pagination. ### Request Example ```python properties = torn.market.get_properties(property_type_id=1, limit=20, offset=0) ``` ### Response #### Success Response (200) - **properties** (list) - A list of property market listings. ``` -------------------------------- ### user.get_bounties() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch bounties on a user. Returns active bounties placed on the authenticated user or a specific player. Requires a Public-access key. ```APIDOC ## user.get_bounties() ### Description Fetch bounties on a user. Returns active bounties placed on the authenticated user or a specific player. Requires a Public-access key. ### Method GET ### Endpoint /user/get_bounties ### Parameters #### Query Parameters - **user_id** (integer) - Optional - The ID of the user to fetch bounties for (defaults to the authenticated user). ### Request Example ```python bounties = torn.user.get_bounties(user_id=2561334) ``` ### Response #### Success Response (200) - **bounties** (array) - List of bounty objects. - **reward** (integer) - The reward amount for the bounty. - **reason** (string) - The reason for the bounty. ``` -------------------------------- ### Fetch Property Market Listings Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Retrieves paginated property listings for sale by property type. Requires a Public-access key. ```python properties = torn.market.get_properties(property_type_id=1, limit=20, offset=0) ``` -------------------------------- ### Fetch energy/nerve/happy/life bars Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Returns current values for energy, nerve, happy, and life bars. Requires a Minimal-access key. ```python bars = torn.user.get_bars() print(bars["energy"]["current"], "/", bars["energy"]["maximum"]) print(bars["nerve"]["current"], "/", bars["nerve"]["maximum"]) ``` -------------------------------- ### faction.get_chain() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch current chain status. Returns the current or most recent chain for your faction or a specific faction. Requires a Public-access key. ```APIDOC ## faction.get_chain() ### Description Fetch current chain status. Returns the current or most recent chain for your faction or a specific faction. Requires a Public-access key. ### Method GET (Assumed) ### Endpoint /faction/get_chain ### Parameters #### Query Parameters - **faction_id** (int) - Optional - The ID of the faction to fetch chain status for. ### Request Example ```python chain = torn.faction.get_chain() print(chain["chain"]["current"], chain["chain"]["max"]) chain = torn.faction.get_chain(faction_id=7835) ``` ### Response #### Success Response (200) - **chain** (object) - Contains chain details. - **current** (int) - The current chain status. - **max** (int) - The maximum chain achieved. ``` -------------------------------- ### key.get_log() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetches up to 250 recent request logs for the current API key. Requires a Public-access key. ```APIDOC ## key.get_log() ### Description Returns up to 250 recent request logs for the current key. Requires a Public-access key. ### Method Signature `key.get_log(limit=None, timestamp=None, comment=None)` ### Parameters #### Query Parameters - **limit** (int) - Optional - Number of results to return. - **timestamp** (int) - Optional - Unix timestamp to bypass the API cache and get data at that time. - **comment** (str) - Optional - Identifies your tool/bot in Torn's API access logs. ### Request Example ```python log = torn.key.get_log(limit=50) for entry in log["key_access_log"]: print(entry["timestamp"], entry["endpoint"], entry["ip_address"]) ``` ### Response #### Success Response (200) - **key_access_log** (list) - A list of log entries. - Each entry is a dictionary containing: - **timestamp** (int) - The time of the request. - **endpoint** (str) - The API endpoint accessed. - **ip_address** (str) - The IP address from which the request was made. ``` -------------------------------- ### company.get_employees() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch company employees. Returns the list of employees. Extended data with Limited/Full/Custom keys. Requires a Public-access key. ```APIDOC ## company.get_employees() ### Description Fetch company employees. Returns the list of employees. Extended data with Limited/Full/Custom keys. Requires a Public-access key. ### Method GET (Assumed) ### Endpoint /company/get_employees ### Parameters None ### Request Example ```python employees = torn.company.get_employees() for uid, emp in employees["employees"].items(): print(uid, emp["name"], emp["position"]) ``` ### Response #### Success Response (200) - **employees** (object) - An object where keys are employee IDs and values are employee details. - **name** (string) - The name of the employee. - **position** (string) - The employee's position within the company. ``` -------------------------------- ### Fetch Bazaar Directory Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Retrieves the weekly bazaar directory or a specialized category bazaar. Requires a Public-access key. ```python # Weekly bazaar weekly = torn.market.get_bazaar() # Specialized category bazaar drugs_bazaar = torn.market.get_bazaar(bazaar_category="Drug") # Bazaar for specific item item_bazaar = torn.market.get_bazaar(item_id=180) ``` -------------------------------- ### company.get_profile() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch company profile. Returns a company's public profile. Extended data available with Limited+ keys. Requires a Public-access key. ```APIDOC ## company.get_profile() ### Description Fetch company profile. Returns a company's public profile. Extended data available with Limited+ keys. Requires a Public-access key. ### Method GET (Assumed) ### Endpoint /company/get_profile ### Parameters #### Query Parameters - **company_id** (int) - Optional - The ID of the company to fetch the profile for. If not provided, returns the profile of the company associated with the API key. ### Request Example ```python my_company = torn.company.get_profile() other_company = torn.company.get_profile(company_id=12345) print(other_company["name"], other_company["rating"]) ``` ### Response #### Success Response (200) - **company** (object) - Contains company profile details. - **name** (string) - The name of the company. - **rating** (int) - The company's rating. ``` -------------------------------- ### Async Client with Manual Lifecycle Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Instantiate the asynchronous TornAPIWrapperAsync and manually close the client when done. Ensure `await torn.close()` is called. ```python import asyncio from TornAPIWrapper import TornAPIWrapperAsync async def main(): torn = TornAPIWrapperAsync(api_key="YOUR_API_KEY") data = await torn.user.get_profile(user_id=2561334) print(data) await torn.close() # Must be called manually asyncio.run(main()) ``` -------------------------------- ### Fetch Faction News Feed Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Retrieves faction news entries by category, combining up to 10 categories. Requires faction permissions and a Minimal-access key. ```python news = torn.faction.get_news( news_category="attack", limit=50, sort="DESC", striptags=True ) ``` -------------------------------- ### faction.get_rankedwars() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch ranked war history. Returns paginated ranked war history. Requires a Public-access key. ```APIDOC ## faction.get_rankedwars() ### Description Fetch ranked war history. Returns paginated ranked war history. Requires a Public-access key. ### Method GET (Assumed) ### Endpoint /faction/get_rankedwars ### Parameters #### Query Parameters - **limit** (int) - Optional - The number of ranked wars to return per page (default 20). - **offset** (int) - Optional - The starting offset for pagination. ### Request Example ```python rw_history = torn.faction.get_rankedwars(limit=20, offset=0) for war in rw_history["rankedwars"]: print(war["war"]["start"], war["war"]["end"], war["war"]["winner"]) ``` ### Response #### Success Response (200) - **rankedwars** (list) - A list of ranked war history records. ``` -------------------------------- ### forum.get_threads() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch threads across all categories or for specific category IDs. Requires a Public-access key. ```APIDOC ## forum.get_threads() ### Description Returns threads across all categories or for specific category IDs. ### Access Requires a Public-access key. ### Parameters #### Query Parameters - **category_ids** (list of int) - Optional - IDs of the categories to fetch threads from. - **limit** (int) - Optional - The maximum number of threads to return. - **sort** (string) - Optional - The order to sort threads by (e.g., "DESC"). ### Usage ```python # All recent threads threads = torn.forum.get_threads(limit=50, sort="DESC") # Threads from specific categories threads = torn.forum.get_threads(category_ids=[1, 5, 12], limit=20) for thread in threads["threads"]: print(thread["title"], thread["author"]["name"]) ``` ``` -------------------------------- ### market.get_itemmarket() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch item market listings. Returns paginated item market listings for a specific item ID, with optional weapon bonus filter. Requires a Public-access key. ```APIDOC ## market.get_itemmarket() ### Description Fetch item market listings. Returns paginated item market listings for a specific item ID, with optional weapon bonus filter. Requires a Public-access key. ### Method GET (Assumed) ### Endpoint /market/get_itemmarket ### Parameters #### Query Parameters - **item_id** (int) - Required - The ID of the item to fetch listings for. - **limit** (int) - Optional - The number of listings to return per page (default 20). - **offset** (int) - Optional - The starting offset for pagination. - **bonus** (string) - Optional - Filters listings by a specific weapon bonus (e.g., "Damage"). ### Request Example ```python # Listings for item ID 206 (Micro Uzi) listings = torn.market.get_itemmarket(item_id=206, limit=20, offset=0) for listing in listings["itemmarket"]: print(listing["price"], listing["amount"]) # Filter for a specific weapon bonus listings = torn.market.get_itemmarket(item_id=206, bonus="Damage") ``` ### Response #### Success Response (200) - **itemmarket** (list) - A list of item market listings. ``` -------------------------------- ### user.get_bars() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch energy/nerve/happy/life bars. Returns current bar values. Requires a Minimal-access key. ```APIDOC ## user.get_bars() ### Description Fetch energy/nerve/happy/life bars. Returns current bar values. Requires a Minimal-access key. ### Method GET ### Endpoint /user/get_bars ### Response #### Success Response (200) - **energy** (object) - Energy bar details. - **current** (integer) - Current energy level. - **maximum** (integer) - Maximum energy level. - **nerve** (object) - Nerve bar details. - **current** (integer) - Current nerve level. - **maximum** (integer) - Maximum nerve level. ### Request Example ```python bars = torn.user.get_bars() ``` ### Response Example ```json { "energy": {"current": 100, "maximum": 100}, "nerve": {"current": 50, "maximum": 50}, "happy": {"current": 80, "maximum": 100}, "life": {"current": 1000, "maximum": 1000} } ``` ``` -------------------------------- ### Fetch Item Market Listings Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Retrieves paginated item market listings for a specific item ID, with an optional weapon bonus filter. Requires a Public-access key. ```python # Listings for item ID 206 (Micro Uzi) listings = torn.market.get_itemmarket(item_id=206, limit=20, offset=0) for listing in listings["itemmarket"]: print(listing["price"], listing["amount"]) # Filter for a specific weapon bonus listings = torn.market.get_itemmarket(item_id=206, bonus="Damage") ``` -------------------------------- ### forum.get_posts() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch 20 posts per page for a specific thread. Filterable by offset or timestamp range. Requires a Public-access key. ```APIDOC ## forum.get_posts() ### Description Returns posts for a specific thread, with options for pagination and filtering. ### Access Requires a Public-access key. ### Parameters #### Query Parameters - **thread_id** (int) - Required - The ID of the thread to fetch posts from. - **striptags** (bool) - Optional - Whether to strip HTML tags from post content. - **offset** (int) - Optional - The number of posts to skip. - **from_** (int) - Optional - Unix timestamp to fetch posts from. - **to** (int) - Optional - Unix timestamp to fetch posts until. ### Usage ```python posts = torn.forum.get_posts(thread_id=18453201, striptags=True, offset=0) for post in posts["posts"]: print(post["author"]["name"], post["content"]) # Filter by timestamp posts = torn.forum.get_posts(thread_id=18453201, from_=1700000000, to=1710000000) ``` ``` -------------------------------- ### faction.get_news() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch faction news feed. Returns faction news entries by category. Up to 10 categories can be combined. Requires faction permissions and a Minimal-access key. ```APIDOC ## faction.get_news() ### Description Fetch faction news feed. Returns faction news entries by category. Up to 10 categories can be combined. Requires faction permissions and a Minimal-access key. ### Method GET (Assumed) ### Endpoint /faction/get_news ### Parameters #### Query Parameters - **news_category** (string) - Required - The category of news to fetch (e.g., "attack"). - **limit** (int) - Optional - The maximum number of news entries to return (default 50). - **sort** (string) - Optional - The order to sort the results (e.g., "DESC"). - **striptags** (bool) - Optional - Whether to strip HTML tags from the news content. ### Request Example ```python news = torn.faction.get_news( news_category="attack", limit=50, sort="DESC", striptags=True ) ``` ### Response #### Success Response (200) - **news** (list) - A list of faction news entries. ``` -------------------------------- ### Fetch crime statistics Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Returns statistics and details for a specific crime by crime ID. Requires a Minimal-access key. ```python crime_stats = torn.user.get_crimes(crime_id=42) print(crime_stats) ``` -------------------------------- ### faction.get_contributors() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch challenge contributors. Returns member contribution data for a specific stat key. Requires faction API permissions and a Public-access key. ```APIDOC ## faction.get_contributors() ### Description Fetch challenge contributors. Returns member contribution data for a specific stat key. Requires faction API permissions and a Public-access key. ### Method GET (Assumed) ### Endpoint /faction/get_contributors ### Parameters #### Query Parameters - **stat_key** (string) - Required - The key for the statistic to fetch contributors for (e.g., "attackswon"). - **contributors_category** (string) - Required - The category of contributors (e.g., "current"). ### Request Example ```python contributors = torn.faction.get_contributors( stat_key="attackswon", contributors_category="current" ) ``` ### Response #### Success Response (200) - **contributors** (list) - A list of contributor data. ``` -------------------------------- ### faction.get_search() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Search factions by name or filter criteria. Requires a Public-access key. ```APIDOC ## faction.get_search() ### Description Search factions by name or filter criteria. Requires a Public-access key. ### Method GET (Assumed) ### Endpoint /faction/get_search ### Parameters #### Query Parameters - **faction_name** (string) - Optional - The name of the faction to search for. - **filters** (list) - Optional - A list of filter criteria (e.g., ["respectLessOrEqual20000", "membersGreater10"]). - **limit** (int) - Optional - The maximum number of factions to return (default 5). ### Request Example ```python results = torn.faction.get_search( faction_name="Dynasty", filters=["respectLessOrEqual20000", "membersGreater10"], limit=5 ) for faction in results["factions"]: print(faction["id"], faction["name"], faction["respect"]) ``` ### Response #### Success Response (200) - **factions** (list) - A list of faction search results. ``` -------------------------------- ### user.get_crimes() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch crime statistics. Returns statistics and details for a specific crime by crime ID. Requires a Minimal-access key. ```APIDOC ## user.get_crimes() ### Description Fetch crime statistics. Returns statistics and details for a specific crime by crime ID. Requires a Minimal-access key. ### Method GET ### Endpoint /user/get_crimes ### Parameters #### Query Parameters - **crime_id** (integer) - Required - The ID of the crime to fetch statistics for. ### Request Example ```python crime_stats = torn.user.get_crimes(crime_id=42) ``` ### Response #### Success Response (200) - **crime_stats** (object) - An object containing statistics and details for the specified crime. ``` -------------------------------- ### Fetch Item Catalog Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Retrieves game items, filterable by category or specific item IDs. Detail fields are only populated for specific item lookups. Requires a Public-access API key. ```python # All items (no details) all_items = torn.torn.get_items() ``` ```python # Specific items with full details items = torn.torn.get_items(item_ids=[206, 207, 180]) for item in items["items"].values(): print(item["name"], item["market_value"], item["type"]) ``` ```python # By category weapons = torn.torn.get_items(item_category="Primary") ``` -------------------------------- ### Fetch Faction Attack History Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Retrieves up to 100 detailed faction attack records. Requires faction API permissions and a Limited-access key. ```python attacks = torn.faction.get_attacks( attack_filters=["outgoing"], limit=100, sort="DESC", from_=1700000000 ) ``` -------------------------------- ### Fetch detailed attack history Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Retrieves up to 100 detailed attack records. Supports filtering, pagination, and sorting. Requires a Limited-access key. ```python data = torn.user.get_attacks( attack_filters=["outgoing"], limit=50, sort="DESC", from_=1700000000, to=1710000000 ) for attack in data["attacks"]: print(attack["attacker_id"], attack["result"], attack["respect_gain"]) ``` -------------------------------- ### Fetch Faction Chain Status Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Retrieves the current or most recent chain for your faction or a specific faction. Requires a Public-access key. ```python chain = torn.faction.get_chain() print(chain["chain"]["current"], chain["chain"]["max"]) chain = torn.faction.get_chain(faction_id=7835) ``` -------------------------------- ### Fetch Ranked War History Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Retrieves paginated ranked war history. Requires a Public-access key. ```python rw_history = torn.faction.get_rankedwars(limit=20, offset=0) for war in rw_history["rankedwars"]: print(war["war"]["start"], war["war"]["end"], war["war"]["winner"]) ``` -------------------------------- ### user.get_attacks() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch detailed attack history. Returns up to 100 detailed attack records. Supports attack_filters, pagination via from_/to timestamps, and sort. Requires a Limited-access key. ```APIDOC ## user.get_attacks() ### Description Fetch detailed attack history. Returns up to 100 detailed attack records. Supports `attack_filters`, pagination via `from_`/`to` timestamps, and `sort`. Requires a Limited-access key. ### Method GET ### Endpoint /user/get_attacks ### Parameters #### Query Parameters - **attack_filters** (array) - Optional - Filters for attacks (e.g., "outgoing"). - **limit** (integer) - Optional - Maximum number of records to return (default 100). - **sort** (string) - Optional - Sort order (e.g., "DESC", "ASC"). - **from_** (integer) - Optional - Unix timestamp to start fetching from. - **to** (integer) - Optional - Unix timestamp to stop fetching at. ### Request Example ```python data = torn.user.get_attacks( attack_filters=["outgoing"], limit=50, sort="DESC", from_=1700000000, to=1710000000 ) ``` ### Response #### Success Response (200) - **attacks** (array) - List of attack records. - **attacker_id** (integer) - The ID of the attacker. - **result** (string) - The result of the attack. - **respect_gain** (integer) - Respect gained from the attack. ``` -------------------------------- ### user.get_trades() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch trade history. Returns ongoing or finished trades. Requires a Limited-access key. ```APIDOC ## user.get_trades() ### Description Fetch trade history. Returns ongoing or finished trades. Requires a Limited-access key. ### Method GET ### Endpoint /user/get_trades ### Parameters #### Query Parameters - **trade_category** (string) - Optional - Category of trades to fetch ("ongoing" or "finished", defaults to "ongoing"). - **limit** (integer) - Optional - Maximum number of trades to return (default 100). - **sort** (string) - Optional - Sort order (e.g., "DESC", "ASC"). ### Request Example ```python # Ongoing trades (default) onegong = torn.user.get_trades(trade_category="ongoing") # Finished trades with pagination finished = torn.user.get_trades(trade_category="finished", limit=50, sort="DESC") ``` ### Response #### Success Response (200) - **trades** (array) - List of trade objects. ``` -------------------------------- ### Fetch Auction House Listings Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Retrieves current auction house listings globally or for a specific item. Requires a Public-access key. ```python # All current auctions auctions = torn.market.get_auctionhouse(limit=20) # Auctions for a specific item item_auctions = torn.market.get_auctionhouse(item_id=206) ``` -------------------------------- ### market.get_auctionhouse() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch auction house listings. Returns current auction house listings globally or for a specific item. Requires a Public-access key. ```APIDOC ## market.get_auctionhouse() ### Description Fetch auction house listings. Returns current auction house listings globally or for a specific item. Requires a Public-access key. ### Method GET (Assumed) ### Endpoint /market/get_auctionhouse ### Parameters #### Query Parameters - **limit** (int) - Optional - The number of auction listings to return per page (default 20). - **item_id** (int) - Optional - Filters auctions for a specific item ID. ### Request Example ```python # All current auctions auctions = torn.market.get_auctionhouse(limit=20) # Auctions for a specific item item_auctions = torn.market.get_auctionhouse(item_id=206) ``` ### Response #### Success Response (200) - **auctionhouse** (list) - A list of current auction house listings. ``` -------------------------------- ### faction.get_attacks() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch faction attack history. Returns up to 100 detailed faction attack records. Requires faction API permissions and a Limited-access key. ```APIDOC ## faction.get_attacks() ### Description Fetch faction attack history. Returns up to 100 detailed faction attack records. Requires faction API permissions and a Limited-access key. ### Method GET (Assumed, based on typical API patterns for fetching data) ### Endpoint /faction/get_attacks ### Parameters #### Query Parameters - **attack_filters** (list) - Optional - Filters for attack types (e.g., "outgoing"). - **limit** (int) - Optional - The maximum number of records to return (default 100). - **sort** (string) - Optional - The order to sort the results (e.g., "DESC"). - **from_** (int) - Optional - A Unix timestamp to fetch records from. ### Request Example ```python attacks = torn.faction.get_attacks( attack_filters=["outgoing"], limit=100, sort="DESC", from_=1700000000 ) ``` ### Response #### Success Response (200) - **itemmarket** (list) - A list of attack records. - Each record contains details about the attack. ``` -------------------------------- ### racing.get_cars() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Returns stats for all racing cars. Requires a Public-access key. ```APIDOC ## racing.get_cars() ### Description Returns statistics for all racing cars. ### Access Requires a Public-access key. ### Usage ```python cars = torn.racing.get_cars() for car in cars["cars"]: print(car["name"], car["top_speed"], car["acceleration"]) ``` ``` -------------------------------- ### Fetch Car Stats Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Retrieves statistics for all racing cars. Requires a Public-access API key. ```python cars = torn.racing.get_cars() for car in cars["cars"]: print(car["name"], car["top_speed"], car["acceleration"]) ``` -------------------------------- ### user.get_personalstats() Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Fetch personal statistics. Highly flexible endpoint supporting category filtering and up to 10 historical stat lookups. Requires a Public-access key. ```APIDOC ## user.get_personalstats() ### Description Fetch personal statistics. Highly flexible endpoint supporting category filtering and up to 10 historical stat lookups. Requires a Public-access key. ### Method GET ### Endpoint /user/get_personalstats ### Parameters #### Query Parameters - **user_id** (integer) - Optional - The ID of the user to fetch stats for (defaults to the authenticated user). - **stat_category** (string) - Optional - Category of stats to fetch (e.g., "popular"). - **stat_keys** (array) - Optional - Specific stat keys to fetch (e.g., ["attackswon", "defendswon"]). - **timestamp** (integer) - Optional - Unix timestamp for historical stat lookup. ### Request Example ```python # Get popular stats category data = torn.user.get_personalstats(stat_category="popular") # Get specific stats for another user data = torn.user.get_personalstats(user_id=2561334, stat_keys=["attackswon", "defendswon"]) # Historical stats at a point in time data = torn.user.get_personalstats(stat_keys=["networth", "totalstats"], timestamp=1700000000) ``` ### Response #### Success Response (200) - **stats** (object) - An object containing the requested personal statistics. ``` -------------------------------- ### Fetch bounties on a user Source: https://context7.com/cxdzc/tornapiwrapper/llms.txt Returns active bounties placed on the authenticated user or a specific player. Requires a Public-access key. ```python bounties = torn.user.get_bounties(user_id=2561334) for bounty in bounties["bounties"]: print(bounty["reward"], bounty["reason"]) ```