# OnlyFans API SDKs for TypeScript, Python, PHP & Ruby

> Build creator products with official, production-ready SDKs for Python, TypeScript, PHP, and Ruby. Pick your stack and make your first request in minutes.

Every SDK wraps the same REST API (base URL `https://app.onlyfansapi.com/api/{account}/...`, 290+ endpoints) with the conventions of its language. Authenticate with the `ONLYFANSAPI_API_KEY` environment variable or pass the key to the client constructor.

## Choose the SDK that fits your stack

| Language | Install | Runtime | Page | Source |
| --- | --- | --- | --- | --- |
| TypeScript | `npm install @onlyfansapi/onlyfans-sdk` | Node.js, Deno, Bun | https://onlyfansapi.com/sdk/typescript | https://github.com/onlyfansapi/onlyfansapi-typescript-sdk |
| Python | `pip install onlyfans` | Python 3.9+, sync & async | https://onlyfansapi.com/sdk/python | https://github.com/onlyfansapi/onlyfansapi-python |
| PHP | `composer require onlyfansapi/onlyfansapi-php` | PHP 8.1+ | https://onlyfansapi.com/sdk/php | https://github.com/onlyfansapi/onlyfansapi-php |
| Ruby | `bundle add onlyfans --version "~> 0.2.0"` | Ruby 3.2+ | https://onlyfansapi.com/sdk/ruby | https://github.com/onlyfansapi/onlyfansapi-ruby |

- **Python** — Typed sync and async clients for Python 3.9+.
- **TypeScript** — First-class TypeScript types for modern Node.js.
- **PHP** — Named parameters and value objects for PHP 8.1+.
- **Ruby** — Thread-safe client gem with connection pooling and RBS/RBI types.

## What teams build with the OnlyFans API

- **Analytics Dashboards** — Bring account and performance data into reporting experiences your team can act on.
- **Media Workflows** — Build upload flows around familiar file, stream, and byte-based objects.
- **Internal Automation** — Connect recurring account operations to your own backend jobs and business logic.
- **Multi-account Tools** — Create focused interfaces for teams working across multiple connected accounts.
- **Reporting Pipelines** — Move structured API responses into warehouses, spreadsheets, and custom reports.
- **Custom Integrations** — Extend the typed client with custom requests when your product needs more flexibility.

## The details that matter after your first request

Resilient networking and predictable behavior are built into every client, so production code stays focused on your product.

- **Automatic Retries** — Recover from temporary connection, rate-limit, and server failures. Connection errors, timeouts, 429s, and 5xx responses are retried twice with exponential backoff.
- **Structured Errors** — Handle authentication, validation, rate-limit, and server errors separately.
- **Environment Authentication** — Keep credentials out of source control using the `ONLYFANSAPI_API_KEY` environment variable.
- **Configurable Timeouts** — Set client-wide defaults and override behavior for individual calls.

## Questions before you start

### Does OnlyFans have an official public API?

OnlyFans itself does not offer a public developer API. OnlyFansAPI is an independent platform that provides reliable API access to OnlyFans accounts, with official SDKs for TypeScript, Python, PHP, and Ruby.

### How do I authenticate?

Set the `ONLYFANSAPI_API_KEY` environment variable or pass your API key when creating the client. Environment-based configuration keeps credentials out of source control.

### Does the SDK include request and response types?

Yes. Each SDK follows the conventions of its language and includes structured request and response models: TypeScript definitions, Python TypedDicts and Pydantic models, PHP value objects, and Ruby RBS/RBI types.

### What happens when a request fails?

Failed requests raise a typed error you can catch — authentication, rate-limit, validation, connection, and server errors separately. Connection errors, timeouts, 429s, and 5xx responses are retried twice automatically with exponential backoff.

### Can I upload files?

Yes. Every SDK supports media uploads from file paths, streams, or raw contents in the forms native to its language.

### Can I call an endpoint that is not documented yet?

Yes. Every SDK supports custom requests to undocumented endpoints and parameters while keeping authentication and retries.

## Links

- Get your API key: https://app.onlyfansapi.com/register
- API reference: https://docs.onlyfansapi.com/api-reference/overview
- OpenAPI spec: https://app.onlyfansapi.com/scribe-docs/openapi.json
- Pricing: https://onlyfansapi.com/pricing