anazawa / metakgs.org

Unofficial JSON API for KGS Go Server
https://metakgs.org/
6 stars 0 forks source link

Add "queries" attribute to /api/archives body #4

Closed anazawa closed 9 years ago

anazawa commented 9 years ago

The KGS archives provides the yearly calendar which includes all the possible queries, the year and month combinations:

/gameArchives.jsp?user=foo&year=2015&month=1 /gameArchives.jsp?user=foo&year=2014&month=12 ...

The above list allows us to know which page is the next page, the previous page, and so on. In other words, the list indicates the link relations between the search result.

To indicate the above relations, the "link" attribute exists in /api/archives body:

"link": {
    "first": "/api/archives/foo/2014/8",
    "prev": "/api/archives/foo/2014/11",
    "next": "/api/archives/foo/2015/1",
    "last": "/api/archives/foo"
}

You can get the URI of the previous page (link.prev), etc., from the above JSON object.

The problem is you can not know which query (year & month combination) corresponds to the specific URI, keeping MetaKGS URIs opaque. Though you can parse the URI to get the year & month pair using regular expressions, (I believe) that's not a good API design. That's why "queries" attribute should exist in /api/archives body:

"queries": [
    {
        "user": "foo",
        "year": 2014,
        "month": 8,
        "url": "/api/archives/foo/2014/8"
    },
    {
        "user": "foo",
        "year": 2014,
        "month": 9,
        "url": "/api/archives/foo/2014/9"
    }
]

The "link" attribute can be always derived from the "queries" attributes, and not vice versa.

NOTE: I'm not saying the "link" attribute should be deprecated, but the "queries" attributes should be simply added to /api/archives body.

anazawa commented 9 years ago

Patch anazawa/metakgs.org@bc165e32ce148df39bdba30d798785b6c9fd23dd

anazawa commented 9 years ago

Merged to "develop" branch.