Python Client for RocketLaunchLive API
Project description
RocketLauchLive.com has a REST API for getting information about scheduled and past launches, locations of launnches, companies doing launches, the kind so vehicles launched, and the missions involved. This python client library was developed in order to leverage the REST API in order to pull historical data for analysis and reporting purposes.
Install
# Install tool
pip install py-rocket-launch-live-client
Usage
You will need an API key from https://www.rocketlaunch.live/api
It is recommended that you use an environment variable or some "secret" method to protect your API key and provide it to your python script.
key = API_KEY
import either the library or the end-point you are interested in:
import py_rocket_launch_live_client as prllc
key = API_key
vehicles = prllc.vehicles.get(key)
or
from py_rocket_launch_live_client import vheicles
vehcles = prllc.vehicles.get(key)
Each endpoint has its get function, all the rocketlaunchlive.com api endpoints as of 2/1/2024 are supported these are:
The general convention is: results = prllc.{endpoint}.get({key},{paramname}=value,...) The endpoint list above links to the rocketlaunchlive.com api documentation for the endpoint. The parameters described should be supported as valid parameters in any combination to the endpoint's get function.
Two universal parameters are
- page_size - number of results to request at a time with an api enforced max limit of 25, which is also the default if not specified.
- limit - number of total results to limit to if set.
The get functions return an iterable RocketLaunchLiveCursor object which will allow you to loop on the results and will fetch additional pages until limit results or all results are retrieved. The iterator values return a dict for each entry in the 'results' property from the parsed API response.
import py_rocket_launch_live_client as prllc
key = API_KEY
launches = prllc.launches.get(key,limit=100)
for launch in launches:
print(launch['date_str'],launch['name'])
Note that in the code above a maximum of 100 results will be retrieved, but it will do so by retrieving 4 pages of 25 records, this may create a lag in your loop but the api is fairly performant.
Return Values
At this time, this cilent library isn't specifying the types returned by the API and the documentation for anything but launches at rocketlaunchlive is underwhelming. For best results call an end point with a limit=1 and see what you get and know that you can access an entry from the cursor iteration using dict syntax.
slug
The slug parameter is inconsistent in the API in terms of being returned and usable for retrieval. If you need an identifier, id is usually a guranteed way to find something. A slug if you have one can be used best with the launches endpoint which seems to find launches by any slug regardless of the object type the slug was for.
Raw Response
The cursor uses the requests python library for making the REST calls to the API. The requests response is held in the cursor's currentResponse property.
The cursor holds the lastPage value returned from the API, and you can use the cursor's GoToPage(n),NextPage(),PrevPage(), and Rewind() functions to jump to another page of results, this will update currentResponse to reflect the response for the target page.
Note: pages are 1-based
import py_rocket_launch_live_client as prllc
key = API_KEY
launches = prllc.launches.get(key,limit=100)
launches.GoToPage(2)
page1Text = launches.currentResponse.text
launches.GoToPage(3)
page2Text = launches.currentResponse.text
Tip-Jar
This library was created as a personal project and intended as a contribution to rocketlaunchlive.com. If you value this library and would like to show your support can do so through {PayPal
Thank you for your support
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file py-rocket-launch-live-client-1.1.0.tar.gz
.
File metadata
- Download URL: py-rocket-launch-live-client-1.1.0.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 054b9da9d428ff5c7be91430973d145457130480fdae086f5bfa47678acdcfab |
|
MD5 | ea9f626ecb7008130ca899e089db905e |
|
BLAKE2b-256 | 82b5a1ae48cd31e49ba3d3d7400ffd84c443a25e8806dbfb971bd4bf92166c87 |
File details
Details for the file py_rocket_launch_live_client-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: py_rocket_launch_live_client-1.1.0-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5bf087019427ae486add2cbc329ed806fca019ba5fd540ec0b312242572f13b2 |
|
MD5 | f9007bec26cc554cf34964075d0e273b |
|
BLAKE2b-256 | 38f35b752fd283902b5be92939097ef9bcf9eeef33dad6103d3f2a2fad22c5a3 |