⚠ Please note, this SDK is still in very active development, features may be added and removed, although I will try and keep on top of using proper semantic versioning. ⚠
This is a C# library to enable developers to interact with the United States Strategic Command Space Tracker (space-track.org).
This documentation will be updated with more detail as functionality is added to the project.
As with most C# packages, install it through Nuget via your IDE or the CLI.
dotnet add <csproj> package SpaceTrackSdk
It is also available as a package from the Github Image Repo.
By default the SDK handles the fetching of an authentication cookie for you and automatically refreshes it when it expires.
However, for this to work, you need to provide the SpaceTrackSdkOptions
to the DI container.
This can be done in two ways:
- Add the appropriate section to your
appsettings.config
(and then make sure you don't commit sensitive information to your repo):
{
"SpaceTrackSdkOptions": {
"Password": "myPass",
"Username": "myUsername",
"ApiUrl": "https://space-track.org",
"AuthEndpoint": "ajaxauth/login"
}
}
- Set the following environment variables:
SpaceTrackSdkOptions__Password="myPass"
SpaceTrackSdkOptions__Username="myUsername"
SpaceTrackSdkOptions__ApiUrl="https://space-track.org"
SpaceTrackSdkOptions__AuthEndpoint="ajaxauth/login"
Currently, the SDK is designed in such a way that it plugs in via Microsoft.DependencyInjection
. If there is a big desire for this to change in the future, I might reconsider this.
For now, once you've got your IServiceCollection
, you need to call the extension method services.AddSpaceTrackServices(configuration)
.
From here, you'll be able to resolve or inject the IBasicSpaceDataClient
which gives you access to everything on the BasicSpaceData
API.
ServiceCollection services = new();
services.AddSpaceTrackServices(config);
IServiceProvider provider = services.BuildServiceProvider();
IBasicSpaceDataClient service = provider.GetRequiredService<IBasicSpaceDataClient>();
Fetching data is done through the IBasicSpaceDataClient
interface.
public interface IBasicSpaceDataClient
{
public IClientAdapter<Announcement> Announcements { get; }
public IClientAdapter<BoxScore> BoxScores { get; }
public IClientAdapter<Conjunction> Conjunctions { get; }
public IClientAdapter<Decay> Decays { get; }
public IClientAdapter<GeneralPerturbation> GeneralPerturbations { get; }
public IClientAdapter<GeneralPerturbation> GeneralPerturbationHistory { get; }
public IClientAdapter<LaunchSite> LaunchSites { get; }
public IClientAdapter<SatCatChange> SatCatChanges { get; }
public IClientAdapter<SatCatEntry> SatCatEntries { get; }
public IClientAdapter<SatCatEntry> SatCatDebuts { get; }
public IClientAdapter<TrackingAndImpactPrediction> TrackingAndImpactPredictions { get; }
}
Every endpoint provides an instance of an IClientAdapter<T>
, this is a very simple interfact that allows for you to Get()
or GetMany()
.
public interface IClientAdapter<T>
{
public Task<T?> Get(string predicates = "");
public Task<List<T>?> GetMany(string predicates = "");
}
You can optionally provide a list of pre-formatted predicates such as /limit/5
.
There are plans to add predicate classes and a query builder to the solution in due time.