Created
June 20, 2025 09:51
-
-
Save odysseus0/23ec48167372a3bd33efe180b21fccb6 to your computer and use it in GitHub Desktop.
Test alternative HTTP clients - aiohttp verification
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
#!/usr/bin/env python3 | |
import asyncio | |
import aiohttp | |
import json | |
async def test_tikapi_aiohttp(): | |
"""Test TikAPI using aiohttp instead of httpx.""" | |
print("🧪 Testing TikAPI with aiohttp...") | |
url = "https://api.tikapi.io/public/video" | |
params = {"id": "7003402629929913605"} | |
headers = { | |
"X-API-KEY": "YOUR_TIKAPI_KEY_HERE", | |
"Accept": "application/json", | |
"User-Agent": "aiohttp-test/1.0" | |
} | |
try: | |
timeout = aiohttp.ClientTimeout(total=30) | |
async with aiohttp.ClientSession(timeout=timeout) as session: | |
async with session.get(url, params=params, headers=headers) as response: | |
response.raise_for_status() | |
data = await response.json() | |
print(f"✅ aiohttp worked! Status: {data.get('status')}") | |
return True | |
except Exception as e: | |
print(f"❌ aiohttp failed: {type(e).__name__}: {e}") | |
return False | |
if __name__ == "__main__": | |
asyncio.run(test_tikapi_aiohttp()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment