satisfactory-sdk
0.2.0
dotnet add package satisfactory-sdk --version 0.2.0
NuGet\Install-Package satisfactory-sdk -Version 0.2.0
<PackageReference Include="satisfactory-sdk" Version="0.2.0" />
paket add satisfactory-sdk --version 0.2.0
#r "nuget: satisfactory-sdk, 0.2.0"
// Install satisfactory-sdk as a Cake Addin #addin nuget:?package=satisfactory-sdk&version=0.2.0 // Install satisfactory-sdk as a Cake Tool #tool nuget:?package=satisfactory-sdk&version=0.2.0
SatisfactoryClient
Description
A client utilizing the HTTPS API provided by Satisfactory servers. for documentation on the API, see the wiki docs.
Add to a Project
To use this client, you can run dotnet add package satisfactory-sdk
(see the NuGet homepage for more information).
Getting a Authentication Token
There are a few ways of getting an authentication token. If the server has already been create and setup, you can run the server.GenerateAPIToken
command using the in-game server console to get a token. If the server has not been setup, you can use the ClaimServer
function to claim the server and generate an admin token.
Using the in-game console
- Click on the Server Manager in the main menu.
- Open the server and authenticate if required.
- Open the server console and run the
server.GenerateAPIToken
command. - Copy the given token out of the console.
Basic Example
using SatisfactorySdk;
namespace ExampleApplication
{
public class Program
{
public static async void Main(string[] args)
{
// Instantiate a new client.
// NOTE: This does not perform any commands nor test the connection to the server.
var client = new SatisfactoryClient(
"127.0.0.1",
7777,
authToken: "API_KEY"
);
// Perform a health check function on the server.
// NOTE: This can throw an exception if a non-standard error occurs (e.g. Timeout, SSL, etc.)
var healthCheckResponse = await client.HealthCheckAsync();
// Print out the status code returned from the server.
Console.WriteLine(healthCheckResponse.StatusCode);
// You can check if a standard error was returned by the server (status code will still be 200).
if (healthCheckResponse.HasError)
{
// ClientResponse.ErrorResponse will contain all the information about the error.
Console.WriteLine(healthCheckResponse.ErrorResponse.ErrorCode);
}
// Print out the health returned from the server.
Console.WriteLine(healthCheckResponse.RequestResponse.Health);
}
}
}
Advanced Examples
Setting up a brand new server
var client = new SatisfactoryClient("127.0.0.1", 7777);
// Perform the initial login to get a admin token
var loginResponse = await client.PasswordlessLoginAsync(PrivilegeLevelEnum.InitialAdmin);
// Set the client's auth token to what was received before
client.TrySetAuthToken(loginResponse.RequestResponse.Data.AuthenticationToken);
// Claim the server and set the admin password for the server
var claimServerResponse = await client.ClaimServerAsync("Test Server", "Admin1234!");
// Login to the server using the newly set admin password
loginResponse = await client.PasswordLoginAsync("Admin1234!", PrivilegeLevelEnum.Administrator);
// From this point, you can begin the rest of set up (i.e. settings, saves, sessions, etc.)
Utilizing non-standard configurations
var client = new SatisfactoryClient(
"127.0.0.1",
7788,
updPort: 7788, // Can pass a custom port for the UDP connection
authToken: "API_KEY", // Can pass the API bearer token in from instatiation rather than performing a login
trustSelfSignedCerts: true, // You can either trust or not trust the self-signed certificates
usePort: false, // You an decide to not use the port in the connection string (i.e. https://127.0.0.1/api/v1)
client: new HttpClient(), // You can pass in the HTTP Client to be used by the Satisfactory Client (allows mocked responses for unit testing)
logger: new Logger() // You can pass in your own logger for the Satisfactory Client to use
);
// You can also provide the full connection string of the server API
// NOTE: The UDP endpoint currently does not work with this constructor!
var client = new SatisfactoryClient(
"https://127.0.0.1:7777/api/v1",
authToken: "API_KEY", // Can pass the API bearer token in from instatiation rather than performing a login
trustSelfSignedCerts: true, // You can either trust or not trust the self-signed certificates
client: new HttpClient(), // You can pass in the HTTP Client to be used by the Satisfactory Client (allows mocked responses for unit testing)
logger: new Logger() // You can pass in your own logger for the Satisfactory Client to use
);
Requesting new features or reporting bugs
Please submit an issue in Github and mark either as a bug or enhancement.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
-
net8.0
- Microsoft.Extensions.Logging (>= 8.0.0)
- Microsoft.Extensions.Logging.Console (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Updated bool response to take into account error responses in body.