The SDK supports three different modes. Choose the one that best fits your use case:
Access Mode (recommended) — Managed API calls through OFAuth, ideal for most applications.
Copy
import OFSDK from "@ofauth/onlyfans-sdk"const sdk = new OFSDK({ mode: "access", ofauthApiKey: process.env.OFAUTH_API_KEY, debugLog: false // Enable for development})
Access mode uses OFAuth’s managed infrastructure to handle OnlyFans API complexities automatically.
Direct Mode — Full control over API requests, session management, and local debugging without usage costs.
Copy
import OFSDK from "@ofauth/onlyfans-sdk"const sdk = new OFSDK({ mode: "direct", ofauthApiKey: process.env.OFAUTH_API_KEY, // Required for request signing debugLog: true // Helpful for debugging direct API calls})
Direct mode requires manual session management and handling of OnlyFans API changes.
Custom Mode — Enterprise setups with custom proxy infrastructure and routing requirements.
Copy
import OFSDK from "@ofauth/onlyfans-sdk"const sdk = new OFSDK({ mode: "custom", customOptions: { baseUrl: "https://your-api-proxy.com", signRequests: false, // Set to true if using OFAuth signing beforeRequest: (url, request) => { // Add custom headers or modify requests request.headers = { ...request.headers, "X-Custom-Header": "your-value" } return request } }, ofauthApiKey: process.env.OFAUTH_API_KEY // Required if signRequests: true})
Custom mode is perfect for enterprise environments where requests need to go through internal proxies or custom infrastructure.
Use the Account API to verify that your API key and platform metadata are set up correctly. The whoami endpoint returns only general information about your organization.