Request for example code for "beginners"?

Request for example code for "beginners"?

in API Development

Posted by: Samuraiken.9581

Samuraiken.9581

I typically develop in C# and ASP.NET (lately, in the MVC 4 framework), and am only just getting started with jQuery, JSON, and using Ajax. That being said, I have done some work back in the day with a couple of very minor addons for Warhammer Online and one for World of Warcraft (mainly just recording chat, parsing it for a string, and then sounding a chime). Going through the API that is now available in GW2, I would like to get started in it, but am not sure where to start.

Could someone please lend their expertise and advise, or even throw up a small example of how to utilize the information that’s been given to us?

Thanks, and sorry for any inconveniences.

Request for example code for "beginners"?

in API Development

Posted by: smiley.1438

smiley.1438

There is already a huge list providing implementations for several languages where you can read through over here: https://forum-en.gw2archive.eu/forum/community/api/API-implementation-library-master-list/2068146

Anyway, the most common steps are:

  • send a HTTP GET request to the url of the desired API
  • recieve the response
  • parse the response JSON
  • use the data

Milage may vary between programming languages. You may also want to cache the data which you receive from several requests like e.g. the world names to reduce the amount of requests you send since they’re static anyway.

(edited by smiley.1438)

Request for example code for "beginners"?

in API Development

Posted by: Ruhrpottpatriot.7293

Ruhrpottpatriot.7293

As you are developing in C#/Asp.Net you could use GW2.NET to have wrapper around the API.
Why reinvent the wheel if you can get one for free

Administrator of GW2.NET: GitHub , Forum , NuGet

Request for example code for "beginners"?

in API Development

Posted by: Healix.5819

Healix.5819

Why reinvent the wheel if you can get one for free

Because it’s fun and since I specifically tailored my wheel, it has a perfect fit. There’s no point in having snow tires if it’ll never snow.

(smaller, faster and more efficient)

For a beginner, don’t just use wrappers, learn from them. Don’t skip the basics, which will include reinventing the wheel. For example, if I ask a javascript developer how to get a JSON response and their only answer is getJSON(), they’ve failed.

Request for example code for "beginners"?

in API Development

Posted by: Dr Ishmael.9685

Dr Ishmael.9685

Why reinvent the wheel if you can get one for free

Because it’s fun

That’s exactly why I wrote my Perl module, even though everyone else uses PHP or Python for script-monkeying these days.

Request for example code for "beginners"?

in API Development

Posted by: steckums.9108

steckums.9108

I would recommend using GW2.Net or GwSharp’s API and break it apart. Look into it, write console applications that display the information you want. Modify the API to display information in a different way.

A pretty nice exercise for myself was to take GW2Stuff’s overlay source code and change it to display WvW information using GwSharp. Nice crash course on how to deal with information and threads.

Request for example code for "beginners"?

in API Development

Posted by: Snowreap.5174

Snowreap.5174

keep in mind, the API is for building external applications or websites that pull data from the GW2 databases. it’s not for for making in-game addons.

-ken

The Purge [PURG] – Ehmry Bay

Request for example code for "beginners"?

in API Development

Posted by: Ruhrpottpatriot.7293

Ruhrpottpatriot.7293

That’s exactly why I wrote my Perl module,

Well that’s something different. If I’d code in C# and there are only c++ wrapper around I’d write something for myself. That’s not reinventing the wheel.

On the other hand if there are already five c# implementations out there I’d probably grab one of those, since it’s far less time consuming.

@Steckums: GW2.Net also has an WvW implementation (and I might add a more complete one)

Administrator of GW2.NET: GitHub , Forum , NuGet

Request for example code for "beginners"?

in API Development

Posted by: DarkSpirit.7046

DarkSpirit.7046

Yes I agree with Ruhrpottpatriot, I would recommend using a well-tested library if development time is a factor.

But if you are doing this for your own edification and you want to learn technologies like JSON.NET or RestSharp, etc. which could be transferable to other similar projects, then I would agree with Healix and recommend that you learn from existing libraries to implement your own library.

(edited by DarkSpirit.7046)

Request for example code for "beginners"?

in API Development

Posted by: Ruhrpottpatriot.7293

Ruhrpottpatriot.7293

yeah if you want to learn something then it’s better to write your own implementation

Administrator of GW2.NET: GitHub , Forum , NuGet

Request for example code for "beginners"?

in API Development

Posted by: Samuraiken.9581

Samuraiken.9581

I"m not even sure how to use a wrapper, but I see your point ;-) I’m going to start messing with it tomorrow evening and will hopefully be able to make something simple. Thanks for the advice, everyone!

Request for example code for "beginners"?

in API Development

Posted by: Snowreap.5174

Snowreap.5174

If you don’t want to use any wrappers,, have a look at this:
https://forum-en.gw2archive.eu/forum/community/api/Simple-C-Example-Rating-Calculation

It’s C#, it doesn’t use any wrappers or libraries except what .NET 2.0 comes with, and it has been updated with more comments to make it a little bit more beginner-friendly.

If nothing else, it will show you the basic mechanism to invoke the API and process the results.

-ken

The Purge [PURG] – Ehmry Bay

Request for example code for "beginners"?

in API Development

Posted by: Blumoon.5437

Blumoon.5437

If you’re new to API programming, I highly recommend this list of free courses on Codecademy. I learned most of what I know about interacting with APIs through JavaScript from those courses. Highly recommended if you’re just starting out!