Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: Dota 2 Web API SDK - C#

  1. #1
    Basic Member
    Join Date
    Dec 2012
    Posts
    7

    Dota 2 Web API SDK - C#

    Hi everyone.

    I made a simple SDK to handle requests from the WebAPI. You can download the DLLs here : https://bitbucket.org/nsgocev/dota2webapisdk/downloads

    Because I am too lazy to upload anything in the wiki (I will in the future if there is interest in the community) you need to do a several things after you include the DLLs.

    You need to add the following in your app.config or web.config

    <configSections>
    <section name="Dota2SDKConfiguration" type="Dota2WebAPISDK.Configuration.Dota2SDKSetting s,
    Dota2WebAPISDK" />
    </configSections>

    <Dota2SDKConfiguration
    APIKey="yourKeyGoesHere"
    UseXMLEngine="true"
    ></Dota2SDKConfiguration>

    UseXMLEngine is used to managed in which data format the api will handle the requests. If you want to use JSON don`t set it or set it to false.

    Here is a sample on how to get all heroes

    using (Dota2WebAPISDK.Engines.WebAPISDKEngine engine = new Dota2WebAPISDK.Engines.WebAPISDKEngine())
    {
    Dota2WebAPISDK.ApiObjects.Heroes.Heroes heroes = engine.GetHeroes();
    }

    I also want to say that it is not fully tested and I will appreciate any feedback and bug reports. Also I am open for ideas on what things to add in the future.

    I want to thank MuppetMaster42 for his web api guide - http://dev.dota2.com/showthread.php?t=58317 - (and for the nice descriptions I stole if you mind please tell me and I will try to come with something from myself


    Waiting for you feedback
    Last edited by nsgocev; 03-16-2013 at 06:08 AM.

  2. #2
    Basic Member GelioS's Avatar
    Join Date
    Aug 2012
    Posts
    130
    First download is my

    Nice lib! But maybe you should do more examples of usage (just as big ReadMe file with basic things that user should know)?
    Last edited by GelioS; 03-16-2013 at 04:35 AM.

    DotA 2 Web API Processing with PHP
    DotA2 Statistic - Professional leagues statistic
    follow @dota2statistic

  3. #3
    Basic Member
    Join Date
    Dec 2012
    Posts
    7
    Quote Originally Posted by GelioS View Post
    First download is my

    Nice lib! But maybe you should do more examples of usage (just as big ReadMe file with basic things that user should know)?
    Well if there is enough interest I will fill the wiki in bitbucket, along with some example on the usage. As for the methods most of them are self descriptive and there are summaries on what exactly the method does. Also all calls are the same as in this minor example I provided. Everything should cover all the possible calls to the API

  4. #4
    Basic Member Netshroud's Avatar
    Join Date
    Dec 2011
    Posts
    166
    https://bitbucket.org/nsgocev/dota2w...t=master#cl-73 - you're deserializing the entire object, reserializing most of it, and then deserializing that again.

    You'd be better off creating an APIResult<T> generic with a property 'T Result' and deserializing the original JSON as that instead.

  5. #5
    Basic Member
    Join Date
    Dec 2012
    Posts
    7
    Quote Originally Posted by Netshroud View Post
    https://bitbucket.org/nsgocev/dota2w...t=master#cl-73 - you're deserializing the entire object, reserializing most of it, and then deserializing that again.

    You'd be better off creating an APIResult<T> generic with a property 'T Result' and deserializing the original JSON as that instead.
    Hei Netshroud thanks for the feedback. But taking in mind the current state of the JSON.Net lib I wasn`t able to find a way to use the same entities for JSON processing. The problem is that there is a result object that holds everything and and there is no equivalent of [XmlRoot] for json processing. Also according to my unit test app - the process is not very time or memory consuming as it seems

  6. #6
    Basic Member GelioS's Avatar
    Join Date
    Aug 2012
    Posts
    130
    As for the methods most of them are self descriptive and there are summaries on what exactly the method does.
    With my code I thought the same, BUT most users don't want to read all of your code (which contains in the many files) - they want one entry point with full description (or not full, but with most basic knowledge).

    DotA 2 Web API Processing with PHP
    DotA2 Statistic - Professional leagues statistic
    follow @dota2statistic

  7. #7
    Basic Member Netshroud's Avatar
    Join Date
    Dec 2011
    Posts
    166
    Quote Originally Posted by nsgocev View Post
    The problem is that there is a result object that holds everything and and there is no equivalent of [XmlRoot] for json processing.
    Here's what I basically did for one of my projects (TF2, but same principle):

    Code:
    	public class APIResult<T>
    	{
    		[JsonProperty("result")]
    		public T Result { get; set; }
    	}
    Code:
    	var result = JsonConvert.DeserializeObject<APIResult<ActualResultTypeHere>>(myJSONStringHere);
    	var innerResult = result.Result;
    	return innerResult;

  8. #8
    Basic Member
    Join Date
    Dec 2012
    Posts
    7
    Quote Originally Posted by Netshroud View Post
    Here's what I basically did for one of my projects (TF2, but same principle):

    Code:
    	public class APIResult<T>
    	{
    		[JsonProperty("result")]
    		public T Result { get; set; }
    	}
    Code:
    	var result = JsonConvert.DeserializeObject<APIResult<ActualResultTypeHere>>(myJSONStringHere);
    	var innerResult = result.Result;
    	return innerResult;
    Yep done the same yesterday after I thinked about your comment it is even in the commit name Thanks a lot .

  9. #9
    Basic Member Netshroud's Avatar
    Join Date
    Dec 2011
    Posts
    166
    If I have some time tomorrow I'll throw a pull request in to save you some code with type checking.

  10. #10
    Basic Member
    Join Date
    Dec 2011
    Posts
    11
    I think this could have been done better; however it's still well written. Proper use of ... well a lot of things ! Great job!
    I might branch this or write my own and just link here.

    I would have created Models so you could easily save the Data to a database and run SQL Queries against it. We can use EntityFramework for this! (Lazy and not optimized but w/e)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •