Hello,
This is related to the humble beginnings of my project at http://racetam.com/lzproblems/ where I generate random whole-board “go problems” taken from games on OGS (in a way inspired by the lichess.org puzzles).
Basically I want to retrieve games/lists of games according to certain parameters. I am not a web developer and so I’m very confused about how this is supposed to work. These questions are related to the /api/v1/games/
address:
- Where can I find the “logic” of the retrieval query parameters documented properly?
- For example: are there other non-field query parameters other than
ordering
that can be used? Is there some support for including logic or simple expressions?- … and what are all those
__isnull
,__gt
, etc. Where are they all documented. I know they are on Django’s QuerySet page, but I assume that is documentation for the backend developers (you), not for someone like me who just wants to build a query URL. Because there are discrepancies, for example:- I couldn’t get
name__contains=...
to work, yetname__icontains=...
works. Why?
name__contains=X
=> “Game has no field named contains” (confusing error message)
name__icontains=X
=> { … games with x in title … }- How do I do a “not-equals” match, for example
outcome__notequals=Timeout
.- Is there expression support, can I somehow “split” the
outcome
field so I can match on the points alone (let’s say I want a list of games that were won by >20 points).
Basically I want to know how much of my logic can be offloaded into query parameters without having to do my own filtering/transforms after requesting/downloading dozens and dozens of pages…
- How do I filter by “sub-object” properties, something like players.white.ratings.overall.rating for example? I tried various things like
players.white.ratings.overall.rating__gt=...
andplayers__white__ratings__overall__rating__gt=...
but couldn’t make it work. I am failing to understand how this actually works.
players__white__ratings__overall__rating__gt=100
=> “Player has no field named ‘overall’” (?? did it do some foreign key look-up here?)
-
[motivation for (2)] Why are the fields X_player_rank (and X_player_rating) sometimes just 0 in the game object, yet for players that are not 30 kyu. Inside the players.X sub-objects they do seem to actually have proper ratings/ranks.
-
Is there a way to get the result in a random order? I want a “random selection” of games given certain parameters. I tried
ordering=random
andordering=?
but neither seemed to work. -
Are foreign key filtering supposed to work or not? Playing around with wanting to get a list of games with specific tournament settings I noticed I could quite easily get the server to hang and produce a “there is an unknown connection issue between Cloudflare and the origin web server” page… For example by using a filter such as
tournament__board_size=19
-
The one question to trump all the previous ones: is there a simple way to just get the entire list of games without having to step through tens/hundreds/thousands of “pages”? I suppose then I could just download that and do my own N different kinds of filtering/logic… But I’d hate to do that when each of those are going to turn into god knows how many requests because it’s all paginated…
-
[related to above] …and then what happens if new games matching my query is added to the database while I’m on page=7 of some query… Does everything get shifted down/up depending on where the new game appeared in the list?
Thanks.