Loading...
  OR  Zero-K Name:    Password:   

Zero-K API ?

13 posts, 1019 views
Post comment
Filter:    Player:  
sort
2 years ago
Hi,

I'am searching an API for zero-k to search for example the grade of a user.

Thanks.
+0 / -0

2 years ago
There is no proper API. Scrape stuff off website pages.
+0 / -0
chaplol
I'd be interested in building something simple and secure like this on top of the ZK database if there's interest. Probably just a flask server.
+3 / -0

2 years ago
An API would be a great way to encourage innovation and contributions.
+0 / -0


2 years ago
I'd love that.
+0 / -0
2 years ago
Lets do it, should only take a weekend. how do we get access to database schema, can we get a read only user created? We could even use pre-made APIs like https://postgrest.org/en/stable/ or https://hasura.io/
+0 / -0
2 years ago
We can host it for free on https://fly.io/ (3x 256mb RAM VMs for free monthly)
+0 / -0
I know that if you follow the instructions on the wiki for setting up the infrastructure, it will create an empty copy of the database (with the requisite tables) for you. You might also poke around in https://github.com/ZeroK-RTS/Zero-K-Infrastructure/tree/master/ZkData to see the interface between the database and the C# code. This file is probably most useful.

Obviously to have a useful API it needs to connect to the live server in some way, but this might help you get started.
+0 / -0
chaplol
2 years ago
Looks like the server is MSSQL 2019. So, PostgREST won't work but hasura will work basically straight out of the box (Just, please no graphql..). Hasura is basically just a dbms client with tooling attached, so we don't necessarily need to figure out the schema beforehand.

Once connected to the prod db, we'd then just expose API-relevant data over API.

The big challenge, depending on the ZK Dev's threat model, is that hasura will need a read-only user that has certain sensitive tables blacklisted, just so they're not exposed through Hasura just so that me nor Killingtime or whoever works on this, can steal those tables.

Aquanim -- is that something you'd be comfortable with? AFAIK, we'd just need a read-only user, preferably with credential/moderator tables blacklisted.
+1 / -0

2 years ago
quote:
Aquanim -- is that something you'd be comfortable with?

That's a question you will have to ask Licho.
+0 / -0
2 years ago
If you are interested in scrapped stuff you can find a sqlite database here: http://zerok-local-analysis.s3-website.eu-west-3.amazonaws.com/data/zk.db.gz (the one that backs this stats website http://zerok-local-analysis.s3-website.eu-west-3.amazonaws.com/release2022-07-07-01/, see http://zero-k.info/Forum/Thread/34840?page=1&Search=&User=&grorder=&grdesc=False&grpage=1)

I did not yet save the rating, I could do that as well if there is interest. If you want them you can easily do a get on the page "http://zero-k.info/Charts/Ratings?RatingCategory=1&UserId=<user of interest>" and look for the data.

For me, most interesting statistics will overwhelm the server and see no easy way to restrict that. We could get a database export regularly (and compute the statistics in our own environments), but the database export would have same info as the scrapping above, without any server change. That's why I did a javascript based solution in which you do all computation locally (downside: you need to download the data, but I have data split per year, so if you want just last year will be smaller, plus browser should cache it so you do it only once).

+1 / -0
chaplol
2 years ago
That's really cool, I didn't realize you had it all in sqlite now! Downloaded, but not sure if I'll have time to poke around it for a week or so :(

I messaged Licho -- he said: "hello i will make a proper api, another option is to run app on zk server"

So that's cool.
+0 / -0
2 years ago
I think some computations (ex: recomputing WHR/trying other rating algorithms/big summarizations over large periods of time) should not be done on the server. A regular database export would be nice and more "scalable" (downloading once a week a large file might be easier than installing an application on the ZK server)
+1 / -0