Skip to main content

Unofficial api for pornhub.com

https://travis-ci.org/derfirm/pornhub-api.svg?branch=master https://api.codacy.com/project/badge/Grade/72b5baaa2a7d438cbe725924954a62b2 https://img.shields.io/pypi/v/pornhub-api.svg

Key Features

  • response are fully-annotated with pydantic

  • rest without parsing

Installing

$ pip install pornhub-api

or with aiohttp support

$ pip install pornhub-api[aiohttp-backend]

or with httpx support

$ pip install pornhub-api[httpx-backend]

Supported versions

  • Python 3.7+

Getting started

Initiate Api client

from pornhub_api import PornhubApi

api = PornhubApi()

Initiate with AioHttp backend

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())

Search Videos

videos = api.search_videos.search_videos(
    "chechick",
    ordering="mostviewed",
    period="weekly",
    tags=["black"],
)
for vid in videos:
    print(vid.title, vid.video_id)

Get Stars

api.stars.all()
or
api.stats.all_detailed()

Get single Video details

video = api.video.get_by_id("ph560b93077ddae")
print(video.title)

Get all videos tags or categories

categories = api.video.categories()
tags = api.video.tags("a")

Check Video availability

response = api.video.is_active("ph560b93077ddae")
print(response.is_active)

Search video by random tag and category

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)

Metadata

Release files for pornhub-api 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pornhub-api 0.4.0
File Size Uploaded Provenance
pornhub_api-0.4.0.tar.gz 8.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pornhub-api 0.4.0
File Interpreter ABI Platform
pornhub_api-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.5 kB

Release files / pornhub_api-0.4.0.tar.gz

Download URL pornhub_api-0.4.0.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d6455ba4cd0a13af597a69e127af9b27c381259289208e0d59d3b19ec452a6e0
BLAKE2b-256 checksum
How to use checksums
dcb92540d9264d7fc726e877c69cff2f94b420a287c1b6d3bbb403a6f4e17265
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.6 Darwin/24.1.0

Release files / pornhub_api-0.4.0-py3-none-any.whl

Download URL pornhub_api-0.4.0-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d5ff8df1f43c867d771bc88bc428b3e50a3d48a3d45999502eda32bea51335b9
BLAKE2b-256 checksum
How to use checksums
0d3600d9278dfbb3a7de313f57221aa1a35f8fb8b19d158348f391c3c2fcd5d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.6 Darwin/24.1.0

Security for pornhub-api 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page