Skip to content

zheng1748/Oddity

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Oddity

GitHub release Build NuGet downloads GitHub issues GitHub stars GitHub license Doxygen

.NET SpaceX API wrapper for https://github.com/r-spacex/SpaceX-API project, providing information about company, rockets and launches. To learn more, you can use Doxygen or directly documentation of the API (method names are very familiar with endpoints):

https://docs.spacexdata.com/

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 built 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:

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.
  • Launchpad - Get brief overview about SpaceX missions.

Example usage

using System;
using System.Threading.Tasks;
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 async Task Main(string[] args)
        {
            var oddity = new OddityCore();

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

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

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

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

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

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

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

            // Get data about all launches of Falcon 9 which has been launched to ISS. Next, sort it ascending
            var launchWithFilters = await oddity.Launches.GetAll()
                .WithRocketName("Falcon 9")
                .WithOrbit(OrbitType.ISS)
                .Ascending()
                .ExecuteAsync();

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

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

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

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

            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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%