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.0.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

File details

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

File metadata

File hashes

Hashes for py-rocket-launch-live-client-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d7edd3dfca0f57656fa3a03e5fa6537cf007705e3da24c96323707d858258de8
MD5 1ba337d8d58ab69f9759e030f4e44c5b
BLAKE2b-256 e4efb29bebc2a3f77fa82ea39d792448602e89c10d3a1c59cdea7b73078e0975

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for py_rocket_launch_live_client-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 62887df527672d5dedf2886a1cea925b4dc327cff5dfca5ea601be65065086f2
MD5 1f80f4e040155dc530a34f5c07090023
BLAKE2b-256 40e7604297adc3d5041f949a1b878e61b9c7ae3f08473b684c80a95980812149

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