Created
July 28, 2025 07:27
-
-
Save companje/96d0901a3fd1b96f9a1a4afd83d77d4a to your computer and use it in GitHub Desktop.
Transkribus Sites Search API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from hua_transkribus import * | |
user = "hetutrechtsarchief" | |
term = "vader" | |
count = get_search_results(user, term) | |
print("Aantal resultaten:",count) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests,json | |
def get_api_base(): | |
return "https://api-sites.transkribus.eu/" | |
def get_request_headers(): | |
return { | |
'accept': 'application/json', | |
'content-type': 'application/json', | |
} | |
def get_collections(user): | |
url = get_api_base() + 'sites/' + user | |
response = requests.get(url, headers=get_request_headers()) | |
json_result = response.json() | |
return json_result["colId"] | |
def get_search_results(user, search_term): | |
response = requests.post( | |
get_api_base() + "search", | |
headers=get_request_headers(), | |
json={ | |
"term": search_term, | |
"collections": get_collections(user), | |
"url": user, | |
"fuzziness": 1, | |
"limit": 10, | |
}) | |
json_result = response.json() | |
print(json.dumps(json_result,indent=2)) | |
return json_result["total"] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment