### Install Go SDK Source: https://docs.ofauth.com/sdk/go Install the OFAuth Go SDK using go get. ```bash go get github.com/ofauth-org/onlyfans-sdk-go ``` -------------------------------- ### Quick Start Go Example Source: https://docs.ofauth.com/sdk/go Initialize the client with your API key and make a basic call to the Whoami endpoint. ```go package main import ( "context" "fmt" "log" "github.com/ofauth-org/onlyfans-sdk-go" ) func main() { client := ofauth.NewClient("your-api-key") acc, err := client.Whoami(context.Background()) if err != nil { log.Fatal(err) } fmt.Println(acc.Id, acc.Permissions) } ``` -------------------------------- ### Quick Start with OFAuth C# SDK Source: https://docs.ofauth.com/sdk/csharp Initialize the OFAuth client with your API key and make a basic authenticated request to the /v2/account/whoami endpoint. This example demonstrates how to fetch account information. ```csharp using OFAuth; var client = new OFAuthClient("your-api-key"); var account = await client.GetAsync("/v2/account/whoami"); Console.WriteLine($"{account.Id} {string.Join(", ", account.Permissions)}"); ``` -------------------------------- ### Quick Start: Authenticate and Get User Info Source: https://docs.ofauth.com/sdk/python Initialize the OFAuthClient with your API key and make a basic call to the 'whoami' endpoint to retrieve user ID and permissions. Ensure you have your API key ready. ```python from onlyfans_sdk import OFAuthClient, account client = OFAuthClient(api_key="your-api-key") result = account.whoami(client) print(result["id"], result["permissions"]) ``` -------------------------------- ### JavaScript GET Request Example Source: https://docs.ofauth.com/api-reference/access/proxy Example of making a GET request to the Access Proxy API using JavaScript's fetch API. Requires your API key and a connection ID. ```javascript const response = await fetch('https://api.ofauth.com/v2/access/proxy/users/me', { headers: { 'apikey': 'YOUR_API_KEY', 'x-connection-id': 'conn_abc123' } }); const userData = await response.json(); ``` -------------------------------- ### cURL GET Request Example Source: https://docs.ofauth.com/api-reference/access/proxy Example of making a GET request to the Access Proxy API using cURL. Ensure you replace YOUR_API_KEY and provide a valid x-connection-id. ```bash curl -X GET 'https://api.ofauth.com/v2/access/proxy/users/me' \ -H 'apikey: YOUR_API_KEY' \ -H 'x-connection-id: conn_abc123' ``` -------------------------------- ### Install OFAuth Python SDK Source: https://docs.ofauth.com/sdk/python Install the OFAuth Python SDK using pip. This command installs the necessary package for using the SDK. ```bash pip install onlyfans-sdk ``` -------------------------------- ### Install OFAuth SDK Source: https://docs.ofauth.com/sdk/typescript/quickstart Install the OFAuth SDK for TypeScript using npm. ```bash npm install @ofauth/onlyfans-sdk ``` -------------------------------- ### Complete Example: Find Subscriber and Send Message Source: https://docs.ofauth.com/guides/how-to/send-message A full example demonstrating how to find an active subscriber and send them a welcome message. ```javascript const API_KEY = "YOUR_API_KEY" const CONNECTION_ID = "conn_abc123" const headers = { apikey: API_KEY, "x-connection-id": CONNECTION_ID, "Content-Type": "application/json" } async function sendWelcomeMessage() { // 1. Get recent subscribers const subsResponse = await fetch( "https://api.ofauth.com/v2/access/subscribers?type=active&limit=1", { headers } ) const subscribers = await subsResponse.json() if (subscribers.length === 0) { console.log("No subscribers found") return } const fan = subscribers[0] console.log(`Sending message to ${fan.username}...`) // 2. Send welcome message const msgResponse = await fetch( `https://api.ofauth.com/v2/access/chats/${fan.id}/messages`, { method: "POST", headers, body: JSON.stringify({ text: `Hey ${fan.name}! 👋\n\nThanks so much for subscribing! Let me know if there's anything specific you'd like to see. 💕` }) } ) const message = await msgResponse.json() console.log("Message sent! ID:", message.id) } sendWelcomeMessage() ``` -------------------------------- ### Python GET Request Example Source: https://docs.ofauth.com/api-reference/access/proxy Example of making a GET request to the Access Proxy API using Python's requests library. Include your API key and connection ID in the headers. ```python import requests response = requests.get( 'https://api.ofauth.com/v2/access/proxy/users/me', headers={ 'apikey': 'YOUR_API_KEY', 'x-connection-id': 'conn_abc123' } ) user_data = response.json() ``` -------------------------------- ### Minimal JavaScript Multipart Upload Example Source: https://docs.ofauth.com/guides/how-to/upload-media A comprehensive example demonstrating the entire multi-part upload process, from initialization to completion, using Node.js `fetch`. ```javascript import { readFileSync } from "node:fs" const API_KEY = "YOUR_API_KEY" const CONNECTION_ID = "conn_abc123" const CONTENT_TYPE = "video/mp4" const FILENAME = "video.mp4" const file = readFileSync(FILENAME) const jsonHeaders = { apikey: API_KEY, "x-connection-id": CONNECTION_ID, "Content-Type": "application/json" } const initResponse = await fetch("https://api.ofauth.com/v2/access/uploads/init", { method: "POST", headers: jsonHeaders, body: JSON.stringify({ filename: FILENAME, size: file.length, contentType: CONTENT_TYPE }) }) if (!initResponse.ok) throw new Error(await initResponse.text()) const upload = await initResponse.json() if (upload.uploadType !== "multipart") { throw new Error("This example expects a multipart upload. Use a larger file.") } for (const part of upload.parts) { const chunk = file.subarray(part.byteRange.start, part.byteRange.end + 1) const partResponse = await fetch(part.uploadUrl, { method: "PUT", headers: { apikey: API_KEY, "x-connection-id": CONNECTION_ID, "Content-Type": CONTENT_TYPE }, body: chunk }) if (!partResponse.ok) { throw new Error(`Part ${part.partNumber} failed: ${await partResponse.text()}`) } } const completeResponse = await fetch(upload.completeUrl, { method: "POST", headers: jsonHeaders, body: JSON.stringify({ mediaUploadId: upload.mediaUploadId }) }) if (!completeResponse.ok) throw new Error(await completeResponse.text()) const result = await completeResponse.json() console.log({ mediaItems: [result.mediaUploadId] }) ``` -------------------------------- ### Media Proxy Example Source: https://docs.ofauth.com/introduction/services Example of how media is served through the OFAuth Media Proxy. URLs are automatically transformed to use media.ofauth.com. ```html ``` -------------------------------- ### Install OFAuth Link Embed Library Source: https://docs.ofauth.com/guides/link Install the OFAuth Link embed library using npm for use in your project. This is the first step for the popup flow. ```bash npm install @ofauth/link-embed ``` -------------------------------- ### Install OFAuth TypeScript SDK Source: https://docs.ofauth.com/sdk/typescript Install the OFAuth TypeScript SDK using npm. This command adds the necessary package to your project dependencies. ```bash npm install @ofauth/onlyfans-sdk ``` -------------------------------- ### Sandbox Test Account Examples Source: https://docs.ofauth.com/setup/sandbox Examples of email formats for sandbox test accounts, differentiating between creator/fan and OTP/no OTP scenarios. ```text jane@creator.sandbox.com // Creator without 2FA alex@creator-otp.sandbox.com // Creator with OTP 123456 marco@fan.sandbox.com // Fan without 2FA sasha@fan-otp.sandbox.com // Fan with OTP 123456 ``` -------------------------------- ### Complete Post Creation Workflow with Media Upload Source: https://docs.ofauth.com/guides/how-to/create-post This comprehensive example demonstrates the full workflow: initializing an upload, uploading media, completing the upload, and finally creating a post with the uploaded media. It requires `fs` module for reading files. ```javascript const API_KEY = "YOUR_API_KEY" const CONNECTION_ID = "conn_abc123" const headers = { apikey: API_KEY, "x-connection-id": CONNECTION_ID, "Content-Type": "application/json" } async function createPostWithMedia(imageBuffer, caption) { // Step 1: Initialize upload const initResponse = await fetch("https://api.ofauth.com/v2/access/uploads/init", { method: "POST", headers, body: JSON.stringify({ filename: "photo.jpg", filesize: imageBuffer.length, mimeType: "image/jpeg" }) }) const { mediaUploadId } = await initResponse.json() // Step 2: Upload the file await fetch(`https://api.ofauth.com/v2/access/uploads/${mediaUploadId}`, { method: "PUT", headers: { ...headers, "Content-Type": "image/jpeg" }, body: imageBuffer }) // Step 3: Complete upload const completeResponse = await fetch("https://api.ofauth.com/v2/access/uploads/complete", { method: "POST", headers, body: JSON.stringify({ mediaUploadId }) }) const { media } = await completeResponse.json() console.log("Media uploaded! ID:", media.id) // Step 4: Create post with the uploaded media const postResponse = await fetch("https://api.ofauth.com/v2/access/posts", { method: "POST", headers, body: JSON.stringify({ text: caption, mediaItems: [media.id] }) }) const post = await postResponse.json() console.log("Post created! ID:", post.id) return post } // Usage const imageBuffer = fs.readFileSync("photo.jpg") createPostWithMedia(imageBuffer, "New photo! 📸") ``` -------------------------------- ### Initialize Vault Media Upload Source: https://docs.ofauth.com/api-reference/vault/initialize-vault-media-upload Initiates a media upload process for a vault. This endpoint is used to get the necessary information to start uploading parts of a media file. ```APIDOC ## POST /vaults/{vaultId}/media/uploads ### Description Initializes a media upload for a vault. This endpoint returns an upload ID, upload URL, and other details required to upload parts of a media file. ### Method POST ### Endpoint /vaults/{vaultId}/media/uploads ### Parameters #### Path Parameters - **vaultId** (string) - Required - The ID of the vault to upload media to. #### Request Body - **partNumber** (integer) - Required - The number of the part being uploaded. - **uploadUrl** (string) - Required - The URL to which the part should be uploaded. - **byteRange** (string) - Required - The byte range of the part being uploaded (e.g., "0-1023"). - **mediaUploadId** (string) - Required - The unique identifier for this media upload session. - **uploadType** (string) - Required - The type of upload (e.g., "multipart"). - **totalParts** (integer) - Required - The total number of parts for the entire media file. - **partSize** (integer) - Required - The size of each part in bytes. - **expiresAt** (string) - Required - The expiration timestamp for the upload URL. - **parts** (array) - Required - A list of parts, where each part includes its number, upload URL, and byte range. ### Security - ApiKey: Your OFAuth API key for authenticating requests. - ConnectionId: Requires a connection via the x-connection-id header. ### Response #### Success Response (200) - **mediaUploadId** (string) - The ID of the media upload. - **uploadType** (string) - The type of upload. - **totalParts** (integer) - The total number of parts. - **partSize** (integer) - The size of each part. - **expiresAt** (string) - The expiration timestamp for the upload URL. - **parts** (array) - A list of parts, where each part includes its number, upload URL, and byte range. - **completeUrl** (string) - The final URL to complete the upload process. #### Error Response - **400**: Bad Request - **401**: Unauthorized - **403**: Forbidden - **429**: Rate Limit Exceeded - **500**: Internal Server Error - **502**: Bad Gateway ``` -------------------------------- ### Complete Workflow Example Source: https://docs.ofauth.com/guides/how-to/mass-message Demonstrates a full workflow: fetching user lists, filtering them (e.g., for active subscribers), and then creating a mass message to send to the selected list. ```APIDOC ## Workflow: Send Promo to Active Subscribers This example outlines a common use case: identifying active subscribers and sending them a promotional message. ### Step 1: Get User Lists Fetch all available user lists to identify the target audience. **Endpoint:** `GET /v2/access/users/lists` ### Step 2: Create the Mass Message Construct and send a POST request to schedule the mass message, targeting the identified user list or using a date filter for recent subscribers. **Endpoint:** `POST /v2/access/mass-messages` **Request Body Example:** ```json { "text": "🎉 **Special Offer!**\n\nThanks for being an amazing subscriber! Here's 20% off my premium content this week only.\n\nUse code: VIP20 💕", "userLists": [activeList.id], // Or use subscribedAfterDate if no specific list found "subscribedAfterDate": "2024-01-01T00:00:00Z" // Example fallback } ``` **Response Example:** ```json { "id": 12345, "scheduledDate": "2024-01-15T10:30:00Z" } ``` ``` -------------------------------- ### Get Top Stories Statistics Source: https://docs.ofauth.com/guides/earnings Fetches a list of top stories based on specified criteria like views, tips, likes, or comments within a date range. Requires setting start and end dates and a limit. ```javascript const response = await fetch("https://api.ofauth.com/v2/access/statistics/stories/top?" + new URLSearchParams({ startDate: "2024-01-01", endDate: "2024-01-31", by: "views", // views | tips | likes | comments limit: "10" }), { headers }) ``` -------------------------------- ### Basic n8n Workflow: Daily Earnings Report Source: https://docs.ofauth.com/sdk/no-code/n8n Example of a basic n8n workflow to send a daily earnings summary to Slack. This workflow uses a Schedule Trigger, the OFAuth node to get earnings, and the Slack node to send a message. ```text Schedule Trigger → OFAuth (Get Earnings) → Slack (Send Message) ``` -------------------------------- ### Initialize Media Upload (Python) Source: https://docs.ofauth.com/guides/how-to/upload-media Initiate a media upload session with file details to obtain an upload ID and plan for data transfer. This is the first step in uploading media. ```python import requests response = requests.post( "https://api.ofauth.com/v2/access/uploads/init", headers={ "apikey": "YOUR_API_KEY", "x-connection-id": "conn_abc123", "Content-Type": "application/json" }, json={ "filename": "photo.jpg", "size": 1024000, "contentType": "image/jpeg" } ) upload = response.json() print(f"Upload ID: {upload['mediaUploadId']}, Parts: {upload['totalParts']}") ``` -------------------------------- ### Basic n8n Workflow: Content Analytics Dashboard Source: https://docs.ofauth.com/sdk/no-code/n8n Example of an n8n workflow to update a Google Sheets dashboard with the latest analytics data. This workflow uses a Schedule Trigger, the OFAuth node to get analytics, and the Google Sheets node to update data. ```text Schedule Trigger → OFAuth (Get Analytics) → Google Sheets (Update) ``` -------------------------------- ### Install n8n-nodes-ofauth Manually Source: https://docs.ofauth.com/sdk/no-code/n8n Install the OFAuth community node manually in your n8n instance by navigating to the nodes directory and running npm install. Remember to restart n8n after installation. ```bash cd ~/.n8n/nodes npm install n8n-nodes-ofauth ``` -------------------------------- ### Create Trial Link Source: https://docs.ofauth.com/api-reference/promotions/create-trial-link Creates a new free trial link. Requires `promotions:write` permission. ```APIDOC ## POST /promotions/trial-links ### Description Creates a new free trial link with specified details. ### Method POST ### Endpoint /promotions/trial-links ### Parameters #### Request Body - **name** (string) - Required - The name of the trial link. - **duration** (integer) - Required - The duration of the trial in seconds. - **offer_limit** (integer) - Optional - The limit for the offer associated with the trial. - **expiration** (integer) - Optional - The expiration time of the trial link in Unix timestamp format. ``` -------------------------------- ### List Subscribers Go Example Source: https://docs.ofauth.com/sdk/go Fetch a list of subscribers for a given connection ID, with optional limit. ```go subs, err := client.ListSubscribers(ctx, &ofauth.ListSubscribersParams{ ConnectionID: "conn_xxx", Limit: 20, }) if err != nil { log.Fatal(err) } for _, sub := range subs.Data { fmt.Println(sub.Username, sub.SubscribedAt) } ``` -------------------------------- ### Get dynamic rules Source: https://docs.ofauth.com/llms.txt Get dynamic rules. ```APIDOC ## GET /dynamic-rules/get-dynamic-rules ### Description Get dynamic rules. ### Endpoint /dynamic-rules/get-dynamic-rules ``` -------------------------------- ### Add OFAuth C# SDK Package Source: https://docs.ofauth.com/sdk/csharp Install the OFAuth C# SDK using the .NET CLI. This command adds the necessary package to your project. ```bash dotnet add package OnlyFans.SDK ``` -------------------------------- ### Get dynamic rules status Source: https://docs.ofauth.com/llms.txt Get dynamic rules status. ```APIDOC ## GET /dynamic-rules/get-dynamic-rules-status ### Description Get dynamic rules status. ### Endpoint /dynamic-rules/get-dynamic-rules-status ``` -------------------------------- ### Switching Between Sandbox and Production Environments Source: https://docs.ofauth.com/setup/sandbox Demonstrates how to switch between sandbox and production API keys without altering the core API call logic. Ensure to use environment variables for managing keys. ```javascript // Development const API_KEY = process.env.OFAUTH_SANDBOX_KEY // sk_sandbox_... // Production const API_KEY = process.env.OFAUTH_API_KEY // sk_live_... // Same code works for both const response = await fetch("https://api.ofauth.com/v2/account/whoami", { headers: { apikey: API_KEY } }) ``` -------------------------------- ### Get account counts Source: https://docs.ofauth.com/api-reference/self/get-account-counts Get account-wide subscription, subscriber, and bookmark counts. This endpoint is deprecated. ```APIDOC ## GET /v2/access/self/counts ### Description Get account-wide subscription, subscriber, and bookmark counts. **Permission Required:** `profile:read` ### Method GET ### Endpoint /v2/access/self/counts ### Response #### Success Response (200) - **subscriptions** (object) - Object containing subscription counts. - **active** (number) - **muted** (number) - **restricted** (number) - **expired** (number) - **blocked** (number) - **attention** (number) - **all** (number) - **subscribers** (object) - Object containing subscriber counts. - **active** (number) - **muted** (number) - **restricted** (number) - **expired** (number) - **blocked** (number) - **all** (number) - **activeOnline** (number) - **bookmarks** (number) - Total number of bookmarks. #### Response Example ```json { "subscriptions": { "active": 100, "muted": 10, "restricted": 5, "expired": 20, "blocked": 2, "attention": 3, "all": 140 }, "subscribers": { "active": 500, "muted": 50, "restricted": 25, "expired": 100, "blocked": 10, "all": 685, "activeOnline": 150 }, "bookmarks": 750 } ``` ``` -------------------------------- ### Webhook Signature Header Example Source: https://docs.ofauth.com/api-reference/system-webhook-events/overview This is an example of the OFAuth-Signature header included in webhook deliveries. It contains the timestamp and signature for verification. ```http OFAuth-Signature: t=1234567890,v1=abc123... ``` -------------------------------- ### Quick Start: Initialize OFAuth Client Source: https://docs.ofauth.com/sdk/typescript Initialize the OFAuth client with your API key. This client instance is used to interact with the OFAuth API. ```typescript import { createOFAuthClient } from '@ofauth/onlyfans-sdk'; const client = createOFAuthClient({ apiKey: 'your-api-key' }); const account = await client.account.whoami(); console.log(account.id, account.permissions); ``` -------------------------------- ### Vault+ Media Details Response Example Source: https://docs.ofauth.com/guides/media-storage Example JSON response when retrieving details for a specific media item stored in Vault+. ```json { "id": "12345", "type": "image", "duration": null, "media": { "full": { "id": "variant_abc123", "status": "stored", "quality": "full", "sizeBytes": 1024000, "contentType": "image/jpeg", "source": "vault", "accessCount": 12, "createdAt": 1715800000, "expiresAt": 1715886400, "storedAt": 1715800100, "lastAccessedAt": 1715800500, "url": "https://..." } } } ``` -------------------------------- ### Handle API Errors Go Example Source: https://docs.ofauth.com/sdk/go Demonstrates how to check for and extract API-specific error details using errors.As. ```go _, err := client.GetUser(ctx, &ofauth.GetUserParams{ ConnectionID: "conn_xxx", UserID: "999", }) if err != nil { var apiErr *ofauth.APIError if errors.As(err, &apiErr) { fmt.Println(apiErr.Status, apiErr.Code, apiErr.Message) } } ``` -------------------------------- ### Create Bundle Source: https://docs.ofauth.com/api-reference/promotions/create-bundle Creates a new subscription bundle with a specified discount and duration. Requires `promotions:write` permission. ```APIDOC ## POST /v2/access/promotions/bundles ### Description Create a new subscription bundle. **Permission Required:** `promotions:write` ### Method POST ### Endpoint /v2/access/promotions/bundles ### Parameters #### Request Body - **discount** (integer) - Required - Bundle discount percentage. Options are 0-50 in 5% increments. - **duration** (integer) - Required - Bundle subscription duration in months. Options are 3, 6, or 12 months. ### Request Example { "discount": 10, "duration": 6 } ### Response #### Success Response (200) - **id** (number) - Description - **discount** (number) - Description - **duration** (number) - Description - **price** (number) - Description - **canBuy** (boolean) - Description #### Response Example { "id": 123, "discount": 10, "duration": 6, "price": 45.00, "canBuy": true } ```