Class: Onlyfans::Resources::Posts

Inherits:
Object
  • Object
show all
Defined in:
lib/onlyfans/resources/posts.rb,
lib/onlyfans/resources/posts/labels.rb,
lib/onlyfans/resources/posts/comments.rb

Overview

APIs for managing OnlyFans posts

Defined Under Namespace

Classes: Comments, Labels

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Posts

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Posts.

Parameters:



344
345
346
347
348
# File 'lib/onlyfans/resources/posts.rb', line 344

def initialize(client:)
  @client = client
  @comments = Onlyfans::Resources::Posts::Comments.new(client: client)
  @labels = Onlyfans::Resources::Posts::Labels.new(client: client)
end

Instance Attribute Details

#commentsOnlyfans::Resources::Posts::Comments (readonly)



8
9
10
# File 'lib/onlyfans/resources/posts.rb', line 8

def comments
  @comments
end

#labelsOnlyfans::Resources::Posts::Labels (readonly)

APIs for managing your post labels



12
13
14
# File 'lib/onlyfans/resources/posts.rb', line 12

def labels
  @labels
end

Instance Method Details

#archive(post_id, account:, private_archive: nil, request_options: {}) ⇒ Onlyfans::Models::PostArchiveResponse

Archive a post from your account. Also can be used to move posts between the Regular and Private Archive.

Parameters:

  • post_id (Integer)

    Path param: The ID of the post

  • account (String)

    Path param: The Account ID

  • private_archive (Boolean)

    Query param: Set to ‘true` to move this post to the Private Archive.

  • request_options (Onlyfans::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/onlyfans/resources/posts.rb', line 236

def archive(post_id, params)
  parsed, options = Onlyfans::PostArchiveParams.dump_request(params)
  query = Onlyfans::Internal::Util.encode_query_params(parsed)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["api/%1$s/posts/%2$s/archive", , post_id],
    query: query,
    model: Onlyfans::Models::PostArchiveResponse,
    options: options
  )
end

#create(account, text:, expire_days: nil, fund_raising_target_amount: nil, fund_raising_tips_presets: nil, label_ids: nil, media_files: nil, previews: nil, rf_tag: nil, save_for_later: nil, scheduled_date: nil, voting_correct_index: nil, voting_due: nil, voting_options: nil, voting_type: nil, request_options: {}) ⇒ Onlyfans::Models::PostCreateResponse

Some parameter documentations has been truncated, see Models::PostCreateParams for more details.

Compose and send a new post to your OnlyFans account.

Parameters:

  • account (String)

    The Account ID

  • text (String)

    The post text content

  • expire_days (Integer)

    Number of days after which the post will expire. Between 1 and 30 days. Keep emp

  • fund_raising_target_amount (Integer)

    Add a fundraising target to your post. If present, value must be at least 10.

  • fund_raising_tips_presets (Array<String>)

    Specify which tip amounts will be listed under the fundraising card. Required wi

  • label_ids (String)

    Array of OF label IDs. Refer to our ‘/posts/labels` endpoint.

  • media_files (Array<Object>)

    Direct file uploads, OFAPI ‘ofapi_media_` IDs, or OF vault IDs.

  • previews (Array<Object>)

    Direct file uploads, OFAPI ‘ofapi_media_` IDs, OF vault IDs, or integer indices

  • rf_tag (String)

    Array OnlyFans creator user IDs to tag in your post

  • save_for_later (Boolean)

    Add your post to the “Saved for later” queue.

  • scheduled_date (String)

    Schedule your post in the future (UTC timezone).

  • voting_correct_index (Integer)

    The array key of your quiz’ correct answer. Required when ‘votingType` is “quiz”

  • voting_due (Integer)

    The due date (in days) of your poll/quiz. Can be 1, 3, 7 or 30 days. Can only be

  • voting_options (Array<String>)

    The options of your poll/quiz. Required with ‘votingType`.

  • voting_type (Symbol, Onlyfans::Models::PostCreateParams::VotingType)

    Include a poll or quiz within your post.

  • request_options (Onlyfans::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



56
57
58
59
60
61
62
63
64
65
# File 'lib/onlyfans/resources/posts.rb', line 56

def create(, params)
  parsed, options = Onlyfans::PostCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["api/%1$s/posts", ],
    body: parsed,
    model: Onlyfans::Models::PostCreateResponse,
    options: options
  )
end

#delete(post_id, account:, request_options: {}) ⇒ Onlyfans::Models::PostDeleteResponse

Delete a post from your account.

Parameters:

  • post_id (Integer)

    The ID of the post

  • account (String)

    The Account ID

  • request_options (Onlyfans::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/onlyfans/resources/posts.rb', line 206

def delete(post_id, params)
  parsed, options = Onlyfans::PostDeleteParams.dump_request(params)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["api/%1$s/posts/%2$s", , post_id],
    model: Onlyfans::Models::PostDeleteResponse,
    options: options
  )
end

#list(account, counters: nil, limit: nil, minimum_publish_date: nil, offset: nil, order: nil, pinned: nil, query: nil, sort: nil, request_options: {}) ⇒ Onlyfans::Models::PostListResponse

Get posts from your OnlyFans account.

Parameters:

  • account (String)

    The Account ID

  • counters (Boolean)

    Set to true to include an array of counters (see example responses)

  • limit (Integer)

    Number of posts to return (default = 10)

  • minimum_publish_date (String)

    Filter posts by minimum publish date

  • offset (Integer)

    Number of posts to skip for pagination

  • order (Symbol, Onlyfans::Models::PostListParams::Order)

    Order the returned posts (default = publish_date)

  • pinned (Boolean)

    Set to true to only show pinned posts

  • query (String)

    Search query to filter posts

  • sort (Symbol, Onlyfans::Models::PostListParams::Sort)

    Sort the returned posts (default = desc)

  • request_options (Onlyfans::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



181
182
183
184
185
186
187
188
189
190
191
# File 'lib/onlyfans/resources/posts.rb', line 181

def list(, params = {})
  parsed, options = Onlyfans::PostListParams.dump_request(params)
  query = Onlyfans::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["api/%1$s/posts", ],
    query: query.transform_keys(minimum_publish_date: "minimumPublishDate"),
    model: Onlyfans::Models::PostListResponse,
    options: options
  )
end

#pin(post_id, account:, request_options: {}) ⇒ Onlyfans::Models::PostPinResponse

Pin or unpin a post to your account.

Parameters:

  • post_id (Integer)

    The ID of the post

  • account (String)

    The Account ID

  • request_options (Onlyfans::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/onlyfans/resources/posts.rb', line 265

def pin(post_id, params)
  parsed, options = Onlyfans::PostPinParams.dump_request(params)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["api/%1$s/posts/%2$s/pin", , post_id],
    model: Onlyfans::Models::PostPinResponse,
    options: options
  )
end

#retrieve(post_id, account:, request_options: {}) ⇒ Onlyfans::Models::PostRetrieveResponse

Retrieve details of a post from your account.

Parameters:

  • post_id (Integer)

    The ID of the post

  • account (String)

    The Account ID

  • request_options (Onlyfans::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/onlyfans/resources/posts.rb', line 80

def retrieve(post_id, params)
  parsed, options = Onlyfans::PostRetrieveParams.dump_request(params)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["api/%1$s/posts/%2$s", , post_id],
    model: Onlyfans::Models::PostRetrieveResponse,
    options: options
  )
end

#stats(post_id, account:, with_historical_data: nil, request_options: {}) ⇒ Onlyfans::Models::PostStatsResponse

Show the statistics of a post like purchases, views, likes, tips and more.

Parameters:

  • post_id (Integer)

    Path param: The ID of the post

  • account (String)

    Path param: The Account ID

  • with_historical_data (Boolean)

    Query param: Set to ‘true` to include historical data for a post.

  • request_options (Onlyfans::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/onlyfans/resources/posts.rb', line 294

def stats(post_id, params)
  parsed, options = Onlyfans::PostStatsParams.dump_request(params)
  query = Onlyfans::Internal::Util.encode_query_params(parsed)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["api/%1$s/posts/%2$s/stats", , post_id],
    query: query,
    model: Onlyfans::Models::PostStatsResponse,
    options: options
  )
end

#unarchive(post_id, account:, private_archive: nil, request_options: {}) ⇒ Onlyfans::Models::PostUnarchiveResponse

Unarchive a post from your account.

Parameters:

  • post_id (Integer)

    Path param: The ID of the post

  • account (String)

    Path param: The Account ID

  • private_archive (Boolean)

    Query param: Set to ‘true` if this post is currently in the Private Archive.

  • request_options (Onlyfans::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/onlyfans/resources/posts.rb', line 325

def unarchive(post_id, params)
  parsed, options = Onlyfans::PostUnarchiveParams.dump_request(params)
  query = Onlyfans::Internal::Util.encode_query_params(parsed)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["api/%1$s/posts/%2$s/unarchive", , post_id],
    query: query,
    model: Onlyfans::Models::PostUnarchiveResponse,
    options: options
  )
end

#update(post_id, account:, text:, expire_days: nil, fund_raising_target_amount: nil, fund_raising_tips_presets: nil, label_ids: nil, media_files: nil, price: nil, rf_tag: nil, save_for_later: nil, scheduled_date: nil, voting_correct_index: nil, voting_due: nil, voting_options: nil, voting_type: nil, request_options: {}) ⇒ String

Some parameter documentations has been truncated, see Models::PostUpdateParams for more details.

Update a posted, queued, or “saved for later” post.

Parameters:

  • post_id (Integer)

    Path param: The ID of the post

  • account (String)

    Path param: The Account ID

  • text (String)

    Body param: The post text content

  • expire_days (Integer)

    Body param: Number of days after which the post will expire. Between 1 and 30 da

  • fund_raising_target_amount (Integer)

    Body param: Add a fundraising target to your post. If present, value must be at

  • fund_raising_tips_presets (Array<String>)

    Body param: Specify which tip amounts will be listed under the fundraising card.

  • label_ids (String)

    Body param: Array of OF label IDs. Refer to our ‘/posts/labels` endpoint.

  • media_files (String)

    Body param: Array of OFAPI ‘ofapi_media_` IDs, or OF media IDs

  • price (Integer)

    Body param: Price for paid content (0 or between 3-100). In case this is not zer

  • rf_tag (String)

    Body param: Array OnlyFans creator user IDs to tag in your post

  • save_for_later (Boolean)

    Body param: Add your post to the “Saved for later” queue.

  • scheduled_date (String)

    Body param: Schedule your post in the future (UTC timezone).

  • voting_correct_index (Integer)

    Body param: The array key of your quiz’ correct answer. Required when ‘votingTyp

  • voting_due (Integer)

    Body param: The due date (in days) of your poll/quiz. Can be 1, 3, 7 or 30 days.

  • voting_options (Array<String>)

    Body param: The options of your poll/quiz. Required with ‘votingType`.

  • voting_type (Symbol, Onlyfans::Models::PostUpdateParams::VotingType)

    Body param: Include a poll or quiz within your post.

  • request_options (Onlyfans::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (String)

See Also:



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/onlyfans/resources/posts.rb', line 138

def update(post_id, params)
  parsed, options = Onlyfans::PostUpdateParams.dump_request(params)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :put,
    path: ["api/%1$s/posts/%2$s", , post_id],
    headers: {"accept" => "text/plain"},
    body: parsed,
    model: String,
    options: options
  )
end