AplikaceAplikace
Nastavení

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:manualy:api [2022/12/22 13:43] michalkrenen:manualy:api [2022/12/29 19:11] (current) – [API] michalkren
Line 1: Line 1:
 ====== API ====== ====== API ======
  
-It is possible to query selected applications via an [[https://en.wikipedia.org/wiki/API|API]]. API access requires user authentication at all times, which holds also for applications where this would not be necessary for their use via the standard user web interface. For the authentication, personal access tokens should be used.+Selected applications can be queried via an [[https://en.wikipedia.org/wiki/API|API]]. API access requires user authentication at all times, which holds also for applications where this would not be necessary for their use via the standard user web interface. For the authentication, personal access tokens should be used.
  
 ===== Getting your personal access token ===== ===== Getting your personal access token =====
Line 18: Line 18:
  
 <WRAP tip important 60%> <WRAP tip important 60%>
-Every application has an API tailored to its needs. Individual API usage **manuals**:+Individual API usage manuals:
   * [[https://github.com/czcorpus/kontext/wiki/HTTP-API|KonText]]   * [[https://github.com/czcorpus/kontext/wiki/HTTP-API|KonText]]
   * [[https://wiki.korpus.cz/doku.php/manualy:treq:api|Treq]]   * [[https://wiki.korpus.cz/doku.php/manualy:treq:api|Treq]]
 </WRAP> </WRAP>
 +
 +The APIs can be queried at the following URLs:
 +  * KonText: ''https://korpus.cz/kontext-api/v0.17''
 +  * Treq: ''https://treq.korpus.cz/api/v1''
  
 <WRAP round important 60%> <WRAP round important 60%>
Line 99: Line 103:
         "async": False         "async": False
     }     }
-    r = s.post('https://korpus.cz/kontext/query_submit', params={'format': 'json'}, json=request_body)+    r = s.post('https://korpus.cz/kontext-api/v0.17/query_submit', params={'format': 'json'}, json=request_body)
     response_json = r.json()     response_json = r.json()
     print(response_json)     print(response_json)
Line 105: Line 109:
     # Displaying a concordance     # Displaying a concordance
     conc_persistence_op_id = response_json['conc_persistence_op_id']     conc_persistence_op_id = response_json['conc_persistence_op_id']
-    r = s.get('https://korpus.cz/kontext/view', params={'format': 'json', 'q': '~'+conc_persistence_op_id})+    r = s.get('https://korpus.cz/kontext-api/v0.17/view', params={'format': 'json', 'q': '~'+conc_persistence_op_id})
     print(r.json())     print(r.json())