Boosty API
A minimal, async-ready client for getting post data from a remote blogging API that requires either a bearer token or a refresh token + device ID combo for authentication. This crate is designed with resiliency in mind: it transparently handles token expiration and retries requests when needed.
Table of Contents
- Disclaimer
- Project Status
- Features
- Installation
- Example: Fetching a Single Post
- Example: Fetching Multiple Posts
- Extracting Content from a Post
- Authentication
- Crate Structure
- Error Handling
- API Documentation
- Contributing
- License
Disclaimer
This crate is intended for research and personal use only. By using it, you agree to:
- Access only your own content from the Boosty platform.
- Refrain from scraping, redistributing, or otherwise misusing content that you do not own.
- Comply with Boosty's Terms of Service and any applicable copyright laws.
The author is not responsible for any misuse of this software.
Project Status
🚧 This library is under active development.
Breaking changes, refactoring, and architectural updates may occur frequently.
Use with caution in production environments and pin specific versions if needed.
Features
🔐 Authentication
- Static bearer token or refresh-token + device ID (OAuth2-like).
- Automatic token refresh and retry on expiration.
- Clean separation of
AuthProviderlogic.
🔁 Retry Behavior
The client automatically retries HTTP requests that fail due to transient network errors or expired access tokens.
- Retry logic is centralized in the
get_request()method. - On token expiration, the client performs a refresh (if refresh-token and device ID are set) and retries the request.
- Other error types (like 4xx or business-logic errors) are not retried.
📝 Post API
- Get single post:
get_post(blog, id). - Get multiple posts:
get_posts(blog, limit). - Strongly typed
Poststruct withserdesupport. - Handles
"not available"status gracefully.
🎯 Blog Metadata
- Get targets via
get_targets(blog). - Get subscription levels via
get_subscription_levels(blog, show_free_level).
📜 Subscriptions
- Get current user subscriptions via
get_subscriptions(limit, with_follow), returning a paginatedSubscriptionsResponse.
⚙️ Low-level Features
- Async-ready
ApiClientusingreqwest. - Custom headers with real-world
User-Agent,DNT,Cache-Control, etc. - Unified error types:
ApiError,AuthErrorwith detailed variants.
Installation
Add this to your Cargo.toml:
[]
= "0.19.0"
or
Example getting single post
use ApiClient;
use Client;
async
Example getting multiple posts
use ApiClient;
use Client;
async
Extracting content from a post
use ContentItem;
Authentication
To get access token or refresh token and device_id, you need to log in to the service, then press F12 in the browser and go to the application tab, where you can select local storage. The required keys are _clentId and auth.
There are two options:
1. Static Bearer Token
api_client.set_bearer_token.await?;
2. Refresh Token Flow
api_client.set_refresh_token_and_device_id.await?;
If a post is unavailable and refresh credentials are present, the client will automatically attempt a refresh.
Crate Structure
api_client: Main entry point; gets post(s), manages headers, and authentication logicauth_provider: Refresh-token and access-token managementapi_response: Deserialization models for all API content types (e.g. post, target); organized by domainerror: Uniform error types for API and auth operationspost_data_extractor: Utility module for extracting structured data from post models
Error Handling
All API and auth operations return Result<T, ApiError> or Result<T, AuthError>, depending on context. Errors are
strongly typed and cover:
- HTTP request failures
- JSON (de)serialization issues
- Invalid or expired credentials
- Unsuccessful API status codes
API Documentation
For detailed documentation, please refer to docs.rs.
Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
License
This project is licensed under the MIT License.