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.
- api_url (
-
next_launches
(num)[source]¶ Get the next {num} launches.
Parameters: num ( int
) – a number for the number of launchesReturn type: List
[UpcomingLaunch
]
-
async_next_launches
(num)[source]¶ Get the next {num} launches.
Parameters: num ( int
) – a number for the number of launchesReturn 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.
-
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
]- network (
-
classmethod
-
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.
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.
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.
-
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.
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