- response are fully-annotated with pydantic
- rest without parsing
$ pip install pornhub-api
or with aiohttp support
$ pip install pornhub-api[aiohttp-backend]
or with httpx support
$ pip install pornhub-api[httpx-backend]
- Python 3.7+
from pornhub_api import PornhubApi
api = PornhubApi()
import asyncio
from pornhub_api.backends.aiohttp import AioHttpBackend
async def execute():
async with AioHttpBackend() as backend:
api = PornhubApi(backend=backend)
video = await api.video.get_by_id("ph560b93077ddae")
print(video.title)
asyncio.run(execute())
videos = api.search_videos.search_videos(
"chechick",
ordering="mostviewed",
period="weekly",
tags=["black"],
)
for vid in videos:
print(vid.title, vid.video_id)
api.stars.all()
or
api.stats.all_detailed()
video = api.video.get_by_id("ph560b93077ddae")
print(video.title)
categories = api.video.categories()
tags = api.video.tags("a")
response = api.video.is_active("ph560b93077ddae")
print(response.is_active)
import random
api = PornhubApi()
tags = random.sample(api.video.tags("f").tags, 5)
category = random.choice(api.video.categories().categories)
result = api.search.search_videos(ordering="mostviewed", tags=tags, category=category)
print(result.size())
for vid in result:
print(vid.title, vid.url)