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 API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.
- API version: 2.3.0
- Package version: 1.0.0
- Generator version: 7.16.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen
Install the following dependencies:
go get github.com/stretchr/testify/assert
go get golang.org/x/net/contextPut the package under your project folder and add the following in import:
import stc "github.com/UnseenBook/spacetraders-go-sdk"To use a proxy, set the environment variable HTTP_PROXY:
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.
For using other server than the one defined on index 0 set context value stc.ContextServerIndex of type int.
ctx := context.WithValue(context.Background(), stc.ContextServerIndex, 1)Templated server URL is formatted using default variables from configuration or from context value stc.ContextServerVariables of type map[string]string.
ctx := context.WithValue(context.Background(), stc.ContextServerVariables, map[string]string{
"basePath": "v2",
})Note, enum values are always validated and all unused variables are silently ignored.
Each operation can use different server URL defined using OperationServers map in the Configuration.
An operation is uniquely identified by "{classname}Service.{nickname}" string.
Similar rules for overriding default operation server index and variables applies by using stc.ContextOperationServerIndices and stc.ContextOperationServerVariables context maps.
ctx := context.WithValue(context.Background(), stc.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), stc.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})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 |
| DataAPI | GetSupplyChain | Get /market/supply-chain | Get Supply Chain |
| 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 | GetShipModules | Get /my/ships/{shipSymbol}/modules | Get Ship Modules |
| FleetAPI | GetShipNav | Get /my/ships/{shipSymbol}/nav | Get Ship Nav |
| FleetAPI | InstallMount | Post /my/ships/{shipSymbol}/mounts/install | Install Mount |
| FleetAPI | InstallShipModule | Post /my/ships/{shipSymbol}/modules/install | Install Ship Module |
| 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 | RemoveShipModule | Post /my/ships/{shipSymbol}/modules/remove | Remove Ship Module |
| 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 |
| GlobalAPI | GetStatus | Get / | Get Status |
| GlobalAPI | Register | Post /register | Register New Agent |
| 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 |
- AcceptContract200Response
- AcceptContract200ResponseData
- ActivityLevel
- Agent
- Chart
- Construction
- ConstructionMaterial
- Contract
- ContractDeliverGood
- ContractPayment
- ContractTerms
- Cooldown
- CreateChart201Response
- CreateChart201ResponseData
- CreateShipShipScan201Response
- CreateShipShipScan201ResponseData
- CreateShipSystemScan201Response
- CreateShipSystemScan201ResponseData
- CreateShipWaypointScan201Response
- CreateShipWaypointScan201ResponseData
- CreateSurvey201Response
- CreateSurvey201ResponseData
- DeliverContract200Response
- DeliverContract200ResponseData
- DeliverContractRequest
- DockShip200Response
- ExtractResources201Response
- ExtractResources201ResponseData
- ExtractResourcesRequest
- ExtractResourcesWithSurvey201Response
- ExtractResourcesWithSurvey201ResponseData
- Extraction
- ExtractionYield
- Faction
- FactionSymbol
- FactionTrait
- FactionTraitSymbol
- FulfillContract200Response
- GetAgents200Response
- GetConstruction200Response
- GetContract200Response
- GetContracts200Response
- GetFaction200Response
- GetFactions200Response
- GetJumpGate200Response
- GetMarket200Response
- GetMounts200Response
- GetMyAgent200Response
- GetMyShip200Response
- GetMyShipCargo200Response
- GetMyShips200Response
- GetRepairShip200Response
- GetRepairShip200ResponseData
- GetScrapShip200Response
- GetScrapShip200ResponseData
- GetShipCooldown200Response
- GetShipModules200Response
- GetShipNav200Response
- GetShipyard200Response
- GetStatus200Response
- GetStatus200ResponseAnnouncementsInner
- GetStatus200ResponseLeaderboards
- GetStatus200ResponseLeaderboardsMostCreditsInner
- GetStatus200ResponseLeaderboardsMostSubmittedChartsInner
- GetStatus200ResponseLinksInner
- GetStatus200ResponseServerResets
- GetStatus200ResponseStats
- GetSupplyChain200Response
- GetSupplyChain200ResponseData
- GetSystem200Response
- GetSystemWaypoints200Response
- GetSystemWaypointsTraitsParameter
- GetSystems200Response
- GetWaypoint200Response
- InstallMount201Response
- InstallMount201ResponseData
- InstallMountRequest
- InstallShipModule201Response
- InstallShipModule201ResponseData
- InstallShipModule201ResponseDataTransaction
- InstallShipModuleRequest
- Jettison200Response
- Jettison200ResponseData
- JettisonRequest
- JumpGate
- JumpShip200Response
- JumpShip200ResponseData
- JumpShipRequest
- Market
- MarketTradeGood
- MarketTransaction
- Meta
- NavigateShip200Response
- NavigateShip200ResponseData
- NavigateShipRequest
- NegotiateContract200Response
- NegotiateContract200ResponseData
- OrbitShip200Response
- OrbitShip200ResponseData
- PatchShipNav200Response
- PatchShipNav200ResponseData
- PatchShipNavRequest
- PurchaseCargo201Response
- PurchaseCargoRequest
- PurchaseShip201Response
- PurchaseShip201ResponseData
- PurchaseShipRequest
- RefuelShip200Response
- RefuelShip200ResponseData
- RefuelShipRequest
- Register201Response
- Register201ResponseData
- RegisterRequest
- RemoveModule201Response
- RemoveMount201Response
- RemoveMount201ResponseData
- RemoveMountRequest
- RemoveShipModuleRequest
- RepairShip200Response
- RepairShip200ResponseData
- RepairTransaction
- ScannedShip
- ScannedShipEngine
- ScannedShipFrame
- ScannedShipMountsInner
- ScannedShipReactor
- ScannedSystem
- ScannedWaypoint
- ScrapShip200Response
- ScrapShip200ResponseData
- ScrapTransaction
- SellCargo201Response
- SellCargo201ResponseData
- SellCargoRequest
- Ship
- ShipCargo
- ShipCargoItem
- ShipConditionEvent
- ShipCrew
- ShipEngine
- ShipFrame
- ShipFuel
- ShipFuelConsumed
- ShipModificationTransaction
- ShipModule
- ShipMount
- ShipNav
- ShipNavFlightMode
- ShipNavRoute
- ShipNavRouteWaypoint
- ShipNavStatus
- ShipReactor
- ShipRefine201Response
- ShipRefine201ResponseData
- ShipRefine201ResponseDataProducedInner
- ShipRefineRequest
- ShipRegistration
- ShipRequirements
- ShipRole
- ShipType
- Shipyard
- ShipyardShip
- ShipyardShipCrew
- ShipyardShipTypesInner
- ShipyardTransaction
- Siphon
- SiphonResources201Response
- SiphonResources201ResponseData
- SiphonYield
- SupplyConstruction201Response
- SupplyConstruction201ResponseData
- SupplyConstructionRequest
- SupplyLevel
- Survey
- SurveyDeposit
- System
- SystemFaction
- SystemType
- SystemWaypoint
- TradeGood
- TradeSymbol
- TransferCargo200Response
- TransferCargoRequest
- WarpShip200Response
- WarpShip200ResponseData
- Waypoint
- WaypointFaction
- WaypointModifier
- WaypointModifierSymbol
- WaypointOrbital
- WaypointTrait
- WaypointTraitSymbol
- WaypointType
Authentication schemes defined for the API:
- Type: HTTP Bearer token authentication
Example
auth := context.WithValue(context.Background(), stc.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)- Type: HTTP Bearer token authentication
Example
auth := context.WithValue(context.Background(), stc.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:
PtrBoolPtrIntPtrInt32PtrInt64PtrFloatPtrFloat32PtrFloat64PtrStringPtrTime