Skip to main content

A Helldivers 2 API wrapper

Project description

helldive.py

A Python client library for the Helldivers 2 API.

Note: Some parts of the API have been reverse-engineered and may not reflect the current state of the game.


Installation

pip install helldivepy

Requires Python 3.11+.


Quick Start

from helldivepy import HelldiveAPIClient
# api.helldivers2.dev requires a contact and a client ID in the X-Super-Contact and X-Super-Client headers for rate-limiting purposes. This is required by the API and can be any contact  (e.g. aj@ajxd2.dev,github/ajxd2,discord/ajxd2, etc).
client = HelldiveAPIClient(
    client="my-app",       # X-Super-Client header
    contact="me@example.com",  # X-Super-Contact header (required by the API)
)

# Get global war status
war = client.war.get()
print(war.now)                          # datetime
print(war.statistics.player_count)     # int

# Get recent dispatches
dispatches = client.dispatches.get_all()
for d in dispatches[:3]:
    print(d.message.to_md())           # converts HDML markup to HTML spans

Modules

Module Status Methods
client.war ✅ Done get() -> War
client.dispatches ✅ Done get_all() -> list[Dispatch], get(index) -> Dispatch | None
client.planets ✅ Done get_all() -> list[Planet], get(index) -> Planet
client.campaigns ✅ Done get_all() -> list[Campaign], get(index) -> Campaign
client.assignments ✅ Done get_all() -> list[Assignment], get(index) -> Assignment
client.space_stations ✅ Done get_all() -> list[SpaceStation], get(index) -> SpaceStation
client.steam ✅ Done get_all() -> list[SteamNews], get(gid) -> SteamNews

Models

All models use automatic camelCase ↔ snake_case aliasing, so API responses deserialize transparently.

Key models

Planet — full planet state including health, owner, biome, hazards, regions, and an optional active Event.

planet = client.planets.get(42)  # coming soon
print(planet.name)
print(planet.current_owner)       # Factions.Terminids
print(planet.health / planet.max_health)
if planet.event:
    print(planet.event.faction, planet.event.end_time)

Assignment (Major Orders) — tasks with parsed progress.

assignments = client.assignments.get_all()  # coming soon
for assignment in assignments:
    print(assignment.title, assignment.expiration)
    for task in assignment.tasks:
        if not task.is_liberation_task:
            print(f"  {task.progress_perc:.1f}% of {task.goal:,}")

Dispatch — in-game broadcasts with HDML (HellDivers Markup Language) markup.

dispatches = client.dispatches.get_all()
latest = dispatches[0]
print(latest.message.to_md())                       # inline styles
print(latest.message.to_md(use_classes=True))       # CSS classes

Development

# Install dependencies
uv sync

# Run tests
uv run pytest

# Lint + format
uv run ruff check .
uv run ruff format .

# Type check
uv run pyright

Thanks

Thanks to the devs of the Community API for keeping a well maintained and easy to use API.


License

MIT

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

helldivepy-1.0.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

helldivepy-1.0.0-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file helldivepy-1.0.0.tar.gz.

File metadata

  • Download URL: helldivepy-1.0.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for helldivepy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f22d0d53274e293f00ad88cfa16ce3091a21c34a5cf096b9cd2a345532202ddb
MD5 c94f40f1402f0c7cdbd5300327aa9c34
BLAKE2b-256 0ef6a742543af4ebc11cb3d155b5421c774af9b3fca20b0f038e74b31de04674

See more details on using hashes here.

Provenance

The following attestation bundles were made for helldivepy-1.0.0.tar.gz:

Publisher: publish.yml on AJXD2/helldive.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file helldivepy-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: helldivepy-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for helldivepy-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2cd1987c7fae6a4b451d6402ba50a2f35473453bf53e0f682e9ddd2591406ef5
MD5 6a1a6fe44695c8e1840ce3e51afdc4e8
BLAKE2b-256 5e19e8effe480eeeea07c18449be57b68a5910dc43ba86cee6e86dcfcdbe9159

See more details on using hashes here.

Provenance

The following attestation bundles were made for helldivepy-1.0.0-py3-none-any.whl:

Publisher: publish.yml on AJXD2/helldive.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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