Overview
The User Management modules (sdk.self and sdk.user) handle user profiles, interactions, and settings. The self module manages your own profile, while the user module handles operations with other users.
Self Module sdk.self - Current user profile, notifications, settings
User Module sdk.user - Other users, profiles, search, interactions
Self Module (sdk.self)
Get Current User Profile
Retrieve the authenticated user’s profile information.
const { data : profile , error } = await sdk . self . getMe ({
authentication: { connectionId: "conn_123" }
})
console . log ( ` ${ profile . name } (@ ${ profile . username } )` )
console . log ( `Subscribers: ${ profile . subscribersCount } ` )
console . log ( `Posts: ${ profile . postsCount } ` )
authentication
AuthenticationOptions
required
Either { connectionId: string } or { session: object }
Returns: User profile with ID, username, name, email, bio, subscriber/post counts, verification status, and avatar/cover URLs.
Update Profile
Update the authenticated user’s profile information.
const { data : result , error } = await sdk . self . updateProfile ({
authentication: { session: userData },
data: {
name: "New Display Name" ,
about: "Updated bio with new information! ✨"
}
})
New display name for the user
Get Notifications
Retrieve notifications for the authenticated user.
const { data : notifications , error } = await sdk . self . getNotifications ({
authentication: { connectionId: "conn_123" },
params: {
limit: 50 ,
filter: "unread" // "all", "unread", "tips", "messages"
}
})
console . log ( ` ${ notifications . list . length } notifications` )
Maximum notifications to return (1-100)
Filter by type: “all”, “unread”, “tips”, “messages”, “subscribers”
Mark Notifications as Read
Mark specific notifications as read.
const { data : result , error } = await sdk . self . markNotificationsRead ({
authentication: { session: userData },
notificationIds: [ "notif_123" , "notif_456" ]
})
User Module (sdk.user)
Get User by ID
Retrieve another user’s public profile information.
const { data : user , error } = await sdk . user . getById ({
authentication: { connectionId: "conn_123" },
userId: 987654321
})
console . log ( ` ${ user . name } (@ ${ user . username } )` )
console . log ( `Verified: ${ user . isVerified } ` )
console . log ( `Posts: ${ user . postsCount } ` )
OnlyFans user ID to retrieve
Returns: Public profile information including username, name, bio, post count, verification status, and avatar.
Search Users
Search for users by username or name.
const { data : results , error } = await sdk . user . search ({
authentication: { connectionId: "conn_123" },
params: {
query: "example" ,
limit: 20
}
})
console . log ( `Found ${ results . users . length } users` )
Search term (username or display name)
Maximum results to return (1-50)
Subscribe to User
Subscribe to another user’s content.
const { data : subscription , error } = await sdk . user . subscribe ({
authentication: { session: userData },
userId: 987654321 ,
params: {
paymentMethod: "card_123" ,
promocode: "WELCOME10" // Optional
}
})
Payment method ID for subscription
Optional promotional code
Unsubscribe from User
Cancel subscription to a user.
const { data : result , error } = await sdk . user . unsubscribe ({
authentication: { session: userData },
userId: 987654321
})
Check Subscription Status
Check if you’re subscribed to a user.
const { data : status , error } = await sdk . user . getSubscriptionStatus ({
authentication: { connectionId: "conn_123" },
userId: 987654321
})
console . log ( `Subscribed: ${ status . isSubscribed } ` )
if ( status . isSubscribed ) {
console . log ( `Expires: ${ status . expiresAt } ` )
}
Block/Unblock User
Block or unblock another user.
// Block user
const { data : blockResult , error } = await sdk . user . block ({
authentication: { session: userData },
userId: 987654321
})
// Unblock user
const { data : unblockResult , error } = await sdk . user . unblock ({
authentication: { session: userData },
userId: 987654321
})
Response Types
User Profile Object
interface UserProfile {
id : string
username : string
name : string
email ?: string // Only for self
about ?: string
subscribersCount : number
postsCount : number
isVerified : boolean
avatar ?: string
cover ?: string
subscriptionPrice ?: number // For other users
}
Notification Object
interface Notification {
id : string
type : "tip" | "message" | "subscriber" | "like" | "comment"
title : string
message : string
createdAt : string
isRead : boolean
userId ?: string
username ?: string
amount ?: number // For tips
}
Subscription Status Object
interface SubscriptionStatus {
isSubscribed : boolean
subscribedAt ?: string
expiresAt ?: string
isExpired : boolean
renewalPrice ?: number
isFree : boolean
}
Error Handling
Common error scenarios for user operations:
const { data , error } = await sdk . user . subscribe ( params )
if ( error ) {
switch ( error . type ) {
case "unauthorized" :
console . log ( "Please login to subscribe" )
break
case "forbidden" :
console . log ( "Cannot subscribe to this user" )
break
case "bad_request" :
if ( error . details ?. paymentMethod ) {
console . log ( "Invalid payment method" )
}
break
case "not_found" :
console . log ( "User not found" )
break
}
}
Best Practices
Profile Updates Update efficiently
Only send changed fields
Validate data client-side
Handle validation errors gracefully
User Interactions Respect user privacy
Check subscription status before actions
Handle blocking/privacy settings
Cache user data appropriately
Privacy & Permissions : Always respect user privacy settings and subscription requirements. Some user information is only available to subscribers.