SpaceTrack¶
-
exception
spacetrack.base.
UnknownPredicateTypeWarning
[source]¶ Used to warn when a predicate type is unknown.
-
class
spacetrack.base.
Predicate
(name, type_, nullable=False, default=None, values=None)[source]¶ Hold Space-Track predicate information.
The current goal of this class is to print the repr for the user.
-
class
spacetrack.base.
SpaceTrackClient
(identity, password, base_url='https://www.space-track.org/')[source]¶ SpaceTrack client class.
Parameters: - identity – Space-Track username.
- password – Space-Track password.
- base_url – May be overridden to use e.g. https://testing.space-track.org/
For more information, refer to the Space-Track documentation.
-
request_controllers
¶ Ordered dictionary of request controllers and their request classes in the following order.
- basicspacedata
- expandedspacedata
- fileshare
- spephemeris
For example, if the
spacetrack.file
method is used without specifying which controller, the client will choose the fileshare controller (which comes before spephemeris).Note
If new request classes and/or controllers are added to the Space-Track API but not yet to this library, you can safely subclass
SpaceTrackClient
with a copy of this ordered dictionary to add them.That said, please open an issue on GitHub for me to add them to the library.
-
session
= None¶ requests.Session
instance. It can be mutated to configure e.g. proxies.
-
authenticate
()[source]¶ Authenticate with Space-Track.
Raises: spacetrack.base.AuthenticationError
– Incorrect login details.Note
This method is called automatically when required.
-
generic_request
(class_, iter_lines=False, iter_content=False, controller=None, parse_types=False, **kwargs)[source]¶ Generic Space-Track query.
The request class methods use this method internally; the public API is as follows:
st.tle_publish(*args, **kw) st.basicspacedata.tle_publish(*args, **kw) st.file(*args, **kw) st.fileshare.file(*args, **kw) st.spephemeris.file(*args, **kw)
They resolve to the following calls respectively:
st.generic_request('tle_publish', *args, **kw) st.generic_request('tle_publish', *args, controller='basicspacedata', **kw) st.generic_request('file', *args, **kw) st.generic_request('file', *args, controller='fileshare', **kw) st.generic_request('file', *args, controller='spephemeris', **kw)
Parameters: - class_ – Space-Track request class name
- iter_lines – Yield result line by line
- iter_content – Yield result in 100 KiB chunks.
- controller – Optionally specify request controller to use.
- parse_types – Parse string values in response according to type given
in predicate information, e.g.
'2017-01-01'
->datetime.date(2017, 1, 1)
. - **kwargs –
These keywords must match the predicate fields on Space-Track. You may check valid keywords with the following snippet:
spacetrack = SpaceTrackClient(...) spacetrack.tle.get_predicates() # or spacetrack.get_predicates('tle')
See
_stringify_predicate_value()
for which Python objects are converted appropriately.
Yields: Lines—stripped of newline characters—if
iter_lines=True
Yields: 100 KiB chunks if
iter_content=True
Returns: Parsed JSON object, unless
format
keyword argument is passed.Warning
Passing
format='json'
will return the JSON unparsed. Do not setformat
if you want the parsed JSON object returned!