SpaceTrack Client
This project is a Java client for querying space data (satellites, two-line element sets, etc.) from the Space-Track.org REST API. It uses builder objects to construct queries and automatically deserializes the results into convenient data model objects.
Getting Started
Prerequisites
SpaceTrack Client requires Java 8+ and uses SLF4J for logging.
Installation
To include SpaceTrack Client in a Maven project, add the following dependency:
<dependencies>
...
<dependency>
<groupId>com.stevenpaligo</groupId>
<artifactId>spacetrack-client</artifactId>
<version>${spacetrack-client.version}</version>
</dependency>
...
</dependencies>
For non-Maven projects, download the JAR from Maven's Central Repository. The list of dependencies can be found in the pom.xml file (see the source on GitHub)
Usage
The following is a quick "Hello World" example of querying data. The example queries the Satellite Catalog (a.k.a. SatCat) for the International Space Station's data and prints out its apogee height.
/*
Define the credentials for the service call. SpaceTrack Client includes the `DefaultCredentialProvider`
class which takes and stores the credentials as simple strings. If a different implementation is
required (e.g. store an encrypted password), just implement the `CredentialProvider` interface and pass
that to the query instead. The implementation can be anything as long as it can provide the credentials
as they should be passed to Space-Track.org.
*/
CredentialProvider credentials = new DefaultCredentialProvider("user", "password");
/*
Query for the International Space Station's satellite record (catalog number 25544). Start by
instantiating the query class that represents Space-Track.org's "request class" (SatCatQuery, TleQuery,
etc.). Next, set the credential object on the query. Then set any predicates, limits, sorting, etc. that
define how the query functions. In this example, the query is searching for the satellite whose catalog
number is equal to 25544. Finally, call the `execute()` method to run the query and return results as
deserialized data model objects.
*/
List<SatCat> results = new SatCatQuery().setCredentials(credentials)
.addPredicate(new Equal<>(SatCatQueryField.CATALOG_NUMBER, 25544)).execute();
/*
Print out the apogee height
*/
SatCat internationalSpaceStation = results.get(0);
if (internationalSpaceStation.getApogeeHeightKilometers().isPresent()) {
long apogeeHeightKm = internationalSpaceStation.getApogeeHeightKilometers().get();
System.out.println("The International Space Station's apogee height is: " + apogeeHeightKm + " km");
} else {
System.out.println("The International Space Station's apogee height is: unknown");
}
See the JavaDoc for more information.
Contributions
Contributions (bug reports, feature requests, etc.) are always welcome and should be coordinated through the GitHub Issues system.
Authors
- Steven Paligo - stevenpaligo.com
See also the list of contributors who participated in this project.
License
This project is licensed under the Apache License Version 2.0. See the license file file for details.