Using the Library
Assuming you're working in C#, add the appropriate using
statement to reference the library:
Instantiate a WarcraftClient
with the the client ID and client secret that you registered for in the Prerequisites step. For simplicity, these values are stored in the source code in the example below. You should instead use the configuration API for your .NET platform to store the key securely. For example, ASP.NET Core developers should read Configuration in ASP.NET Core.
You can optionally specify the region and locale to use when calling the WarcraftClient
constructor. If you omit these parameters, it will default to Region.US
and "Locale.en_US"
. Each method on WarcraftClient
also has an overload that allows you to override these default values for the current call.
Once you have your WarcraftClient
instance, you can start asking for data. All methods are asynchronous. Here's an example for retrieving a character:
This will retrieve the summary for a character named Drinian from the realm Norgannon.
Each request is wrapped in the RequestResult<T>
class. Which has the following properties.
- Value (The generic type argument)
- Error (RequestError class)
- Code (The HTTP status code)
- Type (The HTTP status code description)
- Detail (The details of why the request failed)
- Success (bool)
A proper method call could look like this.
Take a look at the ArgentPonyWarcraftClient.Tests project and the Blizzard World of Warcraft Game Data and Profile APIs documentation to learn more about what else you can do.