Skip to content

Latest commit

 

History

History
200 lines (142 loc) · 7.18 KB

README.md

File metadata and controls

200 lines (142 loc) · 7.18 KB

r/SpaceX API Docs

Base URL

https://api.spacexdata.com/v4

Authentication

Authentication via api key is required for all destructive routes. This includes all create, update, and delete routes.

Authenticate by passing the header spacex-key with your api key. Protected routes return 401 without a valid key.

Pagination + Querying

All /query routes support pagination parameters via mongoose-paginate.

By default the body is:

{
  "query": {},
  "options": {},
}

query accepts any valid MongoDB find() query, documented here

See examples for some common queries

Note: The $where operator is not supported in query. $expr should be used instead for complex query expressions

options accepts any of the options documented here, but here are some of the most common:

  • select { Object | String } - Fields to return (by default returns all fields). Documentation
  • sort { Object | String } - Sort order. Documentation
  • offset { Number } - Use offset or page to set skip position
  • page { Number }
  • limit { Number }
  • pagination { Boolean } - If set to false, it will return all docs without adding limit condition. (Default: True)

This is the default return structure:

{
    "docs": [],
    "totalDocs": 0,
    "offset": 0,
    "limit": 10,
    "totalPages": 1,
    "page": 1,
    "pagingCounter": 1,
    "hasPrevPage": false,
    "hasNextPage": false,
    "prevPage": null,
    "nextPage": null
}

Caching

The api makes use of response caching via Redis for all GET requests, and POST requests on /query endpoints.

Standard cache times are as follows:

launches - 20 seconds

capsules, cores, launchpads, landpads, crew, ships, payloads - 5 minutes

dragons, rockets - 24 hours

Cache can be cleared with the following endpoint:

Routes

Capsules

Detailed info for serialized dragon capsules

Cores

Detailed info for serialized first stage cores

Crew

Detailed info on dragon crew members

Dragons

Detailed info about dragon capsule versions

Landpads

Detailed info about landing pads and ships

Launches

Detailed info about launches

Launchpads

Detailed info about launchpads

Payloads

Detailed info about launch payloads

Rockets

Detailed info about rocket versions

Ships

Detailed info about ships in the SpaceX fleet

Company Info

Detailed info about SpaceX as a company

Roadster info

Detailed info about Elon's Tesla roadster's current position