Skip to main content

ap

license standard-readme compliant

ap is a command-line client for the ActivityPub API.

Table of Contents

Background

I initially developed this program to illustrate how to write client code for the ActivityPub API as part of my book for O'Reilly Media, "ActivityPub: Programming for the Social Web".

Note that not all servers that implement the ActivityPub federation protocol necessarily implement the ActivityPub API. In particular, as of this writing, Mastodon does not implement the ActivityPub API; it has its own API. If you're using Mastodon, you may prefer the toot CLI instead.

A good list of supporting software is here:

https://codeberg.org/fediverse/delightful-fediverse-experience/issues/130

Install

The easiest way to install is from PyPI.

pipx install activitypub-cli

Usage

ap uses the subcommand pattern common with other large command-line programs like git and docker. The full list of subcommands is available by typing ap --help. Familiarity with the ActivityPub API is helpful for understanding these commands!

ap login <id>

Logs in as a user to an ActivityPub API server using OAuth 2.0. The <id> argument is a Webfinger ID like username@domain.example or the ActivityPub Actor ID (usually an HTTPS URL).

Example with a Webfinger ID:

ap login username@domain.example

Example with an ActivityPub actor ID:

ap login https://social.example/person/df816567-4c64-480c-955a-0f734bf93362

ap login stores the OAuth 2.0 token(s) in a file in the user's home directory, $HOME/.ap/token.json, so that subsequent commands can use them.

If this command fails, it's likely that your server doesn't support the ActivityPub API.

ap logout

Logs out of the current session by deleting the token file.

ap whoami

Shows the currently logged-in user.

ap get <id>

Gets the object with the given ID and prints it to stdout.

ap inbox

ap outbox

ap followers

ap following

ap pending followers

ap pending following

Shows these collections for the currently logged-in user.

ap follow <id>

Follows the user with the given ID.

ap accept follower <id>

ap reject follower <id>

Accepts or rejects a follow request from the user with the given ID.

ap undo follow <id>

Unfollows the user with the given ID.

ap create note <text>

Creates a Note object with the given text.

ap upload <filename>

Uploads the given file and prints the resulting URL.

Maintainers

Contributing

The project uses uv. To get set up, clone from Git and set up a virtual environment:

git clone https://github.com/evanp/ap.git
cd ap
uv venv
source .venv/bin/activate
uv pip install -e .

Then you can run the application directly:

ap -h

I'm very interested in contributions to this project. Some quick notes:

  • Please open an issue before starting work on a new feature. This will help us coordinate and make sure that the feature is a good fit for the project.
  • Ideally, commands should map closely to the ActivityPub API. If you're not sure how to do that, please open an issue and we can discuss it.
  • Please make sure that your code passes the existing tests, and add new tests as appropriate.
  • Please make your code format correctly with Python Black.

Small note: If editing the Readme, please conform to the standard-readme specification.

License

GPL v3 or later

Release files for activitypub-cli 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for activitypub-cli 0.5.1
File Size Uploaded
activitypub_cli-0.5.1.tar.gz 29.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for activitypub-cli 0.5.1
File Interpreter ABI Platform
activitypub_cli-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 70.5 kB

Release files / activitypub_cli-0.5.1.tar.gz

Download URL activitypub_cli-0.5.1.tar.gz
Size 29.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c4685fe3b7193ff857c04408097dc72815dd122e3ec3363f782192292ac03c7f
BLAKE2b-256 checksum
How to use checksums
d659fbafa10bfc9884288c1b7565500c2514f2d1c78e4e9bd51fa79209b62fcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 11, 2026.

Transparency log

Release files / activitypub_cli-0.5.1-py3-none-any.whl

Download URL activitypub_cli-0.5.1-py3-none-any.whl
Size 41.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ce666100973645bc582435ffc08ccd16d5d4edaa53ce0a4edcf70252744e843
BLAKE2b-256 checksum
How to use checksums
92410921702929ef9d27b18d5b7200ea1f6f716a64c0cdb6d5288dd38c8540b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page