Mopolauta

Elasto Mania board
It is currently 19 Aug 2017, 04:37

All times are UTC [ DST ]




Post new topic Reply to topic  [ 21 posts ] 
Author Message
 Post subject: Elma Online API 2.0
PostPosted: 3 Jan 2016, 00:05 
Offline
Kuski
User avatar

Joined: 23 May 2002, 13:59
Posts: 6294
Location: In a northern danish city beating YOUR record.
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 false.
default: false
Values: true, false

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

_________________
Kopasite ^ 39 level packs and 1193 levels for your höyling pleasure
LaMe world of Kopa ^ Team LaMe
Elma Online ^ Moposite Records ^ Upload


Last edited by Kopaka on 15 May 2016, 23:47, edited 4 times in total.

Top
 Profile  
 
 Post subject: Re: Elma Online API 2.0
PostPosted: 3 Jan 2016, 12:39 
Offline
Kuski
User avatar

Joined: 16 Jun 2002, 07:36
Posts: 702
Location: Oslo, Norway
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


Top
 Profile  
 
 Post subject: Re: Elma Online API 2.0
PostPosted: 3 Jan 2016, 16:47 
Offline
39mins club
User avatar

Joined: 28 Mar 2005, 18:16
Posts: 110
Check my post from next gen server topic:

viewtopic.php?f=15&t=9395#p245489

_________________
[00:21:58] (@cyre) ismo taas juonu liikaa omenamehuu


Top
 Profile  
 
 Post subject: Re: Elma Online API 2.0
PostPosted: 3 Jan 2016, 17:48 
Offline
Kuski
User avatar

Joined: 23 May 2002, 13:59
Posts: 6294
Location: In a northern danish city beating YOUR record.
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.

_________________
Kopasite ^ 39 level packs and 1193 levels for your höyling pleasure
LaMe world of Kopa ^ Team LaMe
Elma Online ^ Moposite Records ^ Upload


Top
 Profile  
 
 Post subject: Re: Elma Online API 2.0
PostPosted: 14 Jan 2016, 12:48 
Offline
35mins club
User avatar

Joined: 28 Nov 2002, 15:54
Posts: 3693
Location: suo mesta
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


Top
 Profile  
 
 Post subject: Re: Elma Online API 2.0
PostPosted: 14 Jan 2016, 13:27 
Offline
35mins club

Joined: 10 Jan 2006, 17:12
Posts: 430
Location: Russia, Miass
i want chat too. it was very useful


Top
 Profile  
 
 Post subject: Re: Elma Online API 2.0
PostPosted: 14 Jan 2016, 18:50 
Offline
35mins club
User avatar

Joined: 1 Jan 2009, 10:51
Posts: 2070
Location: London, UK
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

Image


Top
 Profile  
 
 Post subject: Re: Elma Online API 2.0
PostPosted: 7 May 2016, 10:35 
Offline
Kuski
User avatar

Joined: 17 Aug 2002, 15:45
Posts: 1502
Location: on the roof
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


Top
 Profile  
 
 Post subject: Re: Elma Online API 2.0
PostPosted: 7 May 2016, 12:07 
Offline
Kuski
User avatar

Joined: 17 Aug 2002, 15:45
Posts: 1502
Location: on the roof
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


Top
 Profile  
 
 Post subject: Re: Elma Online API 2.0
PostPosted: 7 May 2016, 13:07 
Offline
Kuski
User avatar

Joined: 23 May 2002, 13:59
Posts: 6294
Location: In a northern danish city beating YOUR record.
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.

_________________
Kopasite ^ 39 level packs and 1193 levels for your höyling pleasure
LaMe world of Kopa ^ Team LaMe
Elma Online ^ Moposite Records ^ Upload


Top
 Profile  
 
 Post subject: Re: Elma Online API 2.0
PostPosted: 7 May 2016, 13:13 
Offline
Kuski
User avatar

Joined: 17 Aug 2002, 15:45
Posts: 1502
Location: on the roof
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


Top
 Profile  
 
 Post subject: Re: Elma Online API 2.0
PostPosted: 15 May 2016, 23:48 
Offline
Kuski
User avatar

Joined: 23 May 2002, 13:59
Posts: 6294
Location: In a northern danish city beating YOUR record.
Did an update today. Added battle results, player info, level info and battle info calls. Check first post for documentation.

_________________
Kopasite ^ 39 level packs and 1193 levels for your höyling pleasure
LaMe world of Kopa ^ Team LaMe
Elma Online ^ Moposite Records ^ Upload


Top
 Profile  
 
 Post subject: Re: Elma Online API 2.0
PostPosted: 28 May 2016, 12:56 
Offline
Kuski
User avatar

Joined: 24 Aug 2008, 19:56
Posts: 5510
Location: Southampton, UK
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! :)

_________________
Image
Team TR
Multi WR in Labyrinth with GRob
Best Internal Total Times, Pipe stats & Pipe archive
World kuski map, World Cup stats


Top
 Profile  
 
 Post subject: Re: Elma Online API 2.0
PostPosted: 28 May 2016, 13:26 
Offline
Kuski
User avatar

Joined: 22 Aug 2005, 12:23
Posts: 2619
Location: Sweden, Gothemburg
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...


Top
 Profile  
 
 Post subject: Re: Elma Online API 2.0
PostPosted: 29 May 2016, 02:16 
Offline
Kuski
User avatar

Joined: 24 Aug 2008, 19:56
Posts: 5510
Location: Southampton, UK
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

_________________
Image
Team TR
Multi WR in Labyrinth with GRob
Best Internal Total Times, Pipe stats & Pipe archive
World kuski map, World Cup stats


Top
 Profile  
 
 Post subject: Re: Elma Online API 2.0
PostPosted: 9 Jan 2017, 12:19 
Offline
35mins club
User avatar

Joined: 28 Nov 2002, 15:54
Posts: 3693
Location: suo mesta
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


Top
 Profile  
 
 Post subject: Re: Elma Online API 2.0
PostPosted: 14 Jan 2017, 22:36 
Offline
Kuski
User avatar

Joined: 23 May 2002, 13:59
Posts: 6294
Location: In a northern danish city beating YOUR record.
kuskiindex added to results and changed the hard limit to 25k times so it doesn't run out a memory.

_________________
Kopasite ^ 39 level packs and 1193 levels for your höyling pleasure
LaMe world of Kopa ^ Team LaMe
Elma Online ^ Moposite Records ^ Upload


Top
 Profile  
 
 Post subject: Re: Elma Online API 2.0
PostPosted: 15 Jan 2017, 17:14 
Offline
35mins club
User avatar

Joined: 28 Nov 2002, 15:54
Posts: 3693
Location: suo mesta
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:
  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


Top
 Profile  
 
 Post subject: Re: Elma Online API 2.0
PostPosted: 26 Jan 2017, 09:55 
Offline
35mins club
User avatar

Joined: 28 Nov 2002, 15:54
Posts: 3693
Location: suo mesta
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


Top
 Profile  
 
 Post subject: Re: Elma Online API 2.0
PostPosted: 25 Feb 2017, 18:50 
Offline
35mins club
User avatar

Joined: 28 Nov 2002, 15:54
Posts: 3693
Location: suo mesta
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


Top
 Profile  
 
 Post subject: Re: Elma Online API 2.0
PostPosted: 29 Mar 2017, 08:29 
Offline
35mins club
User avatar

Joined: 28 Nov 2002, 15:54
Posts: 3693
Location: suo mesta
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group