Module Documentation

Api

The Api class exposes the main interface for this library. A fetch method is provided for all models.

The fetch method will get the data, turn it into python objects recursively, and do a few other nice things like adding python date-time objects.

class launchlibrary.Api(api_url='https://ll.thespacedevs.com', version='2.0.0', unicode=True)[source]
__init__(api_url='https://ll.thespacedevs.com', version='2.0.0', unicode=True)[source]

The API class for the launchlibrary module.

Parameters:
  • api_url (str) – The URL of the launchlibrary website.
  • version (str) – Version of the api
  • unicode (bool) – Set to False to convert unicode characters to ASCII using unidecode.
fetch_agency(**kwargs)[source]

Fetch from the Agency endpoint

fetch_launch(**kwargs)[source]

Fetch from the Launch endpoint

next_launches(num)[source]

Get the next {num} launches.

Parameters:num (int) – a number for the number of launches
Return type:List[UpcomingLaunch]
fetch_pad(**kwargs)[source]

Fetch from the Pad endpoint

fetch_location(**kwargs)[source]

Fetch from the Location endpoint

fetch_rocket(**kwargs)[source]

Fetch from the Rocket endpoint

async_fetch_agency(**kwargs)[source]

Fetch from the Agency endpoint

async_fetch_launch(**kwargs)[source]

Fetch from the Launch endpoint

async_fetch_location(**kwargs)[source]

Fetch from the Location endpoint

async_fetch_pad(**kwargs)[source]

Fetch from the Pad endpoint

async_fetch_rocket(**kwargs)[source]

Fetch from the Rocket endpoint

async_next_launches(num)[source]

Get the next {num} launches.

Parameters:num (int) – a number for the number of launches
Return type:List[AsyncUpcomingLaunch]

Models

As this library is based on the launchlibrary API, you can find a lot of info on their website . Note that the wrapper only uses the detailed mode.

Additionally, the parameters of every model can be accessed post-creation by using model.param_names.

class launchlibrary.models.BaseModel(network, param_translations, proper_name)[source]

Bases: object

The base model class all models should inherit from. Provides fetch and other utility functionalities.

_endpoint_name:The endpoint to use in the api
_nested_name:The name of that will appear in nested results. “Agencies” and the such.
Operation Description
x == y Checks if both objects are of the same type and have the same id.
classmethod fetch(network, **kwargs)[source]

Initializes a class, or even a list of them from the api using the needed params.

Parameters:
  • network (Network) – An instance of the network class
  • kwargs – Arguments to include in the GET request
Return type:

list

classmethod init_from_json(network, json_object)[source]

Initializes a class from a json object. Only single classes.

Parameters:
  • network (Network) – launchlibrary.Network
  • json_object (dict) – An object containing the “entry” we want to init.
Returns:

cls

class launchlibrary.models.Agency(network)[source]

Bases: launchlibrary.models.BaseModel

A class representing an agency object.

class launchlibrary.models.Launch(network)[source]

Bases: launchlibrary.models.BaseModel

A class representing a launch object.

You may use the ‘windowstart’, ‘windowend’, and ‘net’ params to access datetime objects of the times. They’ll be ‘None’ if the conversion fails.

The comparison magic methods that are implemented essentially compare the dates of the two objects.

Operation Description
x < y Checks if launch y occurs before launch x.
x > y Checks if launch x occurs before launch y.
class launchlibrary.models.UpcomingLaunch(network)[source]

Bases: launchlibrary.models.Launch

classmethod next(network, num)[source]

A simple abstraction method to get the next {num} launches.

Parameters:
  • network (Network) – An instance of launchlibrary.Api
  • num (int) – a number for the number of launches
Return type:

List[UpcomingLaunch]

class launchlibrary.models.Pad(network)[source]

Bases: launchlibrary.models.BaseModel

A class representing a pad object.

class launchlibrary.models.Location(network)[source]

Bases: launchlibrary.models.BaseModel

A class representing a location object.

class launchlibrary.models.Rocket(network)[source]

Bases: launchlibrary.models.BaseModel

A class representing a rocket object.

get_pads()[source]

Returns Pad type objects of the pads the rocket uses.

Return type:List[Pad]

Asynchronous Models

The library also supports asynchronous operation. To receive proper coroutines, just prepend Async to the name of the class.

class launchlibrary.async_models.BaseAsync(network, param_translations, proper_name)[source]

Bases: launchlibrary.models.BaseModel

classmethod fetch(network, **kwargs)[source]

The fetch method implements fetch with an async HTTP GET function.

Parameters:
  • network (Network) – A network instance
  • kwargs – args for the api call
Returns:

objects based on BaseAsync

class launchlibrary.async_models.AsyncAgency(network)[source]

Bases: launchlibrary.models.Agency, launchlibrary.async_models.BaseAsync

A class representing an async agency object.

class launchlibrary.async_models.AsyncLaunch(network)[source]

Bases: launchlibrary.models.Launch, launchlibrary.async_models.BaseAsync

A class representing an async launch object.

class launchlibrary.async_models.AsyncUpcomingLaunch(network)[source]

Bases: launchlibrary.models.UpcomingLaunch, launchlibrary.async_models.BaseAsync

A class representing an upcoming launch object.

classmethod next(network, num)[source]

Get the next {num} launches.

Parameters:
  • network (Network) – A network instance
  • num (int) – a number for the number of launches
class launchlibrary.async_models.AsyncPad(network)[source]

Bases: launchlibrary.models.Pad, launchlibrary.async_models.BaseAsync

A class representing an async pad object.

class launchlibrary.async_models.AsyncLocation(network)[source]

Bases: launchlibrary.models.Location, launchlibrary.async_models.BaseAsync

A class representing an async Location object.

class launchlibrary.async_models.AsyncRocket(network)[source]

Bases: launchlibrary.models.Rocket, launchlibrary.async_models.BaseAsync

A class representing an async rocket.

get_pads()[source]

Returns Pad type objects of the pads the rocket uses.

Return type:List[AsyncPad]

Exceptions

The library attempts not to leak any exceptions except the regular Python ones, like ValueError and KeyError.

exception launchlibrary.exceptions.LlException(message='There was an unspecified exception regarding the LaunchLibrary wrapper.')[source]

Bases: Exception

The base class for all exceptions emitted by the library

exception launchlibrary.exceptions.ApiException(message='There was an unknown issue with the API. Please reevaluate your call.')[source]

Bases: launchlibrary.exceptions.LlException

An exception related to the API’s response

exception launchlibrary.exceptions.NetworkException(message)[source]

Bases: launchlibrary.exceptions.LlException

Some network failure that’s unrelated to the request, like a dropped connection

exception launchlibrary.exceptions.TimeoutException(message='')[source]

Bases: launchlibrary.exceptions.LlException

All timeout failures, both during the initial connection and subsequent messages