API Introduction - czcorpus/kontext GitHub Wiki
HTTP API / Introduction
This text contains both general API documentation for any KonText installation and also a specific installation run by the Institute of the Czech National Corpus (CNC).
The CNC KonText API instance
There are few differences from a general KonText installation:
- all the API actions/endpoints require the client to be registered and logged in (this is mostly due to the nature of provided data)
- there is no need to add URL query parameter
format=json
to get a JSON response in case of actions providing also an HTML output - all the queries are archived so it is always possible to return to an old result set (for older queries, KonText must recalculate data first, so the result access is not instantaneous in such case)
How to authenticate
To use the CNC KonText instance, a user must be registered and create a "Personal Access Token" on user's profile page. Using the token, a session can be created (here, we store the value to the session_cookies.txt
file):
curl -X POST -F 'personal_access_token=....token.value...' -c session_cookies.txt https://www.korpus.cz/login
Then, an API request can be made:
curl -b session_cookies.txt "https://www.korpus.cz/kontext-api/v0.17/query?corpname=syn2020"