dl-spacetraders-sk
v2.0.0
Published
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](https://github.com/SpaceTradersAPI/api-docs). You can se
Downloads
6
Readme
space_traders_api
SpaceTradersApi - JavaScript client for space_traders_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 SDK is automatically generated by the OpenAPI Generator project:
- API version: 2.0.0
- Package version: 2.0.0
- Build package: org.openapitools.codegen.languages.JavascriptClientCodegen
Installation
For Node.js
npm
To publish the library as a npm, please follow the procedure in "Publishing npm packages".
Then install it via:
npm install space_traders_api --save
Finally, you need to build the module:
npm run build
Local development
To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing package.json
(and this README). Let's call this JAVASCRIPT_CLIENT_DIR
. Then run:
npm install
Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR
:
npm link
To use the link you just defined in your project, switch to the directory you want to use your space_traders_api from, and run:
npm link /path/to/<JAVASCRIPT_CLIENT_DIR>
Finally, you need to build the module:
npm run build
git
If the library is hosted at a git repository, e.g.https://github.com/GIT_USER_ID/GIT_REPO_ID then install it via:
npm install GIT_USER_ID/GIT_REPO_ID --save
For browser
The library also works in the browser environment via npm and browserify. After following
the above steps with Node.js and installing browserify with npm install -g browserify
,
perform the following (assuming main.js is your entry file):
browserify main.js > bundle.js
Then include bundle.js in the HTML pages.
Webpack Configuration
Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:
module: {
rules: [
{
parser: {
amd: false
}
}
]
}
Getting Started
Please follow the installation instruction and execute the following JS code:
var SpaceTradersApi = require('space_traders_api');
var defaultClient = SpaceTradersApi.ApiClient.instance;
// Configure Bearer access token for authorization: AgentToken
var AgentToken = defaultClient.authentications['AgentToken'];
AgentToken.accessToken = "YOUR ACCESS TOKEN"
var api = new SpaceTradersApi.AgentsApi()
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
api.getMyAgent(callback);
Documentation for API Endpoints
All URIs are relative to https://api.spacetraders.io/v2
Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- SpaceTradersApi.AgentsApi | getMyAgent | GET /my/agent | My Agent Details SpaceTradersApi.ContractsApi | acceptContract | POST /my/contracts/{contractId}/accept | Accept Contract SpaceTradersApi.ContractsApi | deliverContract | POST /my/contracts/{contractId}/deliver | Deliver Contract SpaceTradersApi.ContractsApi | fulfillContract | POST /my/contracts/{contractId}/fulfill | Fulfill Contract SpaceTradersApi.ContractsApi | getContract | GET /my/contracts/{contractId} | Get Contract SpaceTradersApi.ContractsApi | getContracts | GET /my/contracts | List Contracts SpaceTradersApi.DefaultApi | register | POST /register | Register New Agent SpaceTradersApi.FactionsApi | getFaction | GET /factions/{factionSymbol} | Get Faction SpaceTradersApi.FactionsApi | getFactions | GET /factions | List Factions SpaceTradersApi.FleetApi | createChart | POST /my/ships/{shipSymbol}/chart | Create Chart SpaceTradersApi.FleetApi | createShipShipScan | POST /my/ships/{shipSymbol}/scan/ships | Scan Ships SpaceTradersApi.FleetApi | createShipSystemScan | POST /my/ships/{shipSymbol}/scan/systems | Scan Systems SpaceTradersApi.FleetApi | createShipWaypointScan | POST /my/ships/{shipSymbol}/scan/waypoints | Scan Waypoints SpaceTradersApi.FleetApi | createSurvey | POST /my/ships/{shipSymbol}/survey | Create Survey SpaceTradersApi.FleetApi | dockShip | POST /my/ships/{shipSymbol}/dock | Dock Ship SpaceTradersApi.FleetApi | extractResources | POST /my/ships/{shipSymbol}/extract | Extract Resources SpaceTradersApi.FleetApi | getMyShip | GET /my/ships/{shipSymbol} | Get Ship SpaceTradersApi.FleetApi | getMyShipCargo | GET /my/ships/{shipSymbol}/cargo | Get Ship Cargo SpaceTradersApi.FleetApi | getMyShips | GET /my/ships | List Ships SpaceTradersApi.FleetApi | getShipCooldown | GET /my/ships/{shipSymbol}/cooldown | Get Ship Cooldown SpaceTradersApi.FleetApi | getShipNav | GET /my/ships/{shipSymbol}/nav | Get Ship Nav SpaceTradersApi.FleetApi | jettison | POST /my/ships/{shipSymbol}/jettison | Jettison Cargo SpaceTradersApi.FleetApi | jumpShip | POST /my/ships/{shipSymbol}/jump | Jump Ship SpaceTradersApi.FleetApi | navigateShip | POST /my/ships/{shipSymbol}/navigate | Navigate Ship SpaceTradersApi.FleetApi | orbitShip | POST /my/ships/{shipSymbol}/orbit | Orbit Ship SpaceTradersApi.FleetApi | patchShipNav | PATCH /my/ships/{shipSymbol}/nav | Patch Ship Nav SpaceTradersApi.FleetApi | purchaseCargo | POST /my/ships/{shipSymbol}/purchase | Purchase Cargo SpaceTradersApi.FleetApi | purchaseShip | POST /my/ships | Purchase Ship SpaceTradersApi.FleetApi | refuelShip | POST /my/ships/{shipSymbol}/refuel | Refuel Ship SpaceTradersApi.FleetApi | sellCargo | POST /my/ships/{shipSymbol}/sell | Sell Cargo SpaceTradersApi.FleetApi | shipRefine | POST /my/ships/{shipSymbol}/refine | Ship Refine SpaceTradersApi.FleetApi | transferCargo | POST /my/ships/{shipSymbol}/transfer | Transfer Cargo SpaceTradersApi.FleetApi | warpShip | POST /my/ships/{shipSymbol}/warp | Warp Ship SpaceTradersApi.SystemsApi | getJumpGate | GET /systems/{systemSymbol}/waypoints/{waypointSymbol}/jump-gate | Get Jump Gate SpaceTradersApi.SystemsApi | getMarket | GET /systems/{systemSymbol}/waypoints/{waypointSymbol}/market | Get Market SpaceTradersApi.SystemsApi | getShipyard | GET /systems/{systemSymbol}/waypoints/{waypointSymbol}/shipyard | Get Shipyard SpaceTradersApi.SystemsApi | getSystem | GET /systems/{systemSymbol} | Get System SpaceTradersApi.SystemsApi | getSystemWaypoints | GET /systems/{systemSymbol}/waypoints | List Waypoints SpaceTradersApi.SystemsApi | getSystems | GET /systems | List Systems SpaceTradersApi.SystemsApi | getWaypoint | GET /systems/{systemSymbol}/waypoints/{waypointSymbol} | Get Waypoint
Documentation for Models
- SpaceTradersApi.AcceptContract200Response
- SpaceTradersApi.AcceptContract200ResponseData
- SpaceTradersApi.Agent
- SpaceTradersApi.Chart
- SpaceTradersApi.ConnectedSystem
- SpaceTradersApi.Contract
- SpaceTradersApi.ContractDeliverGood
- SpaceTradersApi.ContractPayment
- SpaceTradersApi.ContractTerms
- SpaceTradersApi.Cooldown
- SpaceTradersApi.CreateChart201Response
- SpaceTradersApi.CreateChart201ResponseData
- SpaceTradersApi.CreateShipShipScan201Response
- SpaceTradersApi.CreateShipShipScan201ResponseData
- SpaceTradersApi.CreateShipSystemScan201Response
- SpaceTradersApi.CreateShipSystemScan201ResponseData
- SpaceTradersApi.CreateShipWaypointScan201Response
- SpaceTradersApi.CreateShipWaypointScan201ResponseData
- SpaceTradersApi.CreateSurvey201Response
- SpaceTradersApi.CreateSurvey201ResponseData
- SpaceTradersApi.DeliverContract200Response
- SpaceTradersApi.DeliverContract200ResponseData
- SpaceTradersApi.DeliverContractRequest
- SpaceTradersApi.DockShip200Response
- SpaceTradersApi.ExtractResources201Response
- SpaceTradersApi.ExtractResources201ResponseData
- SpaceTradersApi.ExtractResourcesRequest
- SpaceTradersApi.Extraction
- SpaceTradersApi.ExtractionYield
- SpaceTradersApi.Faction
- SpaceTradersApi.FactionTrait
- SpaceTradersApi.FulfillContract200Response
- SpaceTradersApi.GetContract200Response
- SpaceTradersApi.GetContracts200Response
- SpaceTradersApi.GetFaction200Response
- SpaceTradersApi.GetFactions200Response
- SpaceTradersApi.GetJumpGate200Response
- SpaceTradersApi.GetMarket200Response
- SpaceTradersApi.GetMyAgent200Response
- SpaceTradersApi.GetMyShip200Response
- SpaceTradersApi.GetMyShipCargo200Response
- SpaceTradersApi.GetMyShips200Response
- SpaceTradersApi.GetShipCooldown200Response
- SpaceTradersApi.GetShipNav200Response
- SpaceTradersApi.GetShipyard200Response
- SpaceTradersApi.GetSystem200Response
- SpaceTradersApi.GetSystemWaypoints200Response
- SpaceTradersApi.GetSystems200Response
- SpaceTradersApi.GetWaypoint200Response
- SpaceTradersApi.Jettison200Response
- SpaceTradersApi.Jettison200ResponseData
- SpaceTradersApi.JettisonRequest
- SpaceTradersApi.JumpGate
- SpaceTradersApi.JumpShip200Response
- SpaceTradersApi.JumpShip200ResponseData
- SpaceTradersApi.JumpShipRequest
- SpaceTradersApi.Market
- SpaceTradersApi.MarketTradeGood
- SpaceTradersApi.MarketTransaction
- SpaceTradersApi.Meta
- SpaceTradersApi.NavigateShip200Response
- SpaceTradersApi.NavigateShip200ResponseData
- SpaceTradersApi.NavigateShipRequest
- SpaceTradersApi.OrbitShip200Response
- SpaceTradersApi.OrbitShip200ResponseData
- SpaceTradersApi.PatchShipNavRequest
- SpaceTradersApi.PurchaseCargo201Response
- SpaceTradersApi.PurchaseCargoRequest
- SpaceTradersApi.PurchaseShip201Response
- SpaceTradersApi.PurchaseShip201ResponseData
- SpaceTradersApi.PurchaseShipRequest
- SpaceTradersApi.RefuelShip200Response
- SpaceTradersApi.RefuelShip200ResponseData
- SpaceTradersApi.Register201Response
- SpaceTradersApi.Register201ResponseData
- SpaceTradersApi.RegisterRequest
- SpaceTradersApi.ScannedShip
- SpaceTradersApi.ScannedShipEngine
- SpaceTradersApi.ScannedShipFrame
- SpaceTradersApi.ScannedShipMountsInner
- SpaceTradersApi.ScannedShipReactor
- SpaceTradersApi.ScannedSystem
- SpaceTradersApi.ScannedWaypoint
- SpaceTradersApi.SellCargo201Response
- SpaceTradersApi.SellCargo201ResponseData
- SpaceTradersApi.SellCargoRequest
- SpaceTradersApi.Ship
- SpaceTradersApi.ShipCargo
- SpaceTradersApi.ShipCargoItem
- SpaceTradersApi.ShipCrew
- SpaceTradersApi.ShipEngine
- SpaceTradersApi.ShipFrame
- SpaceTradersApi.ShipFuel
- SpaceTradersApi.ShipFuelConsumed
- SpaceTradersApi.ShipModule
- SpaceTradersApi.ShipMount
- SpaceTradersApi.ShipNav
- SpaceTradersApi.ShipNavFlightMode
- SpaceTradersApi.ShipNavRoute
- SpaceTradersApi.ShipNavRouteWaypoint
- SpaceTradersApi.ShipNavStatus
- SpaceTradersApi.ShipReactor
- SpaceTradersApi.ShipRefine200Response
- SpaceTradersApi.ShipRefine200ResponseData
- SpaceTradersApi.ShipRefine200ResponseDataProducedInner
- SpaceTradersApi.ShipRefineRequest
- SpaceTradersApi.ShipRegistration
- SpaceTradersApi.ShipRequirements
- SpaceTradersApi.ShipRole
- SpaceTradersApi.ShipType
- SpaceTradersApi.Shipyard
- SpaceTradersApi.ShipyardShip
- SpaceTradersApi.ShipyardShipTypesInner
- SpaceTradersApi.ShipyardTransaction
- SpaceTradersApi.Survey
- SpaceTradersApi.SurveyDeposit
- SpaceTradersApi.System
- SpaceTradersApi.SystemFaction
- SpaceTradersApi.SystemType
- SpaceTradersApi.SystemWaypoint
- SpaceTradersApi.TradeGood
- SpaceTradersApi.TradeSymbol
- SpaceTradersApi.TransferCargo200Response
- SpaceTradersApi.TransferCargoRequest
- SpaceTradersApi.Waypoint
- SpaceTradersApi.WaypointFaction
- SpaceTradersApi.WaypointOrbital
- SpaceTradersApi.WaypointTrait
- SpaceTradersApi.WaypointType
Documentation for Authorization
Authentication schemes defined for the API:
AgentToken
- Type: Bearer authentication