I am trying to access the https://wikidata.reconci.link/
reconciliation API through a Python script. I found a Python script here as an example. By looking at it and the Reconcilliation Service example for a reconciliation query, I assembled this minimal Python script:
import requests
import json
http = requests.Session()
reconciliation_endpoint = 'https://wikidata.reconci.link/en/api'
query_string = '''{
"queries": [
{
"query": "Christel Hanewinckel",
"type": "Q5",
"limit": 5,
"type_strict": "should"
}
]
}'''
response = http.post(reconciliation_endpoint, data=json.loads(query_string))
print(json.dumps(response.json(), indent=2))
Using this script I got an error message from the server:
{
"arguments": {
"lang": "en",
"queries": "query"
},
"details": "Expecting value: line 1 column 1 (char 0)",
"message": "invalid query",
"status": "error"
}
I am getting an API response, so an incorrect API URL doesn’t seem to be the problem (although the API doesn’t seem to follow the protocol specification, which says that the route should be /reconcile
rather than /api
). Based on the error message, the problem doesn’t seem to be a malformed query. Rather, the API seems to not be seeing the query JSON that I am posting. I didn’t see anything in the documentation about any particular required Content-Type headers or authorization being required. So I am mystified as to why it doesn’t work. I can get the other functions that are defined in the service definition (/suggest
, /preview
, etc.) to work, just not the reconcile function.