Mastodon Client for nim
- Nim 89.8%
- Nix 10.2%
|
|
||
|---|---|---|
| .github/workflows | ||
| src | ||
| tests | ||
| changelog.org | ||
| default.nix | ||
| fedi.nimble | ||
| flake.nix | ||
| LICENSE | ||
| README.org | ||
fedi
About
fedi is a small Nim 2 client for the Mastodon REST API. It provides matching
synchronous and asynchronous clients, typed HTTP errors, safe cursor handling,
URL-encoded query parameters, and rate-limit metadata.
Install
nimble install "https://github.com/lost-rob0t/fedi#head"
Example
import std/[asyncdispatch, os]
import fedi
proc main() {.async.} =
let client = newAsyncFediClient(
host = "https://mastodon.social",
token = getEnv("MASTODON_TOKEN")
)
defer: client.close()
let timeline = await client.getTimeline(local = true, limit = 20)
echo timeline
waitFor main()
Implemented API groups
- Account lookup, account details, account statuses, and followers.
- Public timelines with string cursors and all current public-timeline filters.
- Single and multiple status lookup plus thread context.
- Mastodon v2 instance information, peers, activity, rules, and active-user count.
- WebFinger URL construction for
username@domainaccounts.
Errors
Non-2xx responses raise FediError. The exception includes the HTTP status,
the parsed response body, and retryAfterMs when rate-limit headers provide a
retry delay. Non-JSON error bodies are preserved under an error field.
Development
nimble test
The package requires Nim 2.0 or newer and uses only the Nim standard library.