[API Suggestion] Event Details

[API Suggestion] Event Details

in API Development

Posted by: smiley.1438

smiley.1438

Before i start working with these: please group the events by map_id if possible. (It’s already a pain in the kitteh to write workarounds for getting a poi by id in the maps API. I don’t like workarounds – i like usable data )

(edited by smiley.1438)

[API Suggestion] Event Details

in API Development

Posted by: ozma.3498

ozma.3498

And on the subject of event details, it would be nice to see event_type (so apps can show the correct icon next to the event name without having to scrape the wiki for this information), as well as a flag for whether or not it’s a group event. It would also be nice to have details about which sub-region of the zone the event occurs in, although I’m not confident that this data would be easy to add to the API.

(edited by ozma.3498)

[API Suggestion] Event Details

in API Development

Posted by: rodadams.5963

rodadams.5963

How about adding a “skill_point” flag?

It’s also unclear to me how location is handled for Escort events.
They start in one location, and have an effective radius, but that location migrates as the event progresses. What does the location in the API tell us? start location?

[API Suggestion] Event Details

in API Development

Posted by: Dr Ishmael.9685

Dr Ishmael.9685

@Ozma: The new event_details API has a flag for GroupEvent.

@Rodadams: Location→center is starting location, per the documentation post. The rest of the location→ attributes (→radius for type:“sphere”, →points for type:“poly”, etc.) define the 3D volume around the center within which a character can participate in the event.

[API Suggestion] Event Details

in API Development

Posted by: ozma.3498

ozma.3498

@Ozma: The new event_details API has a flag for GroupEvent.

Nice. :-)

@Rodadams: Location->center is starting location, per the documentation post. The rest of the location-> attributes (->radius for type:“sphere”, ->points for type:“poly”, etc.) define the 3D volume around the center within which a character can participate in the event.

Have you played around with the event coordinates yet? I’m not the most technically gifted web developer, but so far none of the event coordinates I’ve plugged in to the map API have been accurate while the POI/Waypoints etc. work just fine.

Is there some difference we should be aware of in the format of the coordinates in event_details.json as opposed to map_floor.json? Apologies if this has already been covered, but I can’t find it anywhere.

[API Suggestion] Event Details

in API Development

Posted by: zeeZ.5713

zeeZ.5713

Is there some difference we should be aware of in the format of the coordinates in event_details.json as opposed to map_floor.json? Apologies if this has already been covered, but I can’t find it anywhere.

See https://forum-en.gw2archive.eu/forum/community/api/Event-Details-API-location-coordinates/first

[API Suggestion] Event Details

in API Development

Posted by: ozma.3498

ozma.3498

Is there some difference we should be aware of in the format of the coordinates in event_details.json as opposed to map_floor.json? Apologies if this has already been covered, but I can’t find it anywhere.

See https://forum-en.gw2archive.eu/forum/community/api/Event-Details-API-location-coordinates/first

Thanks!

[API Suggestion] Event Details

in API Development

Posted by: Primal Zed.9714

Primal Zed.9714

I also would like to have something to indicate if it’s a skill point.

Also, it’d be great if could have an attribute indicating what an appropriate icon to use for the event would be, like those from this list: http://wiki.guildwars2.com/wiki/Template:Event_icon#Standard_values

[API Suggestion] Event Details

in API Development

Posted by: Eremko.6950

Eremko.6950

Is it just me or do you also see the inconsistency in Event Details API? I mean – why do you even use dynamic keys as event IDs? There is a standard JSON approach in Event Names API (flat array with id keys), why don’t you just use the same approach in Event Details API? I would remove the GUID array completely and make it flat events with event_id inside of each of them … The way it is now it just makes the JSON parsing unnecessarily complicated for libraries like RestSharp.

See attached screenshot for explanation what exactly is on my mind.

Attachments:

(edited by Eremko.6950)

[API Suggestion] Event Details

in API Development

Posted by: Healix.5819

Healix.5819

Is it just me or do you also see the inconsistency in Event Details API?

Some people were complaining about how the events were just in a simple array and wanted them to be referenced by the key instead. Since event_details is an extension to event_names, it makes more sense to have the IDs be the keys, since when you already know the ID, you just look it up, rather than iterating through the entire array to search for it. This makes it easier when using javascript. The obvious downside though, which they’ve already encountered, is duplicate keys (map api), causing data to be lost when parsed.

Not sure what RestSharp does, since I use a custom parser, but with the format of event_details, it should be parsed into something like a dictionary. Getting a specific event should be as easy as dictionary[key].

[API Suggestion] Event Details

in API Development

Posted by: Eremko.6950

Eremko.6950

Since event_details is an extension to event_names, it makes more sense to have the IDs be the keys, since when you already know the ID, you just look it up, rather than iterating through the entire array to search for it.

What makes you think that event_details is an extension to event_names? If it would be like this, it would maybe make (a little) sense, but it’s not the case. There is no event_id argument passable into events_details API. You have to fetch everything and thus event_details is more like “one-time get all event informations and cache it” API. And that’s the argument for my initial post – the API should be the same as event_names. There’s no reason to have dynamic key names in JSON, that’s just miles far away from JSON best practices.

Many libraries for JSON parsing in .NET (RestSharp, JSON.NET) and Java can handle what you say automatically without custom parsers when the JSON API is standardized (my suggested image from post above) and you’ll have an dictionary with <eventID, event> created automatically by those libraries … dynamic keys just makes everything harder to parse, in .NET for example your simplest solution is to use <dynamic> (e.g. var events = RestClient.Execute<dynamic>(new RestRequest(“event_details.json”)).Data[“events”];), but it’s just not that pretty as automatic deserialization into your own POJOs/POCOs.

ANet, please get rid of dynamic keys in (some of) your JSON APIs.

(edited by Eremko.6950)

[API Suggestion] Event Details

in API Development

Posted by: Cliff Spradlin.3512

Cliff Spradlin.3512

Lead Programmer

ANet, please get rid of dynamic keys in (some of) your JSON APIs.

https://forum-en.gw2archive.eu/forum/community/api/API-Request-Results-as-map-id-details/2121379 is the discussion that led to our transition to use dictionaries instead of arrays when it makes sense to do so.

The data format for these events are more suited to be a dictionary than an array, and there should be no downsides to having them presented in this format. In javascript there are definitely no downsides.

A quick look at the RestSharp library seems to show that it supports parsing JSON dictionaries. Am I missing something?

(edited by Cliff Spradlin.3512)

[API Suggestion] Event Details

in API Development

Posted by: Healix.5819

Healix.5819

What makes you think that event_details is an extension to event_names?

From my perspective, that was the starting point, so grabbing the details is something you do after you know what you’re looking for. Starting fresh however, event_details makes event_names redundant, so it’s not really an extension, but the starting point. Just looking at the data though, you can see how event_details adds data on top of event_names, hence, extending it.

Having the array key based really shouldn’t change much for you. Instead of parsing the data into a class such as EventDetails, parse it into a dictionary of <String, EventDetails>. If you wanted EventDetails to also contain the event’s ID, then I could see where you’re now facing the problem of having to go through everything twice, without using a custom deserializer, like what was required in JavaScript.

Example:
rq = new RestRequest(“…event_details.json”);
rq.RootElement = “events”;
details = client.Execute<Dictionary<string, EventDetails>>(rq);

[API Suggestion] Event Details

in API Development

Posted by: ozma.3498

ozma.3498

A couple of requests:

In event_details.json, it would be good to have details on the time between an event being completed and it starting again (including whether or not it is based on its own completion or that of another event – for example, meta events). This would be very useful for making timer-based applications. For example, “cooldown”:“600” for an event that takes 10 minutes to respawn, and “preceded_by”:“event_id” for prerequisite event completions.

In events.json, I’d like to see something to indicate when an event entered its current state. It could be relative (i.e. seconds since last state change), or an actual timestamp using a standard time zone (rather than different time zones for each server). For example, “state_changed”:“1372361374”.

(edited by ozma.3498)

[API Suggestion] Event Details

in API Development

Posted by: Rawrfaec.6412

Rawrfaec.6412

The data format for these events are more suited to be a dictionary than an array, and there should be no downsides to having them presented in this format. In javascript there are definitely no downsides.

It is a considerable inconvenience for static languages. With the current approach, in JavaScript, and probably any dynamic language that can map as easily to JSON, everything works immediately and that’s great for JS applications. However, as a rule, static languages have a much easier time processing an array allowing you to explicitly look up the values of the keys you expect to be there. The reasoning that this data is great for maps/dictionaries is completely sound, it’s just that building that dictionary is a lot more work right now if you’re not using JS and literally no work at all if you are. In contrast the alternative would require the same, small amount of work for all languages, including JS, which, of course, is a minor inconvenience for such applications.

I would definitely change this back for an eventual v2 since building your own dictionary from an array is guaranteed trivial in any language with dictionary support, despite the consequence of a needless (but completely negligible) overhead for JS.

[API Suggestion] Event Details

in API Development

Posted by: Lil Puppy.5216

Lil Puppy.5216

hmmm event_details.json has a root element and event_names.json does not. I approve of rooting things but these json don’t exactly need it. I root all my stuff out of habit but sometimes it’s redundant.

In jquery


$(function(){
	var event_names = [], event_details = {};
	$.getJSON( 'https://api.guildwars2.com/v1/event_details.json', function(data){
		event_details = data;
		console.info('got event_details.json');
		$.getJSON( 'https://api.guildwars2.com/v1/event_names.json', function(data){
			event_names = data;
			console.info( 'got event_names.json' );
			console.log( event_details.events[ event_names[11].id ].name );
			//                                               ^ .events is unnecessary root element
		}).fail(function(jqxhr, textStatus, error){ console.warn( 'failure in event_names.json:\n\t' +error); });
	}).fail(function(jqxhr, textStatus, error){ console.warn('failure in event_details.json:\n\t' +error); });
});

console output: “Defeat the spider king.”

If event_details.json was an array it would pretty much require an iterator if you acquire the entire thing. If you get each event separately you would still have to use it as an array. event_details as a dictionary makes sense.

[API Suggestion] Event Details

in API Development

Posted by: smiley.1438

smiley.1438

Ok, now that i’ve spent some hours on merging the event_details into the map data, please…:

  • order the events by map (see screen) – or even better: merge them into the floor.json
  • recalculate the coordinates so that they match the format given by the texture_dims/continent_rect/clamped_view: X,Y 0 top left (you can then also drop the map_rect in the floor.json)
  • spheres and cylinders? We draw 2D maps unless we’re using Google Maps’ 45° view… so you can safely drop all z data as it is useless overhead
  • the flags seem to be pretty useless right now, i’ve only seen “group_event” so far. It would be better if we knew the exact event type according to the list in the wiki - a key “event_type” would be useful

Thanks in advance

Attachments:

(edited by smiley.1438)