2.0.0 • Published 12 months ago

dl-spacetraders-sk v2.0.0

Weekly downloads
-
License
No Permission
Repository
-
Last release
12 months ago

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

ClassMethodHTTP requestDescription
SpaceTradersApi.AgentsApigetMyAgentGET /my/agentMy Agent Details
SpaceTradersApi.ContractsApiacceptContractPOST /my/contracts/{contractId}/acceptAccept Contract
SpaceTradersApi.ContractsApideliverContractPOST /my/contracts/{contractId}/deliverDeliver Contract
SpaceTradersApi.ContractsApifulfillContractPOST /my/contracts/{contractId}/fulfillFulfill Contract
SpaceTradersApi.ContractsApigetContractGET /my/contracts/{contractId}Get Contract
SpaceTradersApi.ContractsApigetContractsGET /my/contractsList Contracts
SpaceTradersApi.DefaultApiregisterPOST /registerRegister New Agent
SpaceTradersApi.FactionsApigetFactionGET /factions/{factionSymbol}Get Faction
SpaceTradersApi.FactionsApigetFactionsGET /factionsList Factions
SpaceTradersApi.FleetApicreateChartPOST /my/ships/{shipSymbol}/chartCreate Chart
SpaceTradersApi.FleetApicreateShipShipScanPOST /my/ships/{shipSymbol}/scan/shipsScan Ships
SpaceTradersApi.FleetApicreateShipSystemScanPOST /my/ships/{shipSymbol}/scan/systemsScan Systems
SpaceTradersApi.FleetApicreateShipWaypointScanPOST /my/ships/{shipSymbol}/scan/waypointsScan Waypoints
SpaceTradersApi.FleetApicreateSurveyPOST /my/ships/{shipSymbol}/surveyCreate Survey
SpaceTradersApi.FleetApidockShipPOST /my/ships/{shipSymbol}/dockDock Ship
SpaceTradersApi.FleetApiextractResourcesPOST /my/ships/{shipSymbol}/extractExtract Resources
SpaceTradersApi.FleetApigetMyShipGET /my/ships/{shipSymbol}Get Ship
SpaceTradersApi.FleetApigetMyShipCargoGET /my/ships/{shipSymbol}/cargoGet Ship Cargo
SpaceTradersApi.FleetApigetMyShipsGET /my/shipsList Ships
SpaceTradersApi.FleetApigetShipCooldownGET /my/ships/{shipSymbol}/cooldownGet Ship Cooldown
SpaceTradersApi.FleetApigetShipNavGET /my/ships/{shipSymbol}/navGet Ship Nav
SpaceTradersApi.FleetApijettisonPOST /my/ships/{shipSymbol}/jettisonJettison Cargo
SpaceTradersApi.FleetApijumpShipPOST /my/ships/{shipSymbol}/jumpJump Ship
SpaceTradersApi.FleetApinavigateShipPOST /my/ships/{shipSymbol}/navigateNavigate Ship
SpaceTradersApi.FleetApiorbitShipPOST /my/ships/{shipSymbol}/orbitOrbit Ship
SpaceTradersApi.FleetApipatchShipNavPATCH /my/ships/{shipSymbol}/navPatch Ship Nav
SpaceTradersApi.FleetApipurchaseCargoPOST /my/ships/{shipSymbol}/purchasePurchase Cargo
SpaceTradersApi.FleetApipurchaseShipPOST /my/shipsPurchase Ship
SpaceTradersApi.FleetApirefuelShipPOST /my/ships/{shipSymbol}/refuelRefuel Ship
SpaceTradersApi.FleetApisellCargoPOST /my/ships/{shipSymbol}/sellSell Cargo
SpaceTradersApi.FleetApishipRefinePOST /my/ships/{shipSymbol}/refineShip Refine
SpaceTradersApi.FleetApitransferCargoPOST /my/ships/{shipSymbol}/transferTransfer Cargo
SpaceTradersApi.FleetApiwarpShipPOST /my/ships/{shipSymbol}/warpWarp Ship
SpaceTradersApi.SystemsApigetJumpGateGET /systems/{systemSymbol}/waypoints/{waypointSymbol}/jump-gateGet Jump Gate
SpaceTradersApi.SystemsApigetMarketGET /systems/{systemSymbol}/waypoints/{waypointSymbol}/marketGet Market
SpaceTradersApi.SystemsApigetShipyardGET /systems/{systemSymbol}/waypoints/{waypointSymbol}/shipyardGet Shipyard
SpaceTradersApi.SystemsApigetSystemGET /systems/{systemSymbol}Get System
SpaceTradersApi.SystemsApigetSystemWaypointsGET /systems/{systemSymbol}/waypointsList Waypoints
SpaceTradersApi.SystemsApigetSystemsGET /systemsList Systems
SpaceTradersApi.SystemsApigetWaypointGET /systems/{systemSymbol}/waypoints/{waypointSymbol}Get Waypoint

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

AgentToken

  • Type: Bearer authentication
2.0.0

12 months ago