Skip to content

ishtatann/SpaceTradersUnitySDK

Repository files navigation

SpaceTradersUnitySDK - the C# library for the SpaceTraders API

SpaceTraders is an open-universe game and learning platform that offers a set of HTTP endpoints to control a fleet of ships and explore a multiplayer universe.

The API is documented using OpenAPI. You can send your first request right here in your browser to check the status of the game server.

{
  \"method\": \"GET\",
  \"url\": \"https://api.spacetraders.io/v2\",
}

Unlike a traditional game, SpaceTraders does not have a first-party client or app to play the game. Instead, you can use the API to build your own client, write a script to automate your ships, or try an app built by the community.

We have a Discord channel where you can share your projects, ask questions, and get help from other players.

This C# SDK is automatically generated by the OpenAPI Generator project:

  • API version: 2.0.0
  • SDK version: 1.0.0
  • Build package: org.openapitools.codegen.languages.CSharpNetCoreClientCodegen

Version support

This generator should support all current LTS versions of Unity

  • Unity 2020.3 (LTS) and up
  • .NET Standard 2.1 / .NET Framework

Dependencies

Installation

Add the dependencies to Packages/manifest.json

{
  "dependencies": {
    ...
    "com.unity.nuget.newtonsoft-json": "3.0.2",
    "com.unity.test-framework": "1.1.33",
  }
}

Then use the namespaces:

using SpaceTradersUnitySDK.Api;
using SpaceTradersUnitySDK.Client;
using SpaceTradersUnitySDK.Model;

Getting Started

using System;
using System.Collections.Generic;
using UnityEngine;
using SpaceTradersUnitySDK.Api;
using SpaceTradersUnitySDK.Client;
using SpaceTradersUnitySDK.Model;

namespace SpaceTradersUnitySDKExample
{

    public class GetAgentExample : MonoBehaviour
    {
        async void Start()
        {
            Configuration config = new Configuration();
            config.BasePath = "https://api.spacetraders.io/v2";
            // Configure Bearer token for authorization: AgentToken
            config.AccessToken = "YOUR_BEARER_TOKEN";

            var apiInstance = new AgentsApi(config);
            var agentSymbol = "\"FEBA66\"";  // string | The agent symbol (default to "FEBA66")

            try
            {
                // Get Public Agent
                GetMyAgent200Response result = await apiInstance.GetAgentAsync(agentSymbol);
                Debug.Log(result);
                Debug.Log("Done!");
            }
            catch (ApiException e)
            {
                Debug.LogError("Exception when calling AgentsApi.GetAgent: " + e.Message );
                Debug.LogError("Status Code: "+ e.ErrorCode);
                Debug.LogError(e.StackTrace);
            }

        }
    }
}

Documentation for API Endpoints

All URIs are relative to https://api.spacetraders.io/v2

Class Method HTTP request Description
AgentsApi GetAgent GET /agents/{agentSymbol} Get Public Agent
AgentsApi GetAgents GET /agents List Agents
AgentsApi GetMyAgent GET /my/agent Get Agent
ContractsApi AcceptContract POST /my/contracts/{contractId}/accept Accept Contract
ContractsApi DeliverContract POST /my/contracts/{contractId}/deliver Deliver Cargo to Contract
ContractsApi FulfillContract POST /my/contracts/{contractId}/fulfill Fulfill Contract
ContractsApi GetContract GET /my/contracts/{contractId} Get Contract
ContractsApi GetContracts GET /my/contracts List Contracts
DefaultApi GetStatus GET / Get Status
DefaultApi Register POST /register Register New Agent
FactionsApi GetFaction GET /factions/{factionSymbol} Get Faction
FactionsApi GetFactions GET /factions List Factions
FleetApi CreateChart POST /my/ships/{shipSymbol}/chart Create Chart
FleetApi CreateShipShipScan POST /my/ships/{shipSymbol}/scan/ships Scan Ships
FleetApi CreateShipSystemScan POST /my/ships/{shipSymbol}/scan/systems Scan Systems
FleetApi CreateShipWaypointScan POST /my/ships/{shipSymbol}/scan/waypoints Scan Waypoints
FleetApi CreateSurvey POST /my/ships/{shipSymbol}/survey Create Survey
FleetApi DockShip POST /my/ships/{shipSymbol}/dock Dock Ship
FleetApi ExtractResources POST /my/ships/{shipSymbol}/extract Extract Resources
FleetApi ExtractResourcesWithSurvey POST /my/ships/{shipSymbol}/extract/survey Extract Resources with Survey
FleetApi GetMounts GET /my/ships/{shipSymbol}/mounts Get Mounts
FleetApi GetMyShip GET /my/ships/{shipSymbol} Get Ship
FleetApi GetMyShipCargo GET /my/ships/{shipSymbol}/cargo Get Ship Cargo
FleetApi GetMyShips GET /my/ships List Ships
FleetApi GetRepairShip GET /my/ships/{shipSymbol}/repair Get Repair Ship
FleetApi GetScrapShip GET /my/ships/{shipSymbol}/scrap Get Scrap Ship
FleetApi GetShipCooldown GET /my/ships/{shipSymbol}/cooldown Get Ship Cooldown
FleetApi GetShipNav GET /my/ships/{shipSymbol}/nav Get Ship Nav
FleetApi InstallMount POST /my/ships/{shipSymbol}/mounts/install Install Mount
FleetApi Jettison POST /my/ships/{shipSymbol}/jettison Jettison Cargo
FleetApi JumpShip POST /my/ships/{shipSymbol}/jump Jump Ship
FleetApi NavigateShip POST /my/ships/{shipSymbol}/navigate Navigate Ship
FleetApi NegotiateContract POST /my/ships/{shipSymbol}/negotiate/contract Negotiate Contract
FleetApi OrbitShip POST /my/ships/{shipSymbol}/orbit Orbit Ship
FleetApi PatchShipNav PATCH /my/ships/{shipSymbol}/nav Patch Ship Nav
FleetApi PurchaseCargo POST /my/ships/{shipSymbol}/purchase Purchase Cargo
FleetApi PurchaseShip POST /my/ships Purchase Ship
FleetApi RefuelShip POST /my/ships/{shipSymbol}/refuel Refuel Ship
FleetApi RemoveMount POST /my/ships/{shipSymbol}/mounts/remove Remove Mount
FleetApi RepairShip POST /my/ships/{shipSymbol}/repair Repair Ship
FleetApi ScrapShip POST /my/ships/{shipSymbol}/scrap Scrap Ship
FleetApi SellCargo POST /my/ships/{shipSymbol}/sell Sell Cargo
FleetApi ShipRefine POST /my/ships/{shipSymbol}/refine Ship Refine
FleetApi SiphonResources POST /my/ships/{shipSymbol}/siphon Siphon Resources
FleetApi TransferCargo POST /my/ships/{shipSymbol}/transfer Transfer Cargo
FleetApi WarpShip POST /my/ships/{shipSymbol}/warp Warp Ship
SystemsApi GetConstruction GET /systems/{systemSymbol}/waypoints/{waypointSymbol}/construction Get Construction Site
SystemsApi GetJumpGate GET /systems/{systemSymbol}/waypoints/{waypointSymbol}/jump-gate Get Jump Gate
SystemsApi GetMarket GET /systems/{systemSymbol}/waypoints/{waypointSymbol}/market Get Market
SystemsApi GetShipyard GET /systems/{systemSymbol}/waypoints/{waypointSymbol}/shipyard Get Shipyard
SystemsApi GetSystem GET /systems/{systemSymbol} Get System
SystemsApi GetSystemWaypoints GET /systems/{systemSymbol}/waypoints List Waypoints in System
SystemsApi GetSystems GET /systems List Systems
SystemsApi GetWaypoint GET /systems/{systemSymbol}/waypoints/{waypointSymbol} Get Waypoint
SystemsApi SupplyConstruction POST /systems/{systemSymbol}/waypoints/{waypointSymbol}/construction/supply Supply Construction Site

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

AgentToken

  • Type: Bearer Authentication

About

A Unity compatible version of the Space Traders V2 API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages