This package is EXPERIMENTAL, NOT stable and NOT intended for use in anything other than your own private projects.
pywarera is a simple Python wrapper for the WarEra API.
It provides high-level classes for working with game models and a low-level wareraapi module for making raw API requests.
API documentation is available at https://api2.warera.io/docs/.
License: GNU General Public License v3.0
Features
- high-level classes to work with API models
- ability to manually send API requests
- caching (x5 - x20 less requests!)
- batching
- delays
- exceptions
Supported models
-
🟢 the wrapper can reliably reproduce this model from the get request
-
🟡 the wrapper can reproduce most properties, but reliability has not been tested
-
🔴 the wrapper is not yet able to work with this model, so you will have to process the response from the API yourself
-
🟡company
-
🟡country
-
🔴event
-
🟡government
-
🟡region
-
🔴battle
-
🔴round
-
🔴battleRanking
-
🔴itemTrading
-
🔴tradingOrder
-
🔴workOffer
-
🔴ranking
-
🔴search
-
🔴gameConfig
-
🟡user
-
🔴article
-
🟡mu
-
🔴transaction
-
🔴upgrade
-
🟡workers
-
🟡party
How to install
Requires Python 3.10+
pip install pywarera
Examples
import pywarera
s = pywarera.WarEraSession(api_token="xxx")
# Returns country id
country_id = s.get_country_id_by_name("Ukraine")
print(country_id)
# I want to know if Ukraine has a president
government = s.get_government(country_id)
is_there_a_president = government.has_president()
if is_there_a_president:
president_id = government.president
print(president_id)
# Let's check the wealth of a random citizen
import random
romania_citizens = s.get_country_citizens_by_name("Romania")
random_citizen = random.choice(romania_citizens)
print(random_citizen.wealth)
Example of a manual API request
from pywarera import wareraapi
api_s = wareraapi.WarEraApiSession(api_token="xxx")
# Regular request, will be cached
user_response = wareraapi.user_get_user_lite(user_id="123456").execute(api_s)
# Batched request, will be cached
from pywarera.wareraapi import BatchSession
with BatchSession(api_s) as batch:
batch.add(wareraapi.user_get_user_lite(user_id="123456"))
batch.add(wareraapi.user_get_user_lite(user_id="7891011"))
print(batch.responses)
Functions
General
- clear_cache()
- update_api_token(new_api_token)
Region
- get_region(region_id) -> returns instance of Region class
Items
- get_items() -> access to resources and products
- get_item(item_code)
- get_trading_prices()
- get_item_price(item_code)
User
- get_user(user_id) -> returns instance of User class
- get_users(user_ids) -> returns list with instances of User class
- get_user_wage(user_id)
Government
- get_government(country_id) -> returns instance of Government clas
Country
- get_country(country_id) -> returns instance of Country class
- get_all_countries(return_list: bool) -> returns dict with instances of Country object, where key is country's ID
- get_country_id_by_name(country_name)
- get_country_citizens_ids(country_id)
- get_country_citizens(country_id) -> returns list with instances of User class
- get_country_citizens_ids_by_name(country_name)
- get_country_citizens_by_name(country_name) -> returns list with instances of User class
Company
- get_user_company_ids(user_id)
- get_users_company_ids(user_ids: list[str])
- get_country_citizens_company_ids(country_id)
- get_company(company_id) -> returns instance of Company class
- get_companies(company_ids: list[str]) -> returns list with instances of Company class
- get_country_citizens_companies(country_id) -> returns list with instances of Company class
MUs
- get_military_unit(mu_id) -> returns instance of MilitaryUnit class
- get_military_units_from_paginated(items: list) -> to work with mu.getManyPaginated request
Parties
- get_party(party_id)
- get_parties(party_ids)
Metadata
Release files for pywarera 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pywarera-0.3.0.tar.gz | 32.5 kB | Without provenance | Details for pywarera-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pywarera-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for pywarera-0.3.0-py3-none-any.whl |
Total release size: 69.3 kB
Release files / pywarera-0.3.0.tar.gz
| Download URL | pywarera-0.3.0.tar.gz |
|---|---|
| Size | 32.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7ee3abc4a0c4db85f599c68075c13405a24017774291e818b2c2817cf27b42e2
|
|
BLAKE2b-256 checksum How to use checksums |
c16da03237f6a5f8a4d8e08aa9bfb07416dcda16226307e8f77a4646e4d8420b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.1
|
Release files / pywarera-0.3.0-py3-none-any.whl
| Download URL | pywarera-0.3.0-py3-none-any.whl |
|---|---|
| Size | 36.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
786f17d4456973192d789ecc132ec1635a3e13857ca40c04a2303cf72d5651d6
|
|
BLAKE2b-256 checksum How to use checksums |
d0b3b282c9bb9f14bb806c4437ade0ce6b211480c488c9f0f0577d5312bcf93f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.1
|
Security for pywarera 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.