Elma Online API 2.0

Advertise your levels, contests, sites etc.

Moderator: Moporators

Post Reply
User avatar
Kopaka
39mins club
Posts: 6610
Joined: 23 May 2002, 13:59
Team: LAME
Location: In a northern danish city beating YOUR record.
Contact:

Elma Online API 2.0

Post by Kopaka »

Part of the old EOL API was disabled a while ago due to it being slow and potentially slowing down other parts of EOL, so I have been working on a new version. This is now ready with support for times from a level. In regards to what data you can get it's exactly the same as the old, except now 'all' works again, meaning you can get all times in a level not just PR's. But hehind the scenes the code should be much faster and it will be easier for me to add more later. You can also choose to get the data as json now. There's a new url, but the old one will redirect, so there shouldn't be any need to update old scripts if you don't want to.

I'm planning to add more kinds of data as demand requires it. So if there is anything you would like to see don't hesistate to let me know. Anything you can think of from EOL. But preferably things that can come to everyone's benefit somehow. I'm hoping that with some improved API support, we can open up for more uses of all the data we have in EOL, with various people making fancy pants things with the data for everyone's use. Also if there's anything about how the data is presented in the json/xml that is bad, let me know.


Level times
Get times driven in a specific level.
http://elmaonline.net/API/times/X
X is the id of the level. Find the id by finding the level on elmaonline.net and look at last part of the URL (ex http://elmaonline.net/statistics/level/8950). Use a comma seperated list for multiple levels.

Parameters
Add a parameter by adding ? and the name of the parameter at the end of the url, followed by = and the value you want to search. If you add more than one use & instead of ? for any subsequent parameters.

bestall
Show only PR's or all times driven in the level.
default: best
Values: best, all

startindex
Show only times with an Index higher than this. Can be used for reading only times newer than last time you read for example.
default: 0
Values: integer

kuski
Show only times from this Kuski. Can be Kuski ID or name.
default:
Values: integer or string

noorder
Don't order times by lowest time.
default: false
Values: true, false

timeformat
Which time format to show. str for a string something like 00:00,00, hs for an integer showing amount of hundreds of seconds.
default: str
Values: str, hs

xml
Select if you want xml or json format. json is default and shown when this is 0 or not set. XML will be shown when this is 1.
default: 0
Values: 1, 0

Examples
All PR's in TKT01.lev
http://elmaonline.net/API/times/709

All Kopaka's times in TKT01.lev with Index above 1 million, no ordering and hundreds time format:
http://elmaonline.net/API/times/709?bestall=all&startindex=1000000&kuski=Kopaka&noorder=true%timeformat=hs


Battle results
Get results of a battle.
http://elmaonline.net/API/battle/X
X is the id of the battle. Find the id by finding the battle on elmaonline.net and look at last part of the URL (ex http://elmaonline.net/statistics/battles/8950).

Parameters
Add a parameter by adding ? and the name of the parameter at the end of the url, followed by = and the value you want to search. If you add more than one use & instead of ? for any subsequent parameters.

xml
Select if you want xml or json format. json is default and shown when this is false.
default: false
Values: true, false

timeformat
Which time format to show. str for a string something like 00:00,00, hs for an integer showing amount of hundreds of seconds.
default: str
Values: str, hs

Examples
Results from battle in 1L256.lev
http://elmaonline.net/API/battle/107044

Results from battle in NewFF960.lev, results will be ordered as per the battle type, apple results showed as such etc.
http://elmaonline.net/API/battle/107034


Player info
Get info about a player.
http://elmaonline.net/API/player/X
X is the id of the player. Find the id by finding the palyer on elmaonline.net and look at last part of the URL (ex http://elmaonline.net/players/Lousku), or the KuskiIndex you get from the level times and battle results API calls. JSON only.

Parameters
None.

Examples
Get info about Lousku.
http://elmaonline.net/API/player/10


Battle info
Get info about a battle.
http://elmaonline.net/API/battleinfo/X
X is the id of the battle. Find the id by finding the battle on elmaonline.net and look at last part of the URL (ex http://elmaonline.net/statistics/battles/8950). JSON only.

Parameters
None.

Examples
Get info about battle in citron46.lev
http://elmaonline.net/API/battleinfo/107046



Level info
Get info about a level.
http://elmaonline.net/API/level/X
X is the id of the level. Find the id by finding the level on elmaonline.net and look at last part of the URL (ex http://elmaonline.net/statistics/level/118633). JSON only.

Parameters
None.

Examples
Get info about level TKTII01.lev
http://elmaonline.net/API/level/118633


Limitations and error handling
You can not get info, results, or times from battles or levels from battles that are currently in queue, aborted, in progress or locked. It will give an error result a kind to: {"error":"October 18 2011 23:01. Battle is on going, wait for it to be finished."}


Legacy code
For anyone still using the old eol_api_class.php from the old version you will need a new version. Just updating this and old code should still work. Don't use this if you're making something new.
http://kopasite.net/up/1/eol_api_class.zip
Last edited by Kopaka on 18 Oct 2017, 17:17, edited 5 times in total.
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Re: Elma Online API 2.0

Post by skint0r »

ty json and all it :*
maybe limit parameter would be good, would maybe save 0.00000000000001% process power and also little bandwidth if not need to get all times for a level.
make levelid take a list as parameter and return keyed object or such.

e.g. if i wanted only best times for levels with id 100 and 483, http://elmaonline.net/API/times/100,483?limit=1
Prestigious member of 14.6x Tutor14 club
User avatar
Ismo
39mins club
Posts: 114
Joined: 28 Mar 2005, 18:16

Re: Elma Online API 2.0

Post by Ismo »

Check my post from next gen server topic:

http://mopolauta.moposite.com/viewtopic ... 95#p245489
[00:21:58] (@cyre) ismo taas juonu liikaa omenamehuu
User avatar
Kopaka
39mins club
Posts: 6610
Joined: 23 May 2002, 13:59
Team: LAME
Location: In a northern danish city beating YOUR record.
Contact:

Re: Elma Online API 2.0

Post by Kopaka »

skint0r wrote:make levelid take a list as parameter and return keyed object or such.
Added that, with comma seperated list like you wrote. Had the same in old version and moposite needed that. In the json it adds an extra depth with level id as key.
User avatar
Zweq
34mins club
Posts: 4055
Joined: 28 Nov 2002, 15:54
Location: suo mesta

Re: Elma Online API 2.0

Post by Zweq »

pos add chat? cuz http://elmaonline.net/chat seems dead. I just want all nekit chat data from last 6 years for own pervert use :D
Image
Kazan
34mins club
Posts: 484
Joined: 10 Jan 2006, 17:12
Location: Russia, Miass

Re: Elma Online API 2.0

Post by Kazan »

i want chat too. it was very useful
User avatar
Madness
35mins club
Posts: 2168
Joined: 1 Jan 2009, 10:51
Location: UK

Re: Elma Online API 2.0

Post by Madness »

It would be great if there was a link for overall times in battle levels. Not just overall battle times, but overall (all) times.
Image
User avatar
ville_j
Kuski
Posts: 1506
Joined: 17 Aug 2002, 15:45
Team: IS
Location: on the roof
Contact:

Re: Elma Online API 2.0

Post by ville_j »

If I am not mistaken it's not possible to limit results to include only times that were driven during a battle. So would be nice to be able to get results by battle id too.
< roopemies> horror and frustrating and can't play, sounds just like you
Beer battle winner 2014 and 2015
User avatar
ville_j
Kuski
Posts: 1506
Joined: 17 Aug 2002, 15:45
Team: IS
Location: on the roof
Contact:

Re: Elma Online API 2.0

Post by ville_j »

Also I noticed if you use bestall=all you'll get an additional property "datetime", which probably tells the datetime when the time was driven. With bestall=best this property is not returned at all, is this a bug or intended behavior?
< roopemies> horror and frustrating and can't play, sounds just like you
Beer battle winner 2014 and 2015
User avatar
Kopaka
39mins club
Posts: 6610
Joined: 23 May 2002, 13:59
Team: LAME
Location: In a northern danish city beating YOUR record.
Contact:

Re: Elma Online API 2.0

Post by Kopaka »

ville_j wrote:Also I noticed if you use bestall=all you'll get an additional property "datetime", which probably tells the datetime when the time was driven. With bestall=best this property is not returned at all, is this a bug or intended behavior?
They read from two different tables and the best table doesn't have the datetime data. Can add data about which battle if any a time belongs to, but again only from all table.
User avatar
ville_j
Kuski
Posts: 1506
Joined: 17 Aug 2002, 15:45
Team: IS
Location: on the roof
Contact:

Re: Elma Online API 2.0

Post by ville_j »

Okay, well if that is the most efficient way to add the data, then oke ty.
< roopemies> horror and frustrating and can't play, sounds just like you
Beer battle winner 2014 and 2015
User avatar
Kopaka
39mins club
Posts: 6610
Joined: 23 May 2002, 13:59
Team: LAME
Location: In a northern danish city beating YOUR record.
Contact:

Re: Elma Online API 2.0

Post by Kopaka »

Did an update today. Added battle results, player info, level info and battle info calls. Check first post for documentation.
User avatar
pawq
38mins club
Posts: 6547
Joined: 24 Aug 2008, 19:56
Team: TR
Location: Southampton, UK

Re: Elma Online API 2.0

Post by pawq »

This is amazing! I've actually spent quite a few hours recently trying to figure out how to draw data from the eol site, with the answer laying at my fingertips! I'll try to figure out how to use it over the next couple of days and I'll post here if I have any issues/suggestions, but it looks like most of the useful features are covered already :)

Great job Kopaka, thanks so much! :)
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Re: Elma Online API 2.0

Post by niN »

Kopaka wrote:Did an update today. Added battle results, player info, level info and battle info calls. Check first post for documentation.
Epic! Allows for all sorts of statsmaking now!
Team HotHorses, and I'm converting to Icelandian now...
User avatar
pawq
38mins club
Posts: 6547
Joined: 24 Aug 2008, 19:56
Team: TR
Location: Southampton, UK

Re: Elma Online API 2.0

Post by pawq »

niN wrote:
Kopaka wrote:Did an update today. Added battle results, player info, level info and battle info calls. Check first post for documentation.
Epic! Allows for all sorts of statsmaking now!
Yes!!! I'm so excited :D
User avatar
Zweq
34mins club
Posts: 4055
Joined: 28 Nov 2002, 15:54
Location: suo mesta

Re: Elma Online API 2.0

Post by Zweq »

nice stuf :), I have a few problems though:
- Getting additional kuski info programmatically starting from lev index seems impsy. Times api should provide kuski_id for each time result
- Times API returns 200 status (OK), but no results for some levs, when bestall=all is supplied. I noticed this happening for at least warm up(id 2) and uphill battle. Is there going to be a fix for this? "stopindex" parameter would make it possible to get results in slices, if there is some problem with too many results.
Image
User avatar
Kopaka
39mins club
Posts: 6610
Joined: 23 May 2002, 13:59
Team: LAME
Location: In a northern danish city beating YOUR record.
Contact:

Re: Elma Online API 2.0

Post by Kopaka »

kuskiindex added to results and changed the hard limit to 25k times so it doesn't run out a memory.
User avatar
Zweq
34mins club
Posts: 4055
Joined: 28 Nov 2002, 15:54
Location: suo mesta

Re: Elma Online API 2.0

Post by Zweq »

thank you very much :) one more thing that I noticed: There is a lot of overhead when querying for single kuski data.

I have logic like this:

Code: Select all

  timesData = get from eol api for lev 123
  for timeData in timesData:
    kuski = get kuski from my own database with time->kuskiindex
    if kuski was not in my own database yet:
      kuskiData = get kuski data from eol API
      kuski = create new kuski in my own database with kuskiData
    finally, create time entry in my own database with timeData, and link it to kuski
Now the thing is that before I have most of the kuskis saved, there is a lot of traffic back and forth to elma api. Of course there is no problem after I have added a couple of levs and acquired data for most of kuskis, it's just that few first additions feel unnecessarily slow due to the traffic

My suggestion is that it should be possible to query data for all kuskis in one API call. And the results should contain the kuskis id (the same one as in time api results). Then when querying for times api data, linking kuskis and times would be a breeze, without the need for acquiring kuskidata. Or alternatively just add kuski team and nat in the time results.

This is not a big problem of course... and mostly not my problem :P
Image
User avatar
Zweq
34mins club
Posts: 4055
Joined: 28 Nov 2002, 15:54
Location: suo mesta

Re: Elma Online API 2.0

Post by Zweq »

Getting level data based on filename string could be bueno. For example http://elmaonline.net/API/level?pattern=ALP gets all levels with ALP in filename maby with mysql "like". Dunno how well would work just an idee. Sure would get GALPS and HALPS and stuf and also there would be problem with train levs and duplicates, but would still be an enhancement. Mans can do additional filtering on the response data in their own code.
Image
User avatar
Zweq
34mins club
Posts: 4055
Joined: 28 Nov 2002, 15:54
Location: suo mesta

Re: Elma Online API 2.0

Post by Zweq »

After playing around quite a bit with the API imo there are 2 clear improvements.

1. Possibility to get up to 25 000 Level results on a single request (in same fashion as with times API)
2. Possibility to get up to 25 000 Kuski results on a single request (in same fashion as with times API)

Would be win-win for both users of the API and server.

Haven't played around at all with battle stuff so no comment on those
Image
User avatar
Zweq
34mins club
Posts: 4055
Joined: 28 Nov 2002, 15:54
Location: suo mesta

Re: Elma Online API 2.0

Post by Zweq »

Some more points:
- The only way to find out creator of lev is to build a database of every balle and get designer kuski id from there if the lev was balled. Battle api could have a level id parameter to get the battles for that level if any exist or alternatively have level api directly tell the kuski id of the designer, if no balles for that level then it could be 0 (if i got it right there is no way of telling who added lev to database if there are no battles for it?)
- Handling duplicate levels is quite mongo but i dont know if there is any good solution to that. One thing i thought about was to use amount of finishes as indicator.
Image
User avatar
Zweq
34mins club
Posts: 4055
Joined: 28 Nov 2002, 15:54
Location: suo mesta

Re: Elma Online API 2.0

Post by Zweq »

Also I think there should be API endpoints for levelpacks. One endpoint for list of levelpacks with some basic data like levpack id, name, description, whatever and another endpoint for getting a list of levels for given level pack, with same data per level as what level API returns.
Image
User avatar
Zweq
34mins club
Posts: 4055
Joined: 28 Nov 2002, 15:54
Location: suo mesta

Re: Elma Online API 2.0

Post by Zweq »

Times API should include what was kuski's team when the time was driven.
Image
User avatar
Kopaka
39mins club
Posts: 6610
Joined: 23 May 2002, 13:59
Team: LAME
Location: In a northern danish city beating YOUR record.
Contact:

Re: Elma Online API 2.0

Post by Kopaka »

Zweq wrote:Times API should include what was kuski's team when the time was driven.
Added team and nation to times api.

You've mentioned a lot of other things. Possible to give them some priorities or something? Which is most important to help you out.
User avatar
Zweq
34mins club
Posts: 4055
Joined: 28 Nov 2002, 15:54
Location: suo mesta

Re: Elma Online API 2.0

Post by Zweq »

Thanks m8

I don't remember what I wanted earlier and impsy to understand own text. I guess priority would be smth like this:

1. Level API 25000 results at a time with 'startindex' input. Fields can be same gak as they are now when getting one level. Would bring populating levels to own db down from 1 day to 1 minute
2a. Get all levels for a given levelpack id. (or name if not orka make 2b). Fields same again. Would clean up my extremely dirty and volatile workaround
2b. List all levelpacks with id, name, description.
3. Kuski API all kuskis in one query. Same fields as single result. Low priority because getting data for 2000~ kuskis is not too bad
Image
User avatar
Kopaka
39mins club
Posts: 6610
Joined: 23 May 2002, 13:59
Team: LAME
Location: In a northern danish city beating YOUR record.
Contact:

Re: Elma Online API 2.0

Post by Kopaka »

1. Level API 25000 results at a time with 'startindex' input. Fields can be same gak as they are now when getting one level. Would bring populating levels to own db down from 1 day to 1 minute
http://elmaonline.net/API/levels/
http://elmaonline.net/API/levels/0LP
http://elmaonline.net/API/levels/?startindex=345634

2a. Get all levels for a given levelpack id. (or name if not orka make 2b). Fields same again. Would clean up my extremely dirty and volatile workaround
http://elmaonline.net/API/levelpacklevels/byId/1
http://elmaonline.net/API/levelpacklevels/byName/nomb
User avatar
Zweq
34mins club
Posts: 4055
Joined: 28 Nov 2002, 15:54
Location: suo mesta

Re: Elma Online API 2.0

Post by Zweq »

this is very helpful, thank you so much for taking the time and adding these endpoints. :*
Image
User avatar
Kopaka
39mins club
Posts: 6610
Joined: 23 May 2002, 13:59
Team: LAME
Location: In a northern danish city beating YOUR record.
Contact:

Re: Elma Online API 2.0

Post by Kopaka »

Is anyone still using this api?

If no one is or you don't speak up I may just take it down since everything should already be available in the new one, just not documented. If you are feel free to contact me and hopefully we can get you migrated to the new one.
Post Reply