This project is read-only.

If you're having problems accessing members because of naming restriction, read "Known Caveats" below.

API Test Tools and Test API. Read Release Notes Please!

If you like this API check out my Diablo 3 Media Library with Lookup features! 

D3API.Net 

D3API.Net is a lightweight and easy to use .Net wrapper for Blizzard's Web API.

What does it provide?

D3API.Net provides all the functionality of the web API, except that the data is deserialized from JSON into an object. This allows you to navigate API requests just like if you were navigating a regular object. 

Simple Example:

using D3APIdotNet;

...

D3API api = new D3API(HostName.en_US);

...

var careerProfile = api.getCareerProfile("Battletag#0000");

string firstHeroName = careerProfile.heroes[0].name;

If you refer to the Career Profile Example, firstHeroName would have the value of "Yharr".

How does it work?

D3API.Net accesses the web API through HttpWebRequests which return the JSON data. From here, the JSON is deserialized by JavaScriptSerializer into a DynamicJsonObject, which is an extension of DynamicObject, by definition of a DynamicJsonConverter. The DynamicJsonObject uses IDictionary<string, object> to store the Identifier and an object, which will primarily be a DynamicJsonObject, List<object>, or simply an object. When you make a call to a specific object in the DynamicJsonObject, this invokes DynamicObject.TryGetMember() and through overriding this method DyanmicJsonObject can, for lack of better words, sort through the internal IDictionary<string, object> to try and return the correct value. If the identifier(s) are incorrect, the value returned will be null.

Know Caveats (and how to work around them)

 Invalid Identifiers:

If you are familiar with Blizzard's Diablo 3 Web API documentation, you may wonder how to access some of the members that are identified by invalid characters.

Since this issue exists there is an implementation that checks all identifiers and replaces all invalid characters with an underscore ( _ ).

For example, if you were to attempt to access "last-updated", which is a Field of a Hero in the Career Profile, you would not be able to because there is a dash ( - ) in the identifier. So to access this Field, you must substitute the dash for an underscore. In result, the new identifier would be "last_updated".

 Keyword Identifier:

To use a keyword in C# as an identifier all you must do is force the literal. Simply place "@" in front of the keyword and it will treat it like it isn't a keyword. For example, to access the member "class" of the "hero" class, all you must do is "hero.@class".

Conclusion

 D3API.Net allows .Net developers to easily access Blizzard's Diablo 3 Web API without all the hassle of getting, deserializing, and handling the data returned, it's just there.

Suggestions:

I love suggestions, fresh ideas, alternative ways, what ever you may call it. I would absolutely LOVE to hear YOUR ideas! After all this project is dedicated to everyone who uses it! Please either contact me or if you would like to make it publicly open (credit ego seekers ;] ) just post it in the Discussions Tab.

 

 

 


Last edited Jan 12, 2014 at 10:54 AM by ChrisCaruso, version 30