"""Example: Demo-API
SDK attribute: ``client.demo``
Endpoints: 9
Usage::
python examples/demo.py
AUTO-GENERATED by scripts/generate_examples.py.
"""
import asyncio
import json
from tikhub import AsyncTikHub
API_KEY = "YOUR_API_KEY"
async def main():
async with AsyncTikHub(api_key=API_KEY) as client:
# GET /api/v1/demo/demo/cache_status
# 查看Demo缓存状态/View Demo Cache Status
result = await client.demo.cache_status()
print(json.dumps(result, indent=2, ensure_ascii=False))
# GET /api/v1/demo/douyin/web/fetch_one_video
# 【Demo】抖音Web获取固定作品数据(1小时缓存)/[Demo] Fetch Douyin Web Fixed Video Data with Cache
result = await client.demo.douyin_web_fetch_one_video()
print(json.dumps(result, indent=2, ensure_ascii=False))
# GET /api/v1/demo/douyin/app/fetch_one_video
# 【Demo】抖音APP获取固定作品数据(1小时缓存)/[Demo] Fetch Douyin APP Fixed Video Data with Cache
result = await client.demo.douyin_app_fetch_one_video()
print(json.dumps(result, indent=2, ensure_ascii=False))
# GET /api/v1/demo/douyin_search/app/general_search
# 【Demo】抖音搜索综合搜索(1小时缓存)/[Demo] Douyin General Search with Cache
result = await client.demo.general_search()
print(json.dumps(result, indent=2, ensure_ascii=False))
# GET /api/v1/demo/kuaishou/web/fetch_one_video
# 【Demo】快手获取固定视频信息(1小时缓存)/[Demo] Kuaishou Fixed Video with Cache
result = await client.demo.kuaishou_web_fetch_one_video()
print(json.dumps(result, indent=2, ensure_ascii=False))
# GET /api/v1/demo/tiktok/web/fetch_user_profile
# 【Demo】TikTok固定用户信息(1小时缓存)/[Demo] TikTok Fixed User Profile with Cache
result = await client.demo.fetch_user_profile()
print(json.dumps(result, indent=2, ensure_ascii=False))
# GET /api/v1/demo/tiktok/app/fetch_one_video
# 【Demo】TikTok APP获取固定视频详情(1小时缓存)/[Demo] TikTok APP Fixed Video Detail with Cache
result = await client.demo.tiktok_app_fetch_one_video()
print(json.dumps(result, indent=2, ensure_ascii=False))
# GET /api/v1/demo/instagram/web/fetch_user_info
# 【Demo】Instagram获取固定用户信息(1小时缓存)/[Demo] Instagram Fixed User Profile with Cache
result = await client.demo.fetch_user_info()
print(json.dumps(result, indent=2, ensure_ascii=False))
# GET /api/v1/demo/wechat/article_extract
# 【Demo】微信公众号文章提取(1小时缓存)/[Demo] WeChat Article Extract with Cache
result = await client.demo.article_extract()
print(json.dumps(result, indent=2, ensure_ascii=False))
if __name__ == "__main__":
asyncio.run(main())