spacetracktool package

Submodules

spacetracktool.operations module

Operations for use with the SpaceTrackClient.

spacetracktool.operations.make_range_string(start=None, end=None, equal=False)[source]
Return type:str

Generates a string based on input range and mode.

If equal is True, returns start or end (if start is None). If equal is False, retruns ‘>[start]’ if only start is given, returns ‘<[end]’ if only end is given, and returns ‘[start]–[end]’ if both are given. Note that no range checking is performed on the input strings to ensure the result is a valid range.

Kwargs:

start: str or value coercable to str.
The starting (lowest) value of the string. Default is None.
end: str or value coercable to str.
The end (highest) value of the string. Default is None.
equal: if True, returns start if defined, otherwise end. If False,
returns a range based on values of start and end. Default is False.
Returns:

Resulting range string.

Raises:
  • ValueError – if neither start nor end is specified and equal is True.
  • ValueError – if neither start nor end (or both) is specified and equal is False.
  • ValueError – if start or end cannot be coerced to string.

spacetracktool.spacetrackclient module

Defines the space-track.org query client.

Queries to space-track.org are made by first creating a client instance, and then calling the appropriate method for your desired query type. Multiple queries may be created with the same client, but each new query type overwrites the previous query (cannot run multiple concurrent queries with a singel submit command).

class spacetracktool.spacetrackclient.SpaceTrackClient(username, password, fmt=None)[source]

Bases: object

Provides an API for making POST requests to space-track.org

Parameters:
  • username (str) – your space-track.org username.
  • password (str) – the associated password.
Kwargs:
fmt: string specifying format for returned message. Can be one of
‘xml’, ‘json’, ‘html’, ‘csv’, ‘tle’, ‘3le’, ‘kvn’, or None. None is the same as ‘json’. Default is None.
Properties:
result: the result string returned from space-track.org by the last-run
submit command.

Examples:

>> import spacetracktool as st
>> from spacetracktool import operations as ops
>> client = SpaceTrackClient(username, password)
>> result = client.tle_query(norad_cat_id=12345)

>> date_range = ops.make_range_string('2018-01-01', '2018-01-31')
>> result = client.tle_query(epoch=date_range)  # throws out previous query!
announcement_query(**kwargs)[source]

Initiates a announcement request.

Returns:

The result of the query to space-track.org

Raises:
  • IndexError – if no keyword arguments are provided
  • KeyError – if any provided key is not in the expected argument list
base

Returns URL base string.

box_score_query(**kwargs)[source]

Initiates a boxscore query request.

Returns:

The result of the query to space-track.org

Raises:
  • IndexError – if no keyword arguments are provided
  • KeyError – if any provided key is not in the expected argument list
cdm_query(**kwargs)[source]

Initiates a cdm request.

Returns:

The result of the query to space-track.org

Raises:
  • IndexError – if no keyword arguments are provided
  • KeyError – if any provided key is not in the expected argument list
decay_query(**kwargs)[source]

Initiates a decay request.

Note that if the ‘precedence’ argument is not provided, it will default to a precedence of 2, which means messages that specifically announce that the object has decayed.

Returns:

The result of the query to space-track.org

Raises:
  • IndexError – if no keyword arguments are provided
  • KeyError – if any provided key is not in the expected argument list
launch_site_query(**kwargs)[source]

Initiates a launch_site request.

Returns:

The result of the query to space-track.org

Raises:
  • IndexError – if no keyword arguments are provided
  • KeyError – if any provided key is not in the expected argument list
login_url

Returns login URL string.

logout_url

Returns logout URL string.

null

Returns space-track.org’s null string.

organization_query(**kwargs)[source]

Initiates a organization request.

Returns:

The result of the query to space-track.org

Raises:
  • IndexError – if no keyword arguments are provided
  • KeyError – if any provided key is not in the expected argument list
print_query()[source]

Prints the query to the screen.

Note that at this stage the format string has not been applied to the query. This string gets applied at the very end prior to submitting the POST request.

satcat_change_query(**kwargs)[source]

Initiates a satcat_change request.

Returns:

The result of the query to space-track.org

Raises:
  • IndexError – if no keyword arguments are provided
  • KeyError – if any provided key is not in the expected argument list
satcat_debut_query(**kwargs)[source]

Initiates a satcat_debut request.

Returns:

The result of the query to space-track.org

Raises:
  • IndexError – if no keyword arguments are provided
  • KeyError – if any provided key is not in the expected argument list
satcat_query(**kwargs)[source]

Initiates a satcat query request.

Returns:

The result of the query to space-track.org

Raises:
  • IndexError – if no keyword arguments are provided
  • KeyError – if any provided key is not in the expected argument list
submit()[source]
Return type:Response

Submits the generated query to space-track.org.

Returns:Response from space-track.org
tip_query(**kwargs)[source]

Initiates a tracking and impact prediction (TIP) request.

Returns:

The result of the query to space-track.org

Raises:
  • IndexError – if no keyword arguments are provided
  • KeyError – if any provided key is not in the expected argument list
tle_latest_query(**kwargs)[source]

Initiates a TLE_latest query request.

Any number of keyword arguments that are defined by the space-track.org API may be provided. Single value arguments are easy and should be passed a string or an object that can be coerced to a string:

>> import spacetracktool as st
>> query = st.SpaceTrackClient('username', 'password')
>> result = query.tle_latest_query(norad_cat_id=12345)

Range arugment strings should be built with the spacetracktool.operations.make_range_string method. For example, to provide a date range to the epoch argument:

>> import spacetracktool as st
>> from spacetracktool import operations as ops
>> date_range = ops.make_range_string('2018-01-01', '2018-01-31')
>> query = st.SpaceTrackClient('username', 'password')
>> result = query.tle_latest_query(epoch=date_range)
Keyword Arguments:
 
  • ordinal (int, str) – TODO
  • comment (str) – TODO
  • originator (str) – TODO
  • norad_cat_id (int, str) – The norad catalog ID of a satellite. Should be a single value.
  • object_name (str) – The name string associated with an object. Should be a single value.
  • object_type (int, str) – The catalog object type. Should be a single value.
  • classification_type (int, str) – TODO
  • intldes (int, str) –
  • epoch (str) –

    The epoch date or date range in which to search. May be a single value or a range. Dates should be specified in ether of the followingthe formats:

    'YYYY-MM-DD HH:mm:ss'
    'YYYY-MM-DD'
    
  • epoch_microseconds (str) – TODO
  • mean_motion (float, str) – The mean motion to search in revolutions per day. May be a single value or a range.
  • eccentricity (float, str) – The eccentricity to search. May be a single value or a range.
  • inclination (float, str) – The inclination to search in degrees. May be a single value or a range.
  • ra_of_asc_node (float, str) – The right-ascension of the ascending node to search in degrees. May be a single value or a range.
  • arg_of_pericenter (float, str) – The argument of the pericenter to search. May be a single value or a range.
  • mean_anomaly (float, str) – The mean anomaly to search. May be a single value or a range.
  • ephemeris_type (int, str) – TODO
  • element_set_no (int, str) – The element set number to search. Should be a single value.
  • rev_at_epoch (float, str) – The revolution at epoch to search. May be a single value or a range.
  • bstar (float, str) – The b-star drag coefficient to search. May be a single value or a range.
  • mean_motion_dot (float, str) – The first derivative of the mean motion with respect to time. May be a single value or a range.
  • mean_motion_ddot (float, str) – The second derivative of the mean motion with respect to time. May be a single value or a range.
  • file (int, str) – TODO
  • tle_line0 (str) – The first line of a three-line element set.
  • tle_line1 (str) – The second line of a three-line element set or first line of a two-line element set.
  • tle_line2 (str) – The third line of a three-line element set or second line of a two-line element set.
  • object_id (str) – TODO
  • object_number (int, str) – TODO
  • semimajor_axis (float, str) – The semimajor axis in Earth radii. May be a single value or a range.
  • period (float, str) – The orbital period in days. May be single value or a range.
  • apogee (float, str) – The radius when furthest from the Earth. May be a single value or a range.
  • perigee (float, str) – The radius when furthest from the Earth. May be a single value or a range.
Returns:

The result of the query to space-track.org

Raises:
  • IndexError – if no keyword arguments are provided
  • KeyError – if any provided key is not in the expected argument list
tle_publish_query(**kwargs)[source]

Initiates a tle_publish query request.

Returns:

The result of the query to space-track.org

Raises:
  • IndexError – if no keyword arguments are provided
  • KeyError – if any provided key is not in the expected argument list
tle_query(**kwargs)[source]

Initiates a TLE query request.

Any number of keyword arguments that are defined by the space-track.org API may be provided. Single value arguments are easy and should be passed a string or an object that can be coerced to a string:

>> import spacetracktool as st
>> query = st.SpaceTrackClient('username', 'password')
>> result = query.tle_query(norad_cat_id=12345)

Range arugment strings should be built with the spacetracktool.operations.make_range_string method. For example, to provide a date range to the epoch argument:

>> import spacetracktool as st
>> from spacetracktool import operations as ops
>> date_range = ops.make_range_string('2018-01-01', '2018-01-31')
>> query = st.SpaceTrackClient('username', 'password')
>> result = query.tle_query(epoch=date_range)
Keyword Arguments:
 
  • comment (str) – TODO
  • originator (str) – TODO
  • norad_cat_id (int, str) – The norad catalog ID of a satellite. Should be a single value.
  • object_name (str) – The name string associated with an object. Should be a single value.
  • object_type (int, str) – The catalog object type. Should be a single value.
  • classification_type (int, str) – TODO
  • intldes (int, str) –
  • epoch (str) –

    The epoch date or date range in which to search. May be a single value or a range. Dates should be specified in ether of the followingthe formats:

    'YYYY-MM-DD HH:mm:ss'
    'YYYY-MM-DD'
    
  • epoch_microseconds (str) – TODO
  • mean_motion (float, str) – The mean motion to search in revolutions per day. May be a single value or a range.
  • eccentricity (float, str) – The eccentricity to search. May be a single value or a range.
  • inclination (float, str) – The inclination to search in degrees. May be a single value or a range.
  • ra_of_asc_node (float, str) – The right-ascension of the ascending node to search in degrees. May be a single value or a range.
  • arg_of_pericenter (float, str) – The argument of the pericenter to search. May be a single value or a range.
  • mean_anomaly (float, str) – The mean anomaly to search. May be a single value or a range.
  • ephemeris_type (int, str) – TODO
  • element_set_no (int, str) – The element set number to search. Should be a single value.
  • rev_at_epoch (float, str) – The revolution at epoch to search. May be a single value or a range.
  • bstar (float, str) – The b-star drag coefficient to search. May be a single value or a range.
  • mean_motion_dot (float, str) – The first derivative of the mean motion with respect to time. May be a single value or a range.
  • mean_motion_ddot (float, str) – The second derivative of the mean motion with respect to time. May be a single value or a range.
  • file (int, str) – TODO
  • tle_line0 (str) – The first line of a three-line element set.
  • tle_line1 (str) – The second line of a three-line element set or first line of a two-line element set.
  • tle_line2 (str) – The third line of a three-line element set or second line of a two-line element set.
  • object_id (str) – TODO
  • object_number (int, str) – TODO
  • semimajor_axis (float, str) – The semimajor axis in Earth radii. May be a single value or a range.
  • period (float, str) – The orbital period in days. May be single value or a range.
  • apogee (float, str) – The radius when furthest from the Earth. May be a single value or a range.
  • perigee (float, str) – The radius when furthest from the Earth. May be a single value or a range.
Returns:

The result of the query to space-track.org

Raises:
  • IndexError – if no keyword arguments are provided
  • KeyError – if any provided key is not in the expected argument list

Module contents

Module for making queries to space-track.org.

The main entry point of the module is the SpaceTrackClient class. To start, create an instance of the SpaceTrackClient passing your username and password for space-track.org. You can sign up for a free account at space-track.org.

import spacetracktool as st
client = SpaceTrackClient('username', 'password')

Any query class defined in the space-track.org API is implemented as a method of this client, but not all classes have been tested as of yet. If you find problems, please open an issue on the project’s GitHub page or submit a pull request.