evekb / evedev-kb

EVE Killboard
www.evekb.org
41 stars 22 forks source link

added simple api to pull killmails as json #95

Closed jbs1 closed 5 years ago

jbs1 commented 5 years ago

I added a simple API to be able to pull killmails as jsons using the internal killmail id which is not possible right now afaik. Right now I just have to pull the whole html page of the kill, regex match the esi link from there and requests that, so do requests to two different servers.

I tried to stick as close to zkill/esi format when generating the json.

I just used the pre existing database helpers and did not implement any fancy caching or something. and the api could relatively easily be extended with new routes.

Salvoxia commented 5 years ago

Hi,

once again, thank you for your effort! Good job using the existing classes :)

But could you elaborate on your complete use case for this API?

Let me explain my thinking: I agree that fetching kill information from EDK in jSON format is a valid use case, that EDK currently lacks. What it does have, though, is IDFeed. It already contains a number of filtering arguments to pass, and was written with the same thought in mind, but mimicking the XML API. The IDFeed is primarily used for interchanging kills between multiple EDK installations. Even though the complete kill information is provided, EDK clients with IDFeed version 1.2 and up only extract the external kill ID and the hash and fetch the actual kill from CCP directly. That way, authenticity of kill information is guaranteed. EDK does the same when fetching from zKB.

Since you stick to ESI's kill format, all you provide is IDs, that still need to be resolved by the client using ESI. So my proposal would be to use IDFeed as a base and add two additional modifiers to be passed as GET arguments: one for switching the output to jSON, and the other for only providing the external kill ID and kill hash. That way, stress on the host's database and traffic is minimized, as well as kill information is guaranteed to be accurate and authentic, since the kills themselves are fetched from CCP directly. EDK does currently not store moon IDs and war IDs, so that would be available to the client as well when fetching the actual kill from CCP.

What do you think?

Best Regards, Salvoxia

jbs1 commented 5 years ago

Indeed, that seems like a better idea, extending something existing. I didn't know that this feature existet.

It was also my first idea when throwing this api together, to just extract the id/hash from the kb3_mails-table and then pull from esi. I originally decided against that, because it also entailed two requests: user->edkserver->esi I thought creating the json from the database would be faster tht requesting it from esi. But I would agree the argument of "authenticity of kill info" does outweigh the argument of speed. I will amend the pull requests commit accordingly.

jbs1 commented 5 years ago

@Salvoxia commit has been amended accordingly

jbs1 commented 5 years ago

also extended ajcron in the same pull because it's easier than make a new just for that. still compatible with old format