SpaceTrack#

exception spacetrack.base.AuthenticationError[source]#

Space-Track authentication error.

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/', rush_store=None, rush_key_prefix='', httpx_client=None, additional_rate_limit=None)[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/

  • rush_store – A rush storage backend. By default, a DictionaryStore is used. You may wish to use RedisStore to follow rate limits from multiple instances.

  • rush_key_prefix – You may choose a prefix for the keys that will be stored in rush_store, e.g. to avoid conflicts in a redis db.

  • httpx_client – Provide a custom httpx.Client` instance. ``SpaceTrackClient takes ownership of the httpx client. You should only provide your own client if you need to configure it first (e.g. for a proxy).

  • additional_rate_limit – Optionally, a rush.quota.Quota if you want to restrict the rate limit further than the defaults.

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.

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 set format if you want the parsed JSON object returned!

get_predicates(class_, controller=None)[source]#

Get full predicate information for given request class, and cache for subsequent calls.