@ofauth/onlyfans-sdk 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,242 @@
1
+ # OnlyFans API - TypeScript SDK
2
+
3
+ [![npm](https://img.shields.io/npm/v/@ofauth/onlyfans-sdk)](https://www.npmjs.com/package/@ofauth/onlyfans-sdk)
4
+ [![JSR](https://jsr.io/badges/@ofauth-org/onlyfans-sdk)](https://jsr.io/@ofauth-org/onlyfans-sdk)
5
+ [![License](https://img.shields.io/npm/l/@ofauth/onlyfans-sdk)](LICENSE)
6
+
7
+ The official **OnlyFans API TypeScript SDK** by [OFAuth](https://ofauth.com). A type-safe, fully-typed client for integrating with the OnlyFans API. Build OnlyFans tools, dashboards, analytics, and automations with full IntelliSense support.
8
+
9
+ > **What is this?** This is an SDK for the [OnlyFans API](https://ofauth.com) via OFAuth — the only authorized way to programmatically access OnlyFans data. Use it to build OnlyFans integrations, manage creator accounts, access earnings data, automate messaging, and more.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ # npm
15
+ npm install @ofauth/onlyfans-sdk
16
+
17
+ # yarn
18
+ yarn add @ofauth/onlyfans-sdk
19
+
20
+ # pnpm
21
+ pnpm add @ofauth/onlyfans-sdk
22
+
23
+ # JSR (Deno / JSR registry)
24
+ npx jsr add @ofauth-org/onlyfans-sdk
25
+ ```
26
+
27
+ ## Quick Start
28
+
29
+ ```typescript
30
+ import { createOFAuthClient } from '@ofauth/onlyfans-sdk';
31
+
32
+ const client = createOFAuthClient({ apiKey: 'your-api-key' });
33
+
34
+ // Get account info
35
+ const account = await client.whoami();
36
+ console.log(account.id, account.permissions);
37
+ ```
38
+
39
+ ## Features
40
+
41
+ - Full TypeScript support with inline types
42
+ - Nested client structure for intuitive API navigation
43
+ - Async iterators for paginated endpoints
44
+ - Proxy support for direct OnlyFans API access
45
+ - Media upload with automatic chunking
46
+ - Webhook verification and routing (Svix-compatible)
47
+
48
+ ## Configuration
49
+
50
+ ```typescript
51
+ import { createOFAuthClient } from '@ofauth/onlyfans-sdk';
52
+
53
+ const client = createOFAuthClient({
54
+ apiKey: 'your-api-key',
55
+ // Optional: Set a default connection ID for all requests
56
+ connectionId: 'conn_xxx',
57
+ // Optional: Custom base URL
58
+ basePath: 'https://api-next.ofauth.com',
59
+ // Optional: Custom fetch implementation
60
+ fetchApi: customFetch,
61
+ });
62
+ ```
63
+
64
+ ## Usage Examples
65
+
66
+ ### Account Operations
67
+
68
+ ```typescript
69
+ // Get account info
70
+ const account = await client.whoami();
71
+
72
+ // List all connections
73
+ const connections = await client.account.connections.list();
74
+ for (const conn of connections.list) {
75
+ console.log(conn.id, conn.status, conn.userData.username);
76
+ }
77
+
78
+ // Get connection settings
79
+ const settings = await client.account.connections.getSettings('conn_xxx');
80
+ ```
81
+
82
+ ### Pagination with Iterators
83
+
84
+ For endpoints that return paginated data, use the `iterate()` method:
85
+
86
+ ```typescript
87
+ // Iterate over all connections (handles pagination automatically)
88
+ for await (const connection of client.account.connections.iterate()) {
89
+ console.log(connection.id);
90
+ }
91
+
92
+ // With options
93
+ for await (const connection of client.account.connections.iterate({
94
+ maxItems: 100, // Stop after 100 items
95
+ pageSize: 20, // Items per page
96
+ })) {
97
+ console.log(connection.id);
98
+ }
99
+ ```
100
+
101
+ ### Access API (OnlyFans Data)
102
+
103
+ Access endpoints require a connection ID:
104
+
105
+ ```typescript
106
+ // Set connection ID for all requests
107
+ const client = createOFAuthClient({
108
+ apiKey: 'your-api-key',
109
+ connectionId: 'conn_xxx',
110
+ });
111
+
112
+ // Or pass it per-request
113
+ const profile = await client.access.self.get({ connectionId: 'conn_xxx' });
114
+
115
+ // Get earnings data
116
+ const earnings = await client.access.earnings.chart.get({
117
+ startDate: '2024-01-01',
118
+ endDate: '2024-01-31',
119
+ });
120
+
121
+ // List posts
122
+ const posts = await client.access.posts.list({ limit: 20 });
123
+
124
+ // Iterate over all posts
125
+ for await (const post of client.access.posts.iterate()) {
126
+ console.log(post.id, post.text);
127
+ }
128
+ ```
129
+
130
+ ### Proxy Requests
131
+
132
+ Call any OnlyFans API endpoint directly:
133
+
134
+ ```typescript
135
+ // GET request
136
+ const user = await client.proxy({
137
+ path: '/users/me',
138
+ method: 'GET',
139
+ connectionId: 'conn_xxx',
140
+ });
141
+
142
+ // POST request with body
143
+ const response = await client.proxy({
144
+ path: '/messages/queue',
145
+ method: 'POST',
146
+ connectionId: 'conn_xxx',
147
+ body: {
148
+ text: 'Hello!',
149
+ lockedText: false,
150
+ },
151
+ });
152
+
153
+ // With query parameters
154
+ const subscribers = await client.proxy({
155
+ path: '/subscriptions/subscribers',
156
+ method: 'GET',
157
+ connectionId: 'conn_xxx',
158
+ query: { limit: 10 },
159
+ });
160
+ ```
161
+
162
+ ### Media Upload
163
+
164
+ ```typescript
165
+ // Upload from File object (browser)
166
+ const result = await client.access.uploads.upload(
167
+ 'conn_xxx',
168
+ file, // File object
169
+ { onProgress: (uploaded, total) => console.log(`${uploaded}/${total}`) }
170
+ );
171
+
172
+ // Upload from Buffer (Node.js)
173
+ import fs from 'fs';
174
+
175
+ const buffer = fs.readFileSync('video.mp4');
176
+ const result = await client.access.uploads.upload(
177
+ 'conn_xxx',
178
+ new Blob([buffer], { type: 'video/mp4' }),
179
+ { filename: 'video.mp4' }
180
+ );
181
+ ```
182
+
183
+ ## Error Handling
184
+
185
+ ```typescript
186
+ import { OFAuthAPIError } from '@ofauth/onlyfans-sdk';
187
+
188
+ try {
189
+ const account = await client.whoami();
190
+ } catch (error) {
191
+ if (error instanceof OFAuthAPIError) {
192
+ console.error('API Error:', error.status, error.message);
193
+ console.error('Error code:', error.code);
194
+ console.error('Details:', error.details);
195
+ } else {
196
+ throw error;
197
+ }
198
+ }
199
+ ```
200
+
201
+ ## Type Safety
202
+
203
+ All request and response types are generated from the OpenAPI spec:
204
+
205
+ ```typescript
206
+ import type {
207
+ AccountWhoamiResponse,
208
+ AccountConnectionsListResponse,
209
+ AccountConnectionsListItem,
210
+ AccessSelfGetResponse,
211
+ } from '@ofauth/onlyfans-sdk';
212
+
213
+ // Response types are automatically inferred
214
+ const account = await client.whoami();
215
+ // account: AccountWhoamiResponse
216
+
217
+ // Full IntelliSense support
218
+ account.id; // string
219
+ account.name; // string | null
220
+ account.permissions; // string[]
221
+ ```
222
+
223
+ ## API Reference
224
+
225
+ The client provides access to these API namespaces:
226
+
227
+ - `client.whoami()` - Account info
228
+ - `client.account.connections` - Connection management
229
+ - `client.account.settings` - Account settings
230
+ - `client.access.self` - Creator profile
231
+ - `client.access.posts` - Posts management
232
+ - `client.access.chats` - Chat/messages
233
+ - `client.access.subscribers` - Subscriber data
234
+ - `client.access.earnings` - Earnings & analytics
235
+ - `client.access.vault` - Vault media
236
+ - `client.access.promotions` - Promotions & links
237
+ - `client.access.uploads` - Media uploads
238
+ - `client.proxy()` - Direct OnlyFans API access
239
+
240
+ ## License
241
+
242
+ MIT