Async API#
- class spacetrack.aio.AsyncSpaceTrackClient(identity, password, base_url='https://www.space-track.org/', rush_store=None, rush_key_prefix='', httpx_client=None, additional_rate_limit=None)[source]#
Bases:
SpaceTrackClient
Asynchronous SpaceTrack client class.
It must be closed by calling
close()
. Alternatively, instances of this class can be used as an async context manager.Refer to the
SpaceTrackClient
documentation for more information. Note that if passed, thehttpx_client
parameter must be anhttpx.AsyncClient
.- async authenticate()[source]#
Authenticate with Space-Track.
- Raises:
spacetrack.base.AuthenticationError – Incorrect login details.
Note
This method is called automatically when required.
- async 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!