Class: Onlyfans::Client
- Inherits:
-
Internal::Transport::BaseClient
- Object
- Internal::Transport::BaseClient
- Onlyfans::Client
- Defined in:
- lib/onlyfans/client.rb
Constant Summary collapse
- DEFAULT_MAX_RETRIES =
Default max number of retries to attempt after a failed retryable request.
2- DEFAULT_TIMEOUT_IN_SECONDS =
Default per-request timeout.
60.0- DEFAULT_INITIAL_RETRY_DELAY =
Default initial retry delay in seconds. Overall delay is calculated using exponential backoff + jitter.
0.5- DEFAULT_MAX_RETRY_DELAY =
Default max retry delay in seconds.
8.0
Constants inherited from Internal::Transport::BaseClient
Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS
Instance Attribute Summary collapse
-
#accounts ⇒ Onlyfans::Resources::Accounts
readonly
Endpoints for your linked accounts.
- #analytics ⇒ Onlyfans::Resources::Analytics readonly
-
#api_key ⇒ String
readonly
Get your API Key from OnlyFansAPI Console - app.onlyfansapi.com/api-keys.
- #authenticate ⇒ Onlyfans::Resources::Authenticate readonly
-
#banking ⇒ Onlyfans::Resources::Banking
readonly
Operations related to user banking details, payout methods, legal and tax information, and account country settings.
- #bundles ⇒ Onlyfans::Resources::Bundles readonly
- #chargebacks ⇒ Onlyfans::Resources::Chargebacks readonly
- #chats ⇒ Onlyfans::Resources::Chats readonly
- #client_sessions ⇒ Onlyfans::Resources::ClientSessions readonly
-
#data_exports ⇒ Onlyfans::Resources::DataExports
readonly
APIs for managing data exports.
- #engagement ⇒ Onlyfans::Resources::Engagement readonly
-
#fans ⇒ Onlyfans::Resources::Fans
readonly
APIs for managing OnlyFans fans (subscribers).
-
#following ⇒ Onlyfans::Resources::Following
readonly
APIs for managing OnlyFans followings (people you’re subscribed to).
- #giphy ⇒ Onlyfans::Resources::Giphy readonly
-
#link_tags ⇒ Onlyfans::Resources::LinkTags
readonly
APIs for managing tags on free trial links and tracking links.
- #mass_messaging ⇒ Onlyfans::Resources::MassMessaging readonly
-
#me ⇒ Onlyfans::Resources::Me
readonly
Endpoints for your linked accounts.
- #media ⇒ Onlyfans::Resources::Media readonly
- #messages ⇒ Onlyfans::Resources::Messages readonly
-
#notifications ⇒ Onlyfans::Resources::Notifications
readonly
Endpoints for managingr account notifications.
- #payouts ⇒ Onlyfans::Resources::Payouts readonly
-
#posts ⇒ Onlyfans::Resources::Posts
readonly
APIs for managing OnlyFans posts.
- #profiles ⇒ Onlyfans::Resources::Profiles readonly
- #promotions ⇒ Onlyfans::Resources::Promotions readonly
- #queue ⇒ Onlyfans::Resources::Queue readonly
-
#release_forms ⇒ Onlyfans::Resources::ReleaseForms
readonly
APIs for managing OnlyFans release forms.
- #saved_for_later ⇒ Onlyfans::Resources::SavedForLater readonly
- #search ⇒ Onlyfans::Resources::Search readonly
- #settings ⇒ Onlyfans::Resources::Settings readonly
-
#shared_tracking_links ⇒ Onlyfans::Resources::SharedTrackingLinks
readonly
APIs for Tracking Links (campaigns) that other OF creators have shared with this account.
-
#shared_trial_links ⇒ Onlyfans::Resources::SharedTrialLinks
readonly
APIs for Free Trial Links that other OF creators have shared with this account.
-
#smart_link_postbacks ⇒ Onlyfans::Resources::SmartLinkPostbacks
readonly
APIs for managing Smart Link postback destinations.
-
#smart_links ⇒ Onlyfans::Resources::SmartLinks
readonly
APIs for managing Smart Links (Free Trial Links and Tracking Links with pooled inventory).
- #statistics ⇒ Onlyfans::Resources::Statistics readonly
- #stored ⇒ Onlyfans::Resources::Stored readonly
-
#stories ⇒ Onlyfans::Resources::Stories
readonly
APIs for managing OnlyFans stories.
- #subscribers ⇒ Onlyfans::Resources::Subscribers readonly
-
#tracking_links ⇒ Onlyfans::Resources::TrackingLinks
readonly
APIs for managing tracking links.
-
#transactions ⇒ Onlyfans::Resources::Transactions
readonly
APIs for managing OnlyFans transactions.
-
#trial_links ⇒ Onlyfans::Resources::TrialLinks
readonly
APIs for managing Free Trial Links.
- #user_lists ⇒ Onlyfans::Resources::UserLists readonly
-
#users ⇒ Onlyfans::Resources::Users
readonly
APIs for fetching OnlyFans users.
- #webhooks ⇒ Onlyfans::Resources::Webhooks readonly
- #whoami ⇒ Onlyfans::Resources::Whoami readonly
Attributes inherited from Internal::Transport::BaseClient
#base_url, #headers, #idempotency_header, #initial_retry_delay, #max_retries, #max_retry_delay, #requester, #timeout
Instance Method Summary collapse
-
#initialize(api_key: ENV["ONLYFANSAPI_API_KEY"], base_url: ENV["ONLY_FANS_API_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
constructor
Creates and returns a new client for interacting with the API.
Methods inherited from Internal::Transport::BaseClient
follow_redirect, #inspect, reap_connection!, #request, #send_request, should_retry?, validate!
Methods included from Internal::Util::SorbetRuntimeSupport
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize(api_key: ENV["ONLYFANSAPI_API_KEY"], base_url: ENV["ONLY_FANS_API_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
Creates and returns a new client for interacting with the API.
Defaults to ‘ENV`
‘“api.example.com/v2/”`. Defaults to `ENV`
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/onlyfans/client.rb', line 198 def initialize( api_key: ENV["ONLYFANSAPI_API_KEY"], base_url: ENV["ONLY_FANS_API_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY ) base_url ||= "https://app.onlyfansapi.com" if api_key.nil? raise ArgumentError.new("api_key is required, and can be set via environ: \"ONLYFANSAPI_API_KEY\"") end headers = {} custom_headers_env = ENV["ONLY_FANS_API_CUSTOM_HEADERS"] unless custom_headers_env.nil? parsed = {} custom_headers_env.split("\n").each do |line| colon = line.index(":") unless colon.nil? parsed[line[0...colon].strip] = line[(colon + 1)..].strip end end headers = parsed.merge(headers) end @api_key = api_key.to_s super( base_url: base_url, timeout: timeout, max_retries: max_retries, initial_retry_delay: initial_retry_delay, max_retry_delay: max_retry_delay, headers: headers ) @whoami = Onlyfans::Resources::Whoami.new(client: self) @accounts = Onlyfans::Resources::Accounts.new(client: self) @me = Onlyfans::Resources::Me.new(client: self) @analytics = Onlyfans::Resources::Analytics.new(client: self) @banking = Onlyfans::Resources::Banking.new(client: self) @chargebacks = Onlyfans::Resources::Chargebacks.new(client: self) @chats = Onlyfans::Resources::Chats.new(client: self) @messages = Onlyfans::Resources::Messages.new(client: self) @client_sessions = Onlyfans::Resources::ClientSessions.new(client: self) @authenticate = Onlyfans::Resources::Authenticate.new(client: self) @data_exports = Onlyfans::Resources::DataExports.new(client: self) @engagement = Onlyfans::Resources::Engagement.new(client: self) @fans = Onlyfans::Resources::Fans.new(client: self) @following = Onlyfans::Resources::Following.new(client: self) @trial_links = Onlyfans::Resources::TrialLinks.new(client: self) @giphy = Onlyfans::Resources::Giphy.new(client: self) @link_tags = Onlyfans::Resources::LinkTags.new(client: self) @mass_messaging = Onlyfans::Resources::MassMessaging.new(client: self) @media = Onlyfans::Resources::Media.new(client: self) @notifications = Onlyfans::Resources::Notifications.new(client: self) @payouts = Onlyfans::Resources::Payouts.new(client: self) @posts = Onlyfans::Resources::Posts.new(client: self) @promotions = Onlyfans::Resources::Promotions.new(client: self) @profiles = Onlyfans::Resources::Profiles.new(client: self) @search = Onlyfans::Resources::Search.new(client: self) @queue = Onlyfans::Resources::Queue.new(client: self) @release_forms = Onlyfans::Resources::ReleaseForms.new(client: self) @saved_for_later = Onlyfans::Resources::SavedForLater.new(client: self) @settings = Onlyfans::Resources::Settings.new(client: self) @shared_trial_links = Onlyfans::Resources::SharedTrialLinks.new(client: self) @shared_tracking_links = Onlyfans::Resources::SharedTrackingLinks.new(client: self) @smart_link_postbacks = Onlyfans::Resources::SmartLinkPostbacks.new(client: self) @smart_links = Onlyfans::Resources::SmartLinks.new(client: self) @statistics = Onlyfans::Resources::Statistics.new(client: self) @subscribers = Onlyfans::Resources::Subscribers.new(client: self) @stored = Onlyfans::Resources::Stored.new(client: self) @stories = Onlyfans::Resources::Stories.new(client: self) @bundles = Onlyfans::Resources::Bundles.new(client: self) @tracking_links = Onlyfans::Resources::TrackingLinks.new(client: self) @transactions = Onlyfans::Resources::Transactions.new(client: self) @user_lists = Onlyfans::Resources::UserLists.new(client: self) @users = Onlyfans::Resources::Users.new(client: self) @webhooks = Onlyfans::Resources::Webhooks.new(client: self) end |
Instance Attribute Details
#accounts ⇒ Onlyfans::Resources::Accounts (readonly)
Endpoints for your linked accounts
27 28 29 |
# File 'lib/onlyfans/client.rb', line 27 def accounts @accounts end |
#analytics ⇒ Onlyfans::Resources::Analytics (readonly)
34 35 36 |
# File 'lib/onlyfans/client.rb', line 34 def analytics @analytics end |
#api_key ⇒ String (readonly)
Get your API Key from OnlyFansAPI Console - app.onlyfansapi.com/api-keys
20 21 22 |
# File 'lib/onlyfans/client.rb', line 20 def api_key @api_key end |
#authenticate ⇒ Onlyfans::Resources::Authenticate (readonly)
54 55 56 |
# File 'lib/onlyfans/client.rb', line 54 def authenticate @authenticate end |
#banking ⇒ Onlyfans::Resources::Banking (readonly)
Operations related to user banking details, payout methods, legal and tax information, and account country settings.
39 40 41 |
# File 'lib/onlyfans/client.rb', line 39 def banking @banking end |
#bundles ⇒ Onlyfans::Resources::Bundles (readonly)
154 155 156 |
# File 'lib/onlyfans/client.rb', line 154 def bundles @bundles end |
#chargebacks ⇒ Onlyfans::Resources::Chargebacks (readonly)
42 43 44 |
# File 'lib/onlyfans/client.rb', line 42 def chargebacks @chargebacks end |
#chats ⇒ Onlyfans::Resources::Chats (readonly)
45 46 47 |
# File 'lib/onlyfans/client.rb', line 45 def chats @chats end |
#client_sessions ⇒ Onlyfans::Resources::ClientSessions (readonly)
51 52 53 |
# File 'lib/onlyfans/client.rb', line 51 def client_sessions @client_sessions end |
#data_exports ⇒ Onlyfans::Resources::DataExports (readonly)
APIs for managing data exports
58 59 60 |
# File 'lib/onlyfans/client.rb', line 58 def data_exports @data_exports end |
#engagement ⇒ Onlyfans::Resources::Engagement (readonly)
61 62 63 |
# File 'lib/onlyfans/client.rb', line 61 def engagement @engagement end |
#fans ⇒ Onlyfans::Resources::Fans (readonly)
APIs for managing OnlyFans fans (subscribers)
65 66 67 |
# File 'lib/onlyfans/client.rb', line 65 def fans @fans end |
#following ⇒ Onlyfans::Resources::Following (readonly)
APIs for managing OnlyFans followings (people you’re subscribed to)
69 70 71 |
# File 'lib/onlyfans/client.rb', line 69 def following @following end |
#giphy ⇒ Onlyfans::Resources::Giphy (readonly)
76 77 78 |
# File 'lib/onlyfans/client.rb', line 76 def giphy @giphy end |
#link_tags ⇒ Onlyfans::Resources::LinkTags (readonly)
APIs for managing tags on free trial links and tracking links
80 81 82 |
# File 'lib/onlyfans/client.rb', line 80 def @link_tags end |
#mass_messaging ⇒ Onlyfans::Resources::MassMessaging (readonly)
83 84 85 |
# File 'lib/onlyfans/client.rb', line 83 def mass_messaging @mass_messaging end |
#me ⇒ Onlyfans::Resources::Me (readonly)
Endpoints for your linked accounts
31 32 33 |
# File 'lib/onlyfans/client.rb', line 31 def me @me end |
#media ⇒ Onlyfans::Resources::Media (readonly)
86 87 88 |
# File 'lib/onlyfans/client.rb', line 86 def media @media end |
#messages ⇒ Onlyfans::Resources::Messages (readonly)
48 49 50 |
# File 'lib/onlyfans/client.rb', line 48 def @messages end |
#notifications ⇒ Onlyfans::Resources::Notifications (readonly)
Endpoints for managingr account notifications
90 91 92 |
# File 'lib/onlyfans/client.rb', line 90 def notifications @notifications end |
#payouts ⇒ Onlyfans::Resources::Payouts (readonly)
93 94 95 |
# File 'lib/onlyfans/client.rb', line 93 def payouts @payouts end |
#posts ⇒ Onlyfans::Resources::Posts (readonly)
APIs for managing OnlyFans posts
97 98 99 |
# File 'lib/onlyfans/client.rb', line 97 def posts @posts end |
#profiles ⇒ Onlyfans::Resources::Profiles (readonly)
103 104 105 |
# File 'lib/onlyfans/client.rb', line 103 def profiles @profiles end |
#promotions ⇒ Onlyfans::Resources::Promotions (readonly)
100 101 102 |
# File 'lib/onlyfans/client.rb', line 100 def promotions @promotions end |
#queue ⇒ Onlyfans::Resources::Queue (readonly)
109 110 111 |
# File 'lib/onlyfans/client.rb', line 109 def queue @queue end |
#release_forms ⇒ Onlyfans::Resources::ReleaseForms (readonly)
APIs for managing OnlyFans release forms
113 114 115 |
# File 'lib/onlyfans/client.rb', line 113 def release_forms @release_forms end |
#saved_for_later ⇒ Onlyfans::Resources::SavedForLater (readonly)
116 117 118 |
# File 'lib/onlyfans/client.rb', line 116 def saved_for_later @saved_for_later end |
#search ⇒ Onlyfans::Resources::Search (readonly)
106 107 108 |
# File 'lib/onlyfans/client.rb', line 106 def search @search end |
#settings ⇒ Onlyfans::Resources::Settings (readonly)
119 120 121 |
# File 'lib/onlyfans/client.rb', line 119 def settings @settings end |
#shared_tracking_links ⇒ Onlyfans::Resources::SharedTrackingLinks (readonly)
APIs for Tracking Links (campaigns) that other OF creators have shared with this account. Revenue, cost, and spender data are not available for shared campaigns.
129 130 131 |
# File 'lib/onlyfans/client.rb', line 129 def shared_tracking_links @shared_tracking_links end |
#shared_trial_links ⇒ Onlyfans::Resources::SharedTrialLinks (readonly)
APIs for Free Trial Links that other OF creators have shared with this account. Revenue, cost, and spender data are not available for shared links.
124 125 126 |
# File 'lib/onlyfans/client.rb', line 124 def shared_trial_links @shared_trial_links end |
#smart_link_postbacks ⇒ Onlyfans::Resources::SmartLinkPostbacks (readonly)
APIs for managing Smart Link postback destinations
133 134 135 |
# File 'lib/onlyfans/client.rb', line 133 def smart_link_postbacks @smart_link_postbacks end |
#smart_links ⇒ Onlyfans::Resources::SmartLinks (readonly)
APIs for managing Smart Links (Free Trial Links and Tracking Links with pooled inventory)
138 139 140 |
# File 'lib/onlyfans/client.rb', line 138 def smart_links @smart_links end |
#statistics ⇒ Onlyfans::Resources::Statistics (readonly)
141 142 143 |
# File 'lib/onlyfans/client.rb', line 141 def statistics @statistics end |
#stored ⇒ Onlyfans::Resources::Stored (readonly)
147 148 149 |
# File 'lib/onlyfans/client.rb', line 147 def stored @stored end |
#stories ⇒ Onlyfans::Resources::Stories (readonly)
APIs for managing OnlyFans stories
151 152 153 |
# File 'lib/onlyfans/client.rb', line 151 def stories @stories end |
#subscribers ⇒ Onlyfans::Resources::Subscribers (readonly)
144 145 146 |
# File 'lib/onlyfans/client.rb', line 144 def subscribers @subscribers end |
#tracking_links ⇒ Onlyfans::Resources::TrackingLinks (readonly)
APIs for managing tracking links
158 159 160 |
# File 'lib/onlyfans/client.rb', line 158 def tracking_links @tracking_links end |
#transactions ⇒ Onlyfans::Resources::Transactions (readonly)
APIs for managing OnlyFans transactions
162 163 164 |
# File 'lib/onlyfans/client.rb', line 162 def transactions @transactions end |
#trial_links ⇒ Onlyfans::Resources::TrialLinks (readonly)
APIs for managing Free Trial Links
73 74 75 |
# File 'lib/onlyfans/client.rb', line 73 def trial_links @trial_links end |
#user_lists ⇒ Onlyfans::Resources::UserLists (readonly)
165 166 167 |
# File 'lib/onlyfans/client.rb', line 165 def user_lists @user_lists end |
#users ⇒ Onlyfans::Resources::Users (readonly)
APIs for fetching OnlyFans users
169 170 171 |
# File 'lib/onlyfans/client.rb', line 169 def users @users end |
#webhooks ⇒ Onlyfans::Resources::Webhooks (readonly)
172 173 174 |
# File 'lib/onlyfans/client.rb', line 172 def webhooks @webhooks end |
#whoami ⇒ Onlyfans::Resources::Whoami (readonly)
23 24 25 |
# File 'lib/onlyfans/client.rb', line 23 def whoami @whoami end |