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

SpaceTrack client class.

  • identity – Space-Track username.

  • password – Space-Track password.

  • base_url – May be overridden to use e.g.

  • 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.


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).


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 with Space-Track.


spacetrack.base.AuthenticationError – Incorrect login details.


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)
  • 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' ->, 1, 1).

  • **kwargs

    These keywords must match the predicate fields on Space-Track. You may check valid keywords with the following snippet:

    spacetrack = SpaceTrackClient(...)
    # or

    See _stringify_predicate_value() for which Python objects are converted appropriately.


Lines—stripped of newline characters—if iter_lines=True


100 KiB chunks if iter_content=True


Parsed JSON object, unless format keyword argument is passed.


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.