Helldivers2API 1.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package Helldivers2API --version 1.0.4
                    
NuGet\Install-Package Helldivers2API -Version 1.0.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Helldivers2API" Version="1.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Helldivers2API" Version="1.0.4" />
                    
Directory.Packages.props
<PackageReference Include="Helldivers2API" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Helldivers2API --version 1.0.4
                    
#r "nuget: Helldivers2API, 1.0.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Helldivers2API@1.0.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Helldivers2API&version=1.0.4
                    
Install as a Cake Addin
#tool nuget:?package=Helldivers2API&version=1.0.4
                    
Install as a Cake Tool

Another open source library for the undocumented Helldivers2 API

Features

  • .NET 7
  • Easy to use
  • Built-in cache system
  • Consolidates various planet data under a single source
  • Helps spread managed democracy

Planets, Planets, Planets

The majority of data from the Helldivers2 API is associated to one or more planets. Because of this, we have made most data retrievable directly from the IPlanet object. There's no need to jump through multiple requests and pair the data together, this project has done this internally.

Overview

All information is retrievable through the convenient Joel class.

  • Get current assignments, e.g. the Major Order
  • Get news from the galaxy
  • Get status of the on-going war efforts
  • Get information of the on-going war
  • Get all the known planets in the galaxy, including their
    • Sector
    • Biome
    • Envrionmental conditions (fire storms, etc)
    • Supply lines to other planets
    • Player count
    • Health / MaxHealth
    • Planets attacking it
    • Planets it is attacking
    • Original owning faction
    • Current owning faction
    • Factions that claim it as a home world
    • Regen rates
    • Active campaigns
    • Associated planet events
    • Associated global events
    • Associated joint operations
    • etc

Installation

Install the NuGet package via...

the package manager NuGet\Install-Package Helldivers2API

or .NET CLI dotnet add package Helldivers2API

Getting Started

Get the client by setting the current war id, via Joel

// The current war id is 801
var hdClient = Helldivers2API.Joel.Instance.SetWarId(801);

The war id parameter is required to send requests to the web endpoints, but it does not appear to be advertised anywhere.

The war id will likely change when the game transitions to the next season.

Get all the known planets

var planets = hdClient.GetPlanets();
foreach (var planet in planets)
    Debug.Print($"Planet {planet.Name} resides in the {planet.SectorName} sector");

Get all the assignments

var assignments = hdClient.GetAssignments();
foreach (var assignment in assignments)
    Debug.Print($"Assignment: {assignment.Brief}");

Get all the news

var newsfeeds = hdClient.GetNewsFeed();
foreach (var newsfeed in newsfeeds)
    Debug.Print($"{newsfeed.Message}");

The information from the WarStatus and WarInfo that relates to a Planet is retrievable from the Planet object directly. These properties have been marked with internal to hide their visibility and prevent accidental use.

Get the status of the on-going war efforts

var warstatus = hdClient.GetWarStatus();  

Get information about the war

var warinfo = hdClient.GetWarInfo();     

Cache System

The built-in cache system was designed to avoid sending unnecessary requests to the web api endpoints. It's entirely internal and you do not need to manage it. Just request the data and it will handle the rest.

The default cache expiration is about 5 minutes, although this may change in the future. If you modify this value, please be considerate to the game servers.

The web api is never hit until the first request for data is made, at which point only the necessary endpoints are requested.

static void HDClient()
{
    // The current war id is 801
    var hdClient = Helldivers2API.Joel.Instance.SetWarId(801);

    var planets = hdClient.GetPlanets();
    foreach (var planet in planets)
        Debug.Print($"Planet {planet.Name} resides in the {planet.SectorName} sector");

    var assignments = hdClient.GetAssignments();
    foreach (var assignment in assignments)
        Debug.Print($"Assignment: {assignment.Brief}");

    // this call will return data from the local cache since it was just requested (web api endpoint is not hit again)
    var assignments2 = hdClient.GetAssignments();

    var newsfeeds = hdClient.GetNewsFeed();
    foreach (var newsfeed in newsfeeds)
        Debug.Print($"{newsfeed.Message}");

    // omitted for cache example
    //var warstatus  = hdClient.GetWarStatus();

    // omitted for cache example
    //var warinfo = hdClient.GetWarInfo();

    var lastRef = hdClient.GetLastRefreshed();
    foreach (var lastRefreshed in lastRef)
        Debug.Print($"{lastRefreshed.Key} was last refreshed {lastRefreshed.Value}");
}

// Assignments was last refreshed 3/24/2024 12:25:25 PM
// WarInfo was last refreshed    <-- date is null because it was never called, thus a request was never sent to the web api endpoint
// WarStatus was last refreshed  <-- date is null because it was never called, thus a request was never sent to the web api endpoint
// NewsFeed was last refreshed 3/24/2024 12:25:25 PM

Documentation

See technical documentation at, https://travis-stanley.github.io/Helldivers2API-NET/api/Helldivers2API.html

Community

Thanks to all the various communities and sources out there that have documented and shared information about the Helldivers2 API.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.4 207 4/19/2024
1.1.3 173 4/7/2024
1.1.1 182 4/6/2024
1.1.0 149 3/29/2024
1.0.5 158 3/28/2024
1.0.4 138 3/28/2024
1.0.3 169 3/28/2024
1.0.2 163 3/28/2024
1.0.1 165 3/27/2024
1.0.0 175 3/27/2024