/SpaceX-API-Wrapper

A Node.js API Wrapper for r-spacex/SpaceX-API - Now supports V3!

Primary LanguageJavaScriptMIT LicenseMIT

SpaceX API Wrapper (Node.js)

GitHub release GitHub issues GitHub stars GitHub license

Simple and Easy API Wrapper for r-spacex/SpaceX-API!



Installation

To install via npm use: npm i spacex-api-wrapper

To install via yarn use: yarn add spacex-api-wrapper

Basic Usage

To use the wrapper, require the module and initialise the module:

let SpacexApiWrapper = require("spacex-api-wrapper");

SpacexApiWrapper.info().then(function(data) {
    console.log(data);
});
{
  "name": "SpaceX",
  "founder": "Elon Musk",
  "founded": 2002,
  "employees": 7000,
  "vehicles": 3,
  "launch_sites": 3,
  "test_sites": 1,
  "ceo": "Elon Musk",
  "cto": "Elon Musk",
  "coo": "Gwynne Shotwell",
  "cto_propulsion": "Tom Mueller",
  "valuation": 27500000000,
  "headquarters": {
    "address": "Rocket Road",
    "city": "Hawthorne",
    "state": "California"
  },
  "links": {
    "website": "https://www.spacex.com/",
    "flickr": "https://www.flickr.com/photos/spacex/",
    "twitter": "https://twitter.com/SpaceX",
    "elon_twitter": "https://twitter.com/elonmusk"
  },
  "summary": "SpaceX designs, manufactures and launches advanced rockets and spacecraft. The company was founded in 2002 to revolutionize space technology, with the ultimate goal of enabling people to live on other planets."
}

Documentation

This wrapper provides the static methods listed below. Each links to the relevant section of the API's documentation.

Arguments:

  • id - Specifies the id of the entity to retrieve.
  • query - An object listing any additional options or output controls specified in the API's documentation.
  • settings - Object used to setup axios:
    • method - Method to use when making requests. Default is get and is the only method used in the API.
    • baseURL - The URL of the API.
    • ssl - Use SSL?
    • version - Defaults to V3, which this wrapper is designed for. Using other versions may cause the wrapper to stop working or to not cover all endpoints.
    • timeout - How long before timing out a request.

All arguments other than the id argument (only required a small number of methods) are optional.

Documentation for the API can be found here.

Capsules

Cores

Dragons

History

Info

Landing Pads

Launches

Launch Pads

Missions

Payloads

Rockets

Roadster

Ships

FAQs

  • What is returned in replace of a 404?
    • When the API returns a 404, it occurs usually when an id in an endpoint was not valid. This has been handled in this repository by returning undefined.
  • The tests seem a little odd?
    • The tests used for this wrapper are copies of r-spacex/SpaceX-API tests. It seems that these are out of date for their own API. Once they are updated and improved I will update the tests here.