PyScript - Telraam API GET Request

This webpage fetches data from the Telraam API using a GET request with your personal API token.

It uses pyfetch wrapper from pyodide in order to have an async request. Remember to import asyncio and await for the response...we are in asyincland in the browser!

Overall, I believe Pyscript is very cool! :-)

async def fetch_data(): from pyodide.http import pyfetch import asyncio api_token = 'cFYQE43jXY3MQXi74Qzy0aJE6eCslQ8Q5TBxYdIP' url = 'https://telraam-api.net/v1' headers = {'Authorization': f'Bearer {api_token}'} response = await pyfetch(url=url, method="GET", headers=headers) response_text = await response.text() status = f"Request status: {response.status}" text = f"Response text: {response_text}" pyscript.write('request_status', status) pyscript.write('request_text', text) asyncio.create_task(fetch_data())