Skip to main content

Python Client for RocketLaunchLive API

Project description

py-rocket-launch-live-client

As simple python clinet for the api provided by rocketlaunchlive.com.

Build Status Coverage Status PyPi Licence

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
pip3 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py-rocket-launch-live-client-1.0.1.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file py-rocket-launch-live-client-1.0.1.tar.gz.

File metadata

File hashes

Hashes for py-rocket-launch-live-client-1.0.1.tar.gz
Algorithm Hash digest
SHA256 69cbb92b029137085343dc080899e61c95d99cb165b6df91a439bf8bc0aa6c76
MD5 f32d2e93652b02b23c2228d61fbc2cc8
BLAKE2b-256 9c6ce7aa0cf29ae872db28a39225e67667a8c44528b00e5accab613d3a3b1ca7

See more details on using hashes here.

File details

Details for the file py_rocket_launch_live_client-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for py_rocket_launch_live_client-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 08ebf242d18e29045605bb98c3f5f73f04df7c09fec27fcae5d2e92dcdd633a1
MD5 a0ecff0fd9e4498e6662da73da7b1a99
BLAKE2b-256 83a337eed28ba4868c9e03874a1bfb0dfd5b7766fef8f119c1d8e2375b895019

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page