-
Notifications
You must be signed in to change notification settings - Fork 2
FAQ
This page contains answers to common questions and issues developers encounter when building scripts with the warera-client.
No, but it is highly recommended. If you don't provide an API key, the library works perfectly fine anonymously. However, WarEra enforces much stricter rate limits on anonymous IP addresses (e.g., 100 requests instead of 500). For anything beyond basic testing, generate an API key in your game settings and pass it to the client.
These are internal properties returned by the game's backend database (MongoDB / Mongoose).
-
_idis the primary key for a document. The library automatically aliases this to.idin Python for convenience! -
__vis the document version key used internally by the backend to track revisions. You can safely ignore it.
WarEra's backend is highly dynamic. If a user hasn't unlocked a specific feature, or if a country hasn't formed an alliance, the API will often omit that data entirely.
To prevent parsing crashes, the Python client makes these fields Optional (which defaults to None). Always check if a field exists before attempting to access nested properties on it!
# GOOD:
if user.party:
print(user.party.name)
# BAD: (Will crash if the user is independent)
print(user.party.name)Yes! While the library is built around asyncio, we provide a robust synchronous wrapper specifically for this use case.
Just import WareraClient from the sync submodule instead of the root module:
from warera.sync import WareraClient
client = WareraClient(api_key="your_key")The sync wrapper spawns a daemon thread with an isolated event loop, ensuring it plays nicely with Django/Flask's threading models without sacrificing the auto-batching engine's performance.
You usually don't have to! The library automatically intercepts 429 Too Many Requests responses, parses the ratelimit-reset header, silently sleeps your async task for the exact required duration, and transparently retries the request for you.
You only need to manually handle WareraRateLimitError if the library exhausts its automatic retries (which defaults to 3 attempts).
Many endpoints return a "Lite" version of a model to save bandwidth.
-
UserLitecontains basic info (name, avatar, level, citizenship). It is returned by paginated endpoints likeget_by_country()or search endpoints. -
Usercontains the complete profile (stats, inventory, achievements, etc.). It is only returned when fetching a specific user by ID.
Make sure you have pydantic >= 2.0.0 installed. This library relies heavily on Pydantic V2's Rust core for high-speed JSON parsing. It is not compatible with Pydantic V1.
Do not manually loop over pages. Instead, use the built-in collect_all() method available on supported resources.
collect_all() uses time-sliced synthetic cursors to divide the timeline into chunks and fires hundreds of requests concurrently, fetching massive datasets in seconds. See the Advanced Usage page for a guide!
- action_log
- alliance
- article
- battle
- battle_loot_summary
- battle_order
- battle_ranking
- company
- country
- donation
- election
- event
- game_config
- game_stat
- government
- inventory
- item_trading
- mercenary_contract_auction
- mu
- mu_member
- party
- ranking
- region
- round
- search
- tournament
- transaction
- upgrade
- user
- work
- work_offer
- worker