Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
SHA: ${{ github.sha }}
PACKAGE_NAME: onlyfansapi
PACKAGE_NAME: onlyfans
run: ./scripts/utils/upload-artifact.sh
lint:
timeout-minutes: 10
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/publish-gem.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow is triggered when a GitHub release is created.
# It can also be run manually to re-publish to rubygems.org in case it failed for some reason.
# You can run this workflow by navigating to https://www.github.com/onlyfansapi/onlyfansapi-ruby/actions/workflows/publish-gem.yml
name: Publish Gem
on:
workflow_dispatch:

release:
types: [published]

jobs:
publish:
name: publish
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Ruby
uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1.306.0
with:
bundler-cache: false
- run: |-
bundle install

- name: Publish to RubyGems.org
run: |
bash ./bin/publish-gem
env:
# `RUBYGEMS_HOST` is only required for private gem repositories, not https://rubygems.org
RUBYGEMS_HOST: ${{ secrets.ONLY_FANS_API_RUBYGEMS_HOST || secrets.RUBYGEMS_HOST }}
GEM_HOST_API_KEY: ${{ secrets.ONLY_FANS_API_GEM_HOST_API_KEY || secrets.GEM_HOST_API_KEY }}
22 changes: 22 additions & 0 deletions .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release Doctor
on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
release_doctor:
name: release doctor
runs-on: ubuntu-latest
if: github.repository == 'onlyfansapi/onlyfansapi-ruby' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Check release environment
run: |
bash ./bin/check-release-environment
env:
RUBYGEMS_HOST: ${{ secrets.ONLY_FANS_API_RUBYGEMS_HOST || secrets.RUBYGEMS_HOST }}
GEM_HOST_API_KEY: ${{ secrets.ONLY_FANS_API_GEM_HOST_API_KEY || secrets.GEM_HOST_API_KEY }}
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.1.0"
}
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ Layout/LineLength:
AllowedPatterns:
- "^\\s*#.*$"
- ^require(_relative)?
- "Onlyfansapi::Internal::Type::BaseModel$"
- "Onlyfans::Internal::Type::BaseModel$"
- "^\\s*[A-Z0-9_]+ = :"
- "Onlyfansapi::(Models|Resources|Test)::"
- "Onlyfans::(Models|Resources|Test)::"
Max: 110

Layout/MultilineArrayLineBreaks:
Expand Down
4 changes: 2 additions & 2 deletions .solargraph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include:
- 'Rakefile'
- 'examples/**/*.rb'
- 'lib/**/*.rb'
- 'test/onlyfansapi/resource_namespaces.rb'
- 'test/onlyfansapi/test_helper.rb'
- 'test/onlyfans/resource_namespaces.rb'
- 'test/onlyfans/test_helper.rb'
exclude:
- 'rbi/**/*'
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 266
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/onlyfansapi/onlyfansapi-105f57111e8052450e8a8094ad0e089f01bacf8a83bc3e6b9a2dd7876c40ef81.yml
openapi_spec_hash: df45bde0a256fd87ddf78b3775a0e050
config_hash: f21f81a6085d268078fee289dc8f2e5a
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/onlyfansapi/onlyfansapi-72633437c337ec4d9d333f5e895b2b7a1ef13b1c5d4273906d4a6861e24c99dd.yml
openapi_spec_hash: 6c2d47cd85674ece07dc37e471a36ac9
config_hash: 6299d85babc83b296c506e0e64fe2c0a
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Changelog

## 0.1.0 (2026-05-25)

Full Changelog: [v0.0.1...v0.1.0](https://github.com/onlyfansapi/onlyfansapi-ruby/compare/v0.0.1...v0.1.0)

### Features

* **api:** api update ([45f5f58](https://github.com/onlyfansapi/onlyfansapi-ruby/commit/45f5f588f19d12d8c071d7d4a9cf4acf9cccf682))
* **api:** api update ([0eb94d3](https://github.com/onlyfansapi/onlyfansapi-ruby/commit/0eb94d3f12d0a4c34d66d308894bf6b2fa800885))
* **api:** api update ([0ed39af](https://github.com/onlyfansapi/onlyfansapi-ruby/commit/0ed39af885221d4f7a259ea30a202d2854c7afc6))
* **api:** api update ([7e296d4](https://github.com/onlyfansapi/onlyfansapi-ruby/commit/7e296d4c232ab3c5a426beb2410362cab3143067))
* **api:** api update ([84071ab](https://github.com/onlyfansapi/onlyfansapi-ruby/commit/84071ab4352b54308f895008155cf2d178b1bb22))
* **api:** api update ([eb3b6d6](https://github.com/onlyfansapi/onlyfansapi-ruby/commit/eb3b6d6cdaeb2484a08f5b669703f881bb06a77e))
* **api:** manual updates ([27f0026](https://github.com/onlyfansapi/onlyfansapi-ruby/commit/27f00267fd3776c89862fdc2043337c226863c2d))
* **api:** manual updates ([26f588a](https://github.com/onlyfansapi/onlyfansapi-ruby/commit/26f588a61a0cc9736afe486ec7e9347b4aef96c5))


### Chores

* configure new SDK language ([1d36d97](https://github.com/onlyfansapi/onlyfansapi-ruby/commit/1d36d9741a09dbb910e97ba3cdceeadb84b2f51c))
* update SDK settings ([d0745a7](https://github.com/onlyfansapi/onlyfansapi-ruby/commit/d0745a7e804977858ee73202888cc8072f630aaa))
* update SDK settings ([1d02f9d](https://github.com/onlyfansapi/onlyfansapi-ruby/commit/1d02f9de8014097a41956d96e4b896b76bb6f294))
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This will install all the required dependencies.

## Modifying/Adding code

Most of the SDK is generated code. Modifications to code will be persisted between generations, but may result in merge conflicts between manual patches and changes from the generator. The generator will never modify the contents of `lib/onlyfansapi/helpers/` and `examples/` directory.
Most of the SDK is generated code. Modifications to code will be persisted between generations, but may result in merge conflicts between manual patches and changes from the generator. The generator will never modify the contents of `lib/onlyfans/helpers/` and `examples/` directory.

## Adding and running examples

Expand All @@ -24,7 +24,7 @@ All files in the `examples/` directory are not modified by the generator and can
#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative "../lib/onlyfansapi"
require_relative "../lib/onlyfans"

# ...
```
Expand All @@ -43,17 +43,17 @@ If you’d like to use the repository from source, you can either install from g
To install via git in your `Gemfile`:

```ruby
gem "onlyfansapi", git: "https://github.com/stainless-sdks/onlyfansapi-ruby"
gem "onlyfans", git: "https://github.com/onlyfansapi/onlyfansapi-ruby"
```

Alternatively, reference local copy of the repo:

```bash
$ git clone -- 'https://github.com/stainless-sdks/onlyfansapi-ruby' '<path-to-repo>'
$ git clone -- 'https://github.com/onlyfansapi/onlyfansapi-ruby' '<path-to-repo>'
```

```ruby
gem "onlyfansapi", path: "<path-to-repo>"
gem "onlyfans", path: "<path-to-repo>"
```

## Running commands
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GIT
PATH
remote: .
specs:
onlyfansapi (0.0.1)
onlyfans (0.1.0)
cgi
connection_pool

Expand Down Expand Up @@ -210,7 +210,7 @@ DEPENDENCIES
minitest-hooks
minitest-proveit
minitest-rg
onlyfansapi!
onlyfans!
rake
rbs
redcarpet
Expand Down
49 changes: 26 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
# Only Fans API Ruby API library

The Only Fans API Ruby library provides convenient access to the Only Fans API REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/stainless-sdks/onlyfansapi-ruby#Sorbet) for usage with Sorbet. The standard library's `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.
The Only Fans API Ruby library provides convenient access to the Only Fans API REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/onlyfansapi/onlyfansapi-ruby#Sorbet) for usage with Sorbet. The standard library's `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.

It is generated with [Stainless](https://www.stainless.com/).

## Documentation

Documentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/onlyfansapi).
Documentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/onlyfans).

The REST API documentation can be found on [docs.onlyfansapi.com](https://docs.onlyfansapi.com).

## Installation

To use this gem, install via Bundler by adding the following to your application's `Gemfile`:

<!-- x-release-please-start-version -->

```ruby
gem "onlyfansapi", "~> 0.0.1"
gem "onlyfans", "~> 0.1.0"
```

<!-- x-release-please-end -->

## Usage

```ruby
require "bundler/setup"
require "onlyfansapi"
require "onlyfans"

only_fans_api = Onlyfansapi::Client.new(
only_fans_api = Onlyfans::Client.new(
api_key: ENV["ONLYFANSAPI_API_KEY"] # This is the default and can be omitted
)

Expand All @@ -47,8 +51,7 @@ response = only_fans_api.media.upload(file: Pathname("/path/to/file"))
response = only_fans_api.media.upload(file: File.read("/path/to/file"))

# Or, to control the filename and/or content type:
file =
Onlyfansapi::FilePart.new(File.read("/path/to/file"), filename: "/path/to/file", content_type: "…")
file = Onlyfans::FilePart.new(File.read("/path/to/file"), filename: "/path/to/file", content_type: "…")
response = only_fans_api.media.upload(file: file)

puts(response.prefixed_id)
Expand All @@ -58,17 +61,17 @@ Note that you can also pass a raw `IO` descriptor, but this disables retries, as

### Handling errors

When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Onlyfansapi::Errors::APIError` will be thrown:
When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Onlyfans::Errors::APIError` will be thrown:

```ruby
begin
whoami = only_fans_api.whoami.retrieve
rescue Onlyfansapi::Errors::APIConnectionError => e
rescue Onlyfans::Errors::APIConnectionError => e
puts("The server could not be reached")
puts(e.cause) # an underlying Exception, likely raised within `net/http`
rescue Onlyfansapi::Errors::RateLimitError => e
rescue Onlyfans::Errors::RateLimitError => e
puts("A 429 status code was received; we should back off a bit.")
rescue Onlyfansapi::Errors::APIStatusError => e
rescue Onlyfans::Errors::APIStatusError => e
puts("Another non-200-range status code was received")
puts(e.status)
end
Expand Down Expand Up @@ -100,7 +103,7 @@ You can use the `max_retries` option to configure or disable this:

```ruby
# Configure the default for all requests:
only_fans_api = Onlyfansapi::Client.new(
only_fans_api = Onlyfans::Client.new(
max_retries: 0 # default is 2
)

Expand All @@ -114,23 +117,23 @@ By default, requests will time out after 60 seconds. You can use the timeout opt

```ruby
# Configure the default for all requests:
only_fans_api = Onlyfansapi::Client.new(
only_fans_api = Onlyfans::Client.new(
timeout: nil # default is 60
)

# Or, configure per-request:
only_fans_api.whoami.retrieve(request_options: {timeout: 5})
```

On timeout, `Onlyfansapi::Errors::APITimeoutError` is raised.
On timeout, `Onlyfans::Errors::APITimeoutError` is raised.

Note that requests that time out are retried by default.

## Advanced concepts

### BaseModel

All parameter and response objects inherit from `Onlyfansapi::Internal::Type::BaseModel`, which provides several conveniences, including:
All parameter and response objects inherit from `Onlyfans::Internal::Type::BaseModel`, which provides several conveniences, including:

1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax.

Expand Down Expand Up @@ -181,9 +184,9 @@ response = client.request(

### Concurrency & connection pooling

The `Onlyfansapi::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.
The `Onlyfans::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.

Each instance of `Onlyfansapi::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.
Each instance of `Onlyfans::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.

When all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.

Expand All @@ -206,7 +209,7 @@ Or, equivalently:
only_fans_api.whoami.retrieve

# You can also splat a full Params class:
params = Onlyfansapi::WhoamiRetrieveParams.new
params = Onlyfans::WhoamiRetrieveParams.new
only_fans_api.whoami.retrieve(**params)
```

Expand All @@ -216,18 +219,18 @@ Since this library does not depend on `sorbet-runtime`, it cannot provide [`T::E

```ruby
# :revenue
puts(Onlyfansapi::Analytics::FinancialGetForecastParams::Metric::REVENUE)
puts(Onlyfans::Analytics::FinancialGetForecastParams::Metric::REVENUE)

# Revealed type: `T.all(Onlyfansapi::Analytics::FinancialGetForecastParams::Metric, Symbol)`
T.reveal_type(Onlyfansapi::Analytics::FinancialGetForecastParams::Metric::REVENUE)
# Revealed type: `T.all(Onlyfans::Analytics::FinancialGetForecastParams::Metric, Symbol)`
T.reveal_type(Onlyfans::Analytics::FinancialGetForecastParams::Metric::REVENUE)
```

Enum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:

```ruby
# Using the enum constants preserves the tagged type information:
only_fans_api.analytics.financial.get_forecast(
metric: Onlyfansapi::Analytics::FinancialGetForecastParams::Metric::REVENUE,
metric: Onlyfans::Analytics::FinancialGetForecastParams::Metric::REVENUE,
# …
)

Expand All @@ -250,4 +253,4 @@ Ruby 3.2.0 or higher.

## Contributing

See [the contributing documentation](https://github.com/stainless-sdks/onlyfansapi-ruby/tree/main/CONTRIBUTING.md).
See [the contributing documentation](https://github.com/onlyfansapi/onlyfansapi-ruby/tree/main/CONTRIBUTING.md).
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ multitask(:"build:gem") do
sig/*
GLOB

sh(*%w[gem build -- onlyfansapi.gemspec])
sh(*%w[gem build -- onlyfans.gemspec])
rm_rf(ignore_file)
end

Expand Down
21 changes: 21 additions & 0 deletions bin/check-release-environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

errors=()

if [ -z "${GEM_HOST_API_KEY}" ]; then
errors+=("The GEM_HOST_API_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets")
fi

lenErrors=${#errors[@]}

if [[ lenErrors -gt 0 ]]; then
echo -e "Found the following errors in the release environment:\n"

for error in "${errors[@]}"; do
echo -e "- $error\n"
done

exit 1
fi

echo "The environment is ready to push releases!"
Loading
Loading