fopost
Official Rust SDK for the FoPost API. Schedule and publish to +30 social platforms from your code.
[]
= "0.1"
= { = "1", = ["macros", "rt-multi-thread"] }
Async, built on reqwest. Requires Rust 1.85 or newer.
0.x release. The public API is still settling and minor versions may contain breaking changes. Pin an exact version if that matters to you.
Quick start
use ;
async
Configuration
use Duration;
let client = builder
.api_key
.base_url // override for another deployment
.timeout
.max_retries // 1 disables retrying
.build?;
# Ok::
| Env var | Used for |
|---|---|
FOPOST_API_KEY |
The API key Client::from_env() reads |
Keys are created in the dashboard under Settings → API Keys. A key carries only the scopes
granted at creation and may be bound to a single workspace, in which case naming any other
workspace answers 403.
Resources
| Namespace | Methods |
|---|---|
posts() |
list, list_all, get, create, update, delete, duplicate, publish, retry, cancel, preflight, deliveries, publish_runs, analytics, bulk, validate_import, commit_import, rollback_import |
accounts() |
list, get, create, delete, toggle_primary, validate, health, health_summary, refresh_token, analytics, communities, sync_communities, search_communities, add_community, remove_community |
workspaces() |
list, get, create, update, delete, analytics |
labels() |
list, get, create, update, delete |
webhooks() |
list, create, update, delete, test |
automations() |
list, get, create, update, delete, toggle, runs, get_run, stats, trigger |
analytics() |
overview, time_series, top_posts, labels, posts_table, posting_streak, demographics, collect |
media() |
list, upload, delete |
That is every endpoint the API documents. Anything not yet wrapped is reachable through
client.request(method, path, query, body), which gets the same auth, retries, and error handling.
Error handling
Every call returns Result<T, fopost::Error>. A non-2xx response becomes Error::Api, carrying the
status, the API's machine-readable code, and the whole body.
use Error;
# async
Requests are rate limited per key, per minute. A 429 is retried automatically, waiting for the
interval the API asks for in Retry-After, up to max_retries attempts.
Publishing safely
publish in dry-run mode, and preflight, both report what would happen without sending anything:
use ;
# async
Media
Media upload and bulk CSV import post multipart bodies, which the multipart feature covers. It is
on by default.
use ;
# async
Cargo features
| Feature | Default | What it does |
|---|---|---|
rustls-tls |
yes | TLS through rustls, needing no system OpenSSL |
native-tls |
no | TLS through the platform's own stack |
multipart |
yes | Media upload and bulk CSV import |
To use native-tls instead, turn the defaults off and name what you want back:
= { = "0.1", = false, = ["native-tls", "multipart"] }
Forward compatibility
Response types ignore fields they do not know, and every enum keeps an Other(String) variant, so a
platform or status added server-side parses on an older SDK instead of failing the whole response.
use Platform;
assert_eq!;
assert_eq!;
Examples
Contributing
Issues and pull requests are welcome at fopost/fopost-rust.
Other SDKs
TypeScript (@fopost/sdk), Python
(fopost), PHP, Laravel, and WordPress, plus ready-to-run
API collections for Postman and Bruno.
License
MIT. See LICENSE.