1 # File defines functions for making api calls to find translations and transliterations for key terms.
6 from defaults import user_agent
8 def get_wikidata_api():
9 session = mwapi.Session(host="https://wikidata.org/w/api.php", user_agent=user_agent)
12 def search_wikidata(session, term, *args, **kwargs):
13 search_results = session.get(action='query',
16 # srqiprofile='popular_inclinks_pv',
23 query = search_results.get('query', None)
24 results = query.get('search', None)
27 raise mwapi.session.APIError(f"No results for query: {term}")
31 def run_sparql_query(q):
32 results = requests.get("https://query.wikidata.org/bigdata/namespace/wdq/sparql",params={"format":"json","query":q})