OpenXbox.XboxWebApi 0.2.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package OpenXbox.XboxWebApi --version 0.2.5
NuGet\Install-Package OpenXbox.XboxWebApi -Version 0.2.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OpenXbox.XboxWebApi" Version="0.2.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OpenXbox.XboxWebApi --version 0.2.5
#r "nuget: OpenXbox.XboxWebApi, 0.2.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install OpenXbox.XboxWebApi as a Cake Addin
#addin nuget:?package=OpenXbox.XboxWebApi&version=0.2.5

// Install OpenXbox.XboxWebApi as a Cake Tool
#tool nuget:?package=OpenXbox.XboxWebApi&version=0.2.5

Xbox WebAPI library for .NET

Build status NuGet Discord

C# Xbox WebAPI, includes support for authentication with Windows Live / Xbox Live.

Usage

Basic authentication flow

using System;
using XboxWebApi.Authentication;
using XboxWebApi.Authentication.Model;

// ...

string requestUrl = AuthenticationService.GetWindowsLiveAuthenticationUrl();

/* Call requestUrl via WebWidget or manually and authenticate */

WindowsLiveResponse response = AuthenticationService.ParseWindowsLiveResponse(
    "<Received Redirection URL>");

AuthenticationService authenticator = new AuthenticationService(response);

if (!authenticator.Authenticate())
    throw new Exception("Authentication failed!");

Console.WriteLine(authenticator.XToken);
Console.WriteLine(authenticator.UserInformation);

Save token to JSON

using System.IO;
using XboxWebApi.Common;

FileStream fs = new FileStream("tokens.json", FileMode.Create);
authenticator.DumpToFile(fs);
fs.Close();

Load token from JSON

using System.IO;
using XboxWebApi.Common;
using XboxWebApi.Authentication;

FileStream fs = new FileStream("tokens.json", FileMode.Open);
AuthenticationService authenticator = AuthenticationService.LoadFromFile(fs);
fs.Close();

Example Api Usage

using System;
using XboxWebApi.Common;
using XboxWebApi.Extensions;
using XboxWebApi.Services;
using XboxWebApi.Services.Api;
using XboxWebApi.Services.Model;

if (!authenticator.XToken.Valid)
{
    Console.WriteLine("Token expired, please refresh / reauthenticate");
    return;
}

XblConfiguration xblConfig = new XblConfiguration(authenticator.XToken, XblLanguage.United_States);

PresenceService presenceService = new PresenceService(xblConfig);
PeopleService peopleService = new PeopleService(xblConfig);
MessageService messageService = new MessageService(xblConfig);
// ... more services

var friends = peopleService.GetFriends();
var presenceBatch = presenceService.GetPresenceBatch(friends.GetXuids());
for (int i=0; i < friends.TotalCount; i++)
{
    Console.WriteLine($"{presenceBatch[i].Xuid} is {presenceBatch[i].State}");
}

Documentation

Not yet, please look at XboxWebApi.Tests for now.

Credits

Informations on endpoints gathered from:

Disclaimer

Xbox, Xbox One, Smartglass and Xbox Live are trademarks of Microsoft Corporation. Team OpenXbox is in no way endorsed by or affiliated with Microsoft Corporation, or any associated subsidiaries, logos or trademarks.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net452 is compatible.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.3.1 2,970 12/29/2020
0.3.0 1,263 8/9/2020
0.2.6 756 8/8/2020
0.2.5 1,508 12/16/2018
0.2.4 1,461 12/2/2018
0.2.3 794 10/27/2018
0.2.2 695 10/26/2018
0.2.1 896 6/8/2018
0.2.0 890 6/7/2018
0.1.0 885 6/3/2018

Add WindowsLiveConstants and add asyncness to authentication