Mastodon Client for nim
  • Nim 89.8%
  • Nix 10.2%
Find a file
nsaspy d6a3d7f767
Merge pull request #1 from lost-rob0t/agent/modernize-nim2
Modernize Mastodon client for Nim 2
2026-08-04 17:03:10 -04:00
.github/workflows Add Nim 2 CI 2026-07-30 20:30:23 -04:00
src Remove obsolete query macros 2026-07-30 20:29:17 -04:00
tests Add Nim 2 unit tests 2026-07-30 20:30:06 -04:00
changelog.org update ua 2023-08-19 20:05:02 -04:00
default.nix add files 2023-08-05 22:28:36 -04:00
fedi.nimble Modernize package for Nim 2 2026-07-30 20:27:07 -04:00
flake.nix add files 2023-08-05 22:28:36 -04:00
LICENSE add files 2023-08-05 22:28:36 -04:00
README.org Fix README example import 2026-07-30 21:28:18 -04:00

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@domain accounts.

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.