https://api.spacexdata.com/v4
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.
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). Documentationsort
{ Object | String } - Sort order. Documentationoffset
{ Number } - Useoffset
orpage
to set skip positionpage
{ 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
}
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:
- 🔒 Clear cache :
DELETE /admin/cache
Detailed info for serialized dragon capsules
- Get all capsules :
GET /capsules
- Get one capsule :
GET /capsules/:id
- Query capsules :
POST /capsules/query
- 🔒 Create a capsule :
POST /capsules
- 🔒 Update a capsule :
PATCH /capsules/:id
- 🔒 Delete a capsule :
DELETE /capsules/:id
Detailed info for serialized first stage cores
- Get all cores :
GET /cores
- Get one core :
GET /v4/cores/:id
- Query cores :
POST /cores/query
- 🔒 Create a core :
POST /cores
- 🔒 - 🔒 Update a core :
PATCH /cores/:id
- 🔒 - 🔒 Delete a core :
DELETE /cores/:id
- 🔒
Detailed info on dragon crew members
- Get all crew members :
GET /crew
- Get one crew member :
GET /crew/:id
- Query crew members :
POST /crew/query
- 🔒 Create a crew member :
POST /crew
- 🔒 Update a crew member :
PATCH /crew/:id
- 🔒 Delete a crew member :
DELETE /crew/:id
Detailed info about dragon capsule versions
- Get all dragons :
GET /dragons
- Get one dragon :
GET /dragons/:id
- Query dragons :
POST /dragons/query
- 🔒 Create a dragon :
POST /dragons
- 🔒 Update a dragon :
PATCH /dragons/:id
- 🔒 Delete a dragon :
DELETE /dragons/:id
Detailed info about landing pads and ships
- Get all landpads :
GET /landpads
- Get one landpad :
GET /landpads/:id
- Query landpads :
POST /landpads/query
- 🔒 Create a landpad :
POST /landpads
- 🔒 Update a landpad :
PATCH /landpads/:id
- 🔒 Delete a landpad :
DELETE /landpads/:id
Detailed info about launches
- Get past launches :
GET /launches/past
- Get upcoming launches :
GET /launches/upcoming
- Get latest launches :
GET /launches/latest
- Get next launches :
GET /launches/next
- Get all launches :
GET /launches
- Get one launch :
GET /launches/:id
- Query launches :
POST /launches/query
- 🔒 Create a launch :
POST /launches
- 🔒 Update a launch :
PATCH /launches/:id
- 🔒 Delete a launch :
DELETE /launches/:id
Detailed info about launchpads
- Get all launchpads :
GET /launchpads
- Get one launchpad :
GET /launchpads/:id
- Query launchpads :
POST /launchpads/query
- 🔒 Create a launchpad :
POST /launchpads
- 🔒 Update a launchpad :
PATCH /launchpads/:id
- 🔒 Delete a launchpad :
DELETE /launchpads/:id
Detailed info about launch payloads
- Get all payloads :
GET /payloads
- Get one payload :
GET /payloads/:id
- Query payloads :
POST /payloads/query
- 🔒 Create a payload :
POST /payloads
- 🔒 Update a payload :
PATCH /payloads/:id
- 🔒 Delete a payload :
DELETE /payloads/:id
Detailed info about rocket versions
- Get all rockets :
GET /rockets
- Get one rocket :
GET /rockets/:id
- Query rockets :
POST /rockets/query
- 🔒 Create a rocket :
POST /rockets
- 🔒 Update a rocket :
PATCH /rockets/:id
- 🔒 Delete a rocket :
DELETE /rockets/:id
Detailed info about ships in the SpaceX fleet
- Get all ships :
GET /ships
- Get one ship :
GET /ships/:id
- Query ships :
POST /ships/query
- 🔒 Create a ship :
POST /ships
- 🔒 Update a ship :
PATCH /ships/:id
- 🔒 Delete a ship :
DELETE /ships/:id
Detailed info about SpaceX as a company
- Get company info :
GET /company
- 🔒 Update company info :
PATCH /company/:id
Detailed info about Elon's Tesla roadster's current position
- Get roadster info :
GET /roadster
- 🔒 Update roadster info :
PATCH /roadster/:id