Skip to content

A C# SDK for United States Strategic Command Space Tracker (space-track.org)

License

Notifications You must be signed in to change notification settings

hughesjs/SpaceTrackSdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Workflow Status GitHub Workflow Status Nuget (with prereleases) GitHub top language GitHub FTB

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


SpaceTrackSdk

Introduction

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.

How To Use

Installation

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.

Authentication and Configuration

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"

Configuring DI

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

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.

About

A C# SDK for United States Strategic Command Space Tracker (space-track.org)

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

 
 
 

Languages