GW2SDK 1.0.0-preview.5

This is a prerelease version of GW2SDK.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package GW2SDK --version 1.0.0-preview.5
NuGet\Install-Package GW2SDK -Version 1.0.0-preview.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="GW2SDK" Version="1.0.0-preview.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GW2SDK --version 1.0.0-preview.5
#r "nuget: GW2SDK, 1.0.0-preview.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 GW2SDK as a Cake Addin
#addin nuget:?package=GW2SDK&version=1.0.0-preview.5&prerelease

// Install GW2SDK as a Cake Tool
#tool nuget:?package=GW2SDK&version=1.0.0-preview.5&prerelease

About

GW2SDK provides classes for interacting with the Guild Wars 2 API and game client. This package enables you to fetch information about the game, the player's account, PvP seasons, WvW matches and the in-game economy. It also provides realtime information from the game client such as the player's current character and the current map.

Key features

  • Gw2Client provides access to the Guild Wars 2 API
  • GameLink provides realtime information from the game client (Windows only)

How to use

How to use the Gw2Client to fetch the current prices of all tradable items in the game:

using System;
using System.Net.Http;
using GuildWars2;
using GuildWars2.Commerce.Prices;
using GuildWars2.Items;

using var httpClient = new HttpClient();
var gw2 = new Gw2Client(httpClient);

PrintHeader();
await foreach (ItemPrice itemPrice in gw2.Commerce.GetItemPricesBulk())
{
    Item item = await gw2.Items.GetItemById(itemPrice.Id);
    PrintRow(item.Name, itemPrice.BestBid, itemPrice.BestAsk);
}

void PrintHeader()
{
    Console.WriteLine(new string('=', 160));
    Console.WriteLine($"| {"Item",-50} | {"Highest buyer",-50} | {"Lowest seller",-50} |");
    Console.WriteLine(new string('=', 160));
}

void PrintRow(string item, Coin highestBuyer, Coin lowestSeller)
{
    Console.WriteLine($"| {item,-50} | {highestBuyer,-50} | {lowestSeller,-50} |");
}

How to use the GameLink to print the player's name and current map to the console:

using GuildWars2;
using GuildWars2.Exploration.Maps;

if (!GameLink.IsSupported())
{
    Console.WriteLine("GameLink is only supported on Windows!");
    return;
}

var refreshInterval = TimeSpan.FromSeconds(1);
using var gameLink = GameLink.Open(refreshInterval);

// The game link provides the ID of your current map,
// which you can use to look up the map name from the API
// (Pre-fetch all maps to avoid making too many requests)
var maps = await GetMaps();

gameLink.Subscribe(
    tick =>
    {
        var player = tick.GetIdentity();
        if (player != null)
        {
            var map = maps.Single(map => map.Id == player.MapId);

            Console.WriteLine($"[{tick.UiTick}] Your name is {player.Name}.");
            Console.WriteLine($"[{tick.UiTick}] You are currently in {map.Name} ({tick.Context.ServerAddress}).");
            Console.WriteLine();
        }
    });

WaitForCtrlC();

async Task<HashSet<MapSummary>> GetMaps()
{
    using var http = new HttpClient();
    var gw2 = new Gw2Client(http);
    return await gw2.Maps.GetMapSummaries();
}

void WaitForCtrlC()
{
    using var exitEvent = new ManualResetEventSlim();
    Console.CancelKeyPress += (_, _) => exitEvent.Set();
    exitEvent.Wait();
}

Additional documentation

Feedback & contributing

GW2SDK is released as open source under the MIT license. You are welcome to create an issue if you find something is missing or broken, or a discussion for other feedback, questions or ideas. Check out the GitHub page to find more ways to contribute.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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 net461 was computed.  net462 is compatible.  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.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-rc.2 0 4/6/2024
1.0.0-rc.1 0 3/30/2024
1.0.0-preview.15 0 3/25/2024
1.0.0-preview.14 1 3/25/2024
1.0.0-preview.13 0 2/18/2024
1.0.0-preview.12 1 12/11/2023
1.0.0-preview.11 1 12/5/2023
1.0.0-preview.10 1 11/12/2023
1.0.0-preview.9 1 11/5/2023
1.0.0-preview.8 1 11/4/2023
1.0.0-preview.7 1 10/30/2023
1.0.0-preview.6 1 10/29/2023
1.0.0-preview.5 2 10/28/2023
1.0.0-preview.4 1 10/23/2023
1.0.0-preview.3 2 10/21/2023
1.0.0-preview.2 3 10/18/2023
1.0.0-preview.1 0 10/15/2023