/Oddity

SpaceX API wrapper for .NET (company, rockets, launches, capsules and more).

Primary LanguageC#Apache License 2.0Apache-2.0

Oddity

GitHub release NuGet downloads GitHub issues GitHub stars GitHub license

SpaceX API wrapper for .NET based on the https://github.com/r-spacex/SpaceX-API project. Method names are very familiar with API endpoints so you can just use API documents:

https://github.com/r-spacex/SpaceX-API/tree/master/docs

Available data overview:

  • company data, history with most important events
  • detailed information about rockets (Falcon 1, Falcon 9, Falcon Heavy, BFR) and capsules (Dragon 1, Dragon 2, crew Dragon)
  • launchpads data
  • launches: latest, next, all past, all upcoming
  • information about the specified cores and capsules
  • Elon's Roadster data

Most of the endpoints contains a lot of filters which are applied on the API side to save bandwidth. Look at the example and wiki for more information.

Minimal requirements

Library is build on .NET Standard 1.1 which contains support for:

  • .NET Framework 4.5 or higher
  • .NET Core 1.0 or higher
  • Mono 4.6 or higher
  • Xamarin.iOS 10.0 or higher
  • Xamarin.Mac 3.0 or higher
  • Xamarin.Android 7.0 or higher
  • Universal Windows Platform 10.0 or higher

External dependencies:

  • Newtonsoft.Json

Installation

or

  • search "Oddity" in Package Manager

or

  • run Install-Package Oddity in the Package Manager Console

Software using Oddity

  • InElonWeTrust - SpaceX Discord bot providing information about launches, notifications and other commands related to SpaceX and Elon Musk.

Example usage

using System;
using Newtonsoft.Json.Serialization;
using Oddity;
using Oddity.API.Builders;
using Oddity.API.Models.Launch.Rocket.SecondStage.Orbit;
using Oddity.API.Models.Rocket;

namespace OverviewApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var oddity = new OddityCore();

            // Optional
            oddity.OnDeserializationError += OddityOnDeserializationError;
            oddity.OnRequestSend += Oddity_OnRequestSend;
            oddity.OnResponseReceive += OddityOnResponseReceive;

            // Get company information
            var company = oddity.Company.GetInfo().Execute();

            // Get all history
            var history = oddity.Company.GetHistory().Execute();

            // Get history from the last two years and ordered descending
            var historyWithFilter = oddity.Company.GetHistory().WithRange(DateTime.Now.AddYears(-2), DateTime.Now).Descending().Execute();

            // Get data about Falcon Heavy
            var falconHeavy = oddity.Rockets.GetAbout(RocketId.FalconHeavy).Execute();

            // Get list of all launchpads
            var allLaunchpads = oddity.Launchpads.GetAll().Execute();

            // Get information about the next launch
            var nextLaunch = oddity.Launches.GetNext().Execute();

            // Get data about all launches of Falcon 9 which has been launched to ISS and landed with success. Next, sort it ascending
            var launchWithFilters = oddity.Launches.GetAll().WithRocketName("Falcon 9").WithOrbit(OrbitType.ISS).WithLandSuccess(true).Ascending().Execute();

            // Get all capsule types
            var capsuleTypes = oddity.Capsules.GetAll().Execute();

            // Get capsule which has been launched 2015-04-14 at 20:10
            var capsuleWithFilters = oddity.DetailedCapsules.GetAll().WithOriginalLaunch(new DateTime(2015, 4, 14, 20, 10, 0)).Execute();

            // Get all cores
            var allCores = oddity.DetailedCores.GetAll().Execute();

            // Get Roadster info
            var roadster = oddity.Roadster.Get().Execute();

            Console.Read();
        }

        private static void OddityOnDeserializationError(object sender, ErrorEventArgs errorEventArgs)
        {
            Console.WriteLine("Something went wrong.");

            // We don't want to stop program, just leave problematic field as null
            errorEventArgs.ErrorContext.Handled = true;
        }

        private static void Oddity_OnRequestSend(object sender, RequestSendEventArgs e)
        {
            Console.WriteLine($"Sending request... URL: {e.Url}");
        }

        private static void OddityOnResponseReceive(object sender, ResponseReceiveEventArgs e)
        {
            Console.WriteLine($"Response received! Status code: {e.StatusCode}");
            Console.WriteLine($"Raw content: {e.Response}");
            Console.WriteLine();
        }
    }
}

Why Oddity?

https://www.youtube.com/watch?v=iYYRH4apXDo