lichess-org / api

Lichess API documentation and examples
https://lichess.org/api
GNU Affero General Public License v3.0
417 stars 140 forks source link

`/api/player/autocomplete` Autocomplete endpoint with `?object=true` is returning a non-documented key #231

Closed alexrintt closed 1 year ago

alexrintt commented 1 year ago

Source: https://lichess.org/api#tag/Users/operation/apiPlayerAutocomplete.

When hitting the endpoint /api/player/autocomplete with object=false the server response is a simple array of string, as documented:

object: false returns an array of username.

[
  "alexr",
  "alexr7",
  "alexr9",
  "alexr1",
  "alexra",
  "alexrb",
  "alexrc",
  "alexr3",
  "alexrf",
  "alexrd",
  "alexr4",
  "alexr0"
]

cURL:

curl --request GET --url "https://lichess.org/api/player/autocomplete?term=alexr"

But when hitting this same endpoint with object=true the server response is following the schema:

{
  "results": [
    { ...userobj },
    { ...userobj },
    { ...userobj },
  ]
}

This is not what the documentation says:

object: true returns an array of user objects {id,name,title,patron,online}.

The sample schema also does not include this "results" key:

[
  {
    "name": "Chess-Network",
    "title": "NM",
    "patron": true,
    "id": "chess-network",
    "online": true
  }
]

cURL:

curl --request GET --url "https://lichess.org/api/player/autocomplete?term=alexr&object=true"

I'm pretty new to this API though, maybe I'm missing an important piece of information related to search endpoints.

niklasf commented 1 year ago

Thanks for reporting. Fixed the docs.