Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Evan Prodromou
@evanprodromou@socialwebfoundation.org  ·  activity timestamp 2 days ago

⁂ Article

ap, the ActivityPub API command-line client

As part of my book "ActivityPub: Programming for the Social Web", I created a coding example to show how to program for the ActivityPub API. ap is a command-line client, written in Python, for doing basic tasks with ActivityPub.For example, you can log into a server using this command: ap login yourname@yourserver.example Once you're logged in, you can follow someone: ap follow other@different.example Or, you could post some content: ap create note --public "Hello, World" This isn't […]

As part of my book “ActivityPub: Programming for the Social Web“, I created a coding example to show how to program for the ActivityPub API. ap is a command-line client, written in Python, for doing basic tasks with ActivityPub.

For example, you can log into a server using this command:

ap login yourname@yourserver.example

Once you’re logged in, you can follow someone:

ap follow other@different.example

Or, you could post some content:

ap create note --public "Hello, World"

This isn’t enough to have a real social networking experience, but I think it’s pretty useful for testing an ActivityPub API server, or automating some repetitive tasks.

I should note quickly here that not all ActivityPub servers support the ActivityPub API. It’s an under-utilized part of the ActivityPub standard. In particular, Mastodon, Threads, Flipboard, and other services don’t support the API. There’s a pretty good list of servers and clients that do support the API in this Codeberg issue.

Suffice it to say, unless you’re actively working with one of those platforms, or you are writing your own, you’re not going to get much use out of ap. It will probably give you an error message like “No OAuth endpoints found” if it can’t use the service.

Refreshing the project

I’ve never packaged ap for distribution; it was always supposed to be example code. But given the recent interest in the ActivityPub API, including the work going on in the ActivityPub API task force, I decided to get it into shape for installation by developers working on other apps. My friend Matthias Pfefferle of Automattic asked me about it when we were at FOSDEM this year, and I was embarrassed to see how difficult it was for him to use.

So, I’ve made two big upgrades to the package. The first was actually making it a package, and distributing it! I upgraded the package management framework to uv, which seems like a good bet for now, and pushing the application to PyPI, the Python Package Index. It’s visible at https://pypi.org/project/activitypub-cli/ now. (Note: different package name from the command name! The PyPI “ap” package name was taken a while ago.)

You can now install the application in one shot with this command on a computer that has Python on it:

pipx install activitypub-cli

You can test that the application installed correctly in your path by running the version command:

ap version

That should show the same version as is currently on the pypi.org page for the project.

The second change was implementing the current OAuth 2.0 profile best practices. I’ve upgraded the login flow so it tries a lot of different options for identifying itself to the server: CIMD, FEP d8c2, and Dynamic Client Registration. It tries to do them in preferential order; it uses permanent, global client identifiers before dynamic ones.

Help me test

I’m especially interested in testing this command-line client against other servers. If you’re developing an ActivityPub API server, please install the ap command and try it out against your (development!) server. Report a bug if it doesn’t work well, or send me a DM at @evanprodromou if it works OK. Given time, I think ap can be a useful first smoke test for ActivityPub API implementations.

FOSDEM 2026 - Home

Evan Prodromou's Blog

ActivityPub book

In September 2023, I started work on a book about ActivityPub for O’Reilly Media. As of September 2024, the book is now available! Ebook The book is available from several different ebook ven…
GitHub

GitHub - evanp/ap: command-line ActivityPub API client

command-line ActivityPub API client. Contribute to evanp/ap development by creating an account on GitHub.
Codeberg.org

Which ActivityPub applications support Client-to-Server (C2S)?

In preparation of updating and reorganising of this list I would like to collect current FOSS projects that offer an implementation of ActivityPub C2S. In this [current fedi discussion](https://ausglam.space/@hugh/1144176911799110820) a bunch of projects were already named: - [ActivityPods](http...
GitHub

GitHub - swicg/activitypub-api: ActivityPub API Task Force repository.

ActivityPub API Task Force repository. Contribute to swicg/activitypub-api development by creating an account on GitHub.

uv

uv is an extremely fast Python package and project manager, written in Rust.

Client Challenge

FEP-d8c2: OAuth 2.0 Profile for the ActivityPub API - Fediverse Enhancement Proposals

This FEP defines a mechanism for using an ActivityPub object ID as the client_id in the OAuth 2.0 authorization code flow. (An earlier version defined a full profile for using OAuth 2.0 with the ActivityPub API, but this version has been abbreviated to focus only on the client ID mechanism. The title has been retained to accommodate FEP tooling.)
  • Copy link
  • Flag this article
  • Block
Log in

La casa de los gays

This is a bonfire demo instance for testing purposes

La casa de los gays: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0-rc.3.6 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login