API Quick Start Guide
-
Create an account
Start the account creation process by navigating to the Sign Up page or by clicking here. If you encounter an issue, please contact account support at accounts@leolabs.space for assistance.
We automatically create a personal organization for you to use with LeoLabs, but you may want to join or create another organization to use with your colleagues.
-
Create an API key
Once you've created your new account and are logged in, create a new API key on the API Keys page. Navigate there by clicking on "Manage API Keys" in the top menu or by clicking here.
-
Upgrade to a standard subscription for your organization
New organizations start out with a Trial Subscription and have certain restrictions. In order to gain full access to the LeoLabs API, please contact us at accounts@leolabs.space to start the upgrade process.
-
Requesting data from the API
To request data from the LeoLabs API, you must make an HTTP request with a header.
In the curl command line tool, adding a header to a request is as simple as typing:
$ curl -H "<header>" "<url>"
Try out your API key! Make sure you have curl installed, then run this command. (macOS, OSX, and many other Linux-based operating systems come with curl pre-installed.)
$ curl -H "Authorization: basic <access-key>:<secret-key>" "https://api.leolabs.space/v1/instruments"
Remember to replace <access-key> with your access key and <secret-key> with your secret key from the API Keys page.
-
Different commands
The API documentation shows all the different commands you can perform. Here are some examples:
GET /catalog/objects
Returns a list of all the objects in the LeoLabs database.
$ curl -H "Authorization: basic <access-key>:<secret-key>" "https://api.leolabs.space/v1/catalog/objects"
GET /catalog/objects/{catalogNumber}
Returns an object with the specified catalog number. Replace {catalogNumber} with an object's catalog number. For example:
$ curl -H "Authorization: basic <access-key>:<secret-key>" "https://api.leolabs.space/v1/catalog/objects/L355"
GET /catalog/objects/{catalogNumber}/measurements
Returns measurements for the specified object. For example:
$ curl -H "Authorization: basic <access-key>:<secret-key>" "https://api.leolabs.space/v1/catalog/objects/L355/measurements"
GET /instruments
Returns a list of the current LeoLabs instruments.
$ curl -H "Authorization: basic <access-key>:<secret-key>" "https://api.leolabs.space/v1/instruments"
GET /instruments/{instrumentId}/statistics
Returns statistics for the specified instrument.
$ curl -H "Authorization: basic <access-key>:<secret-key>" "https://api.leolabs.space/v1/instruments/msr/statistics"
-
Reading data
Once you've made a request, you will usually receive a JSON object containing the requested data. The format of the data is specified on the API documentation.
The API documentation gives you all the info you need, including possible parameters, data types, and API endpoints.