--- url: /cli.md description: >- The fedify command is a CLI toolchain for Fedify and debugging ActivityPub-enabled federated server apps. This section explains the key features of the fedify command. --- # `fedify`: CLI toolchain The `fedify` command is a CLI toolchain for Fedify and debugging ActivityPub-enabled federated server apps. Although it is primarily designed for developers who use Fedify, it can be used with any ActivityPub-enabled server. ## Installation ### Using npm If you have [Node.js] or [Bun] installed, you can install `fedify` by running the following command: ::: code-group ```sh [Node.js] npm install -g @fedify/cli ``` ```sh [Bun] bun install -g @fedify/cli ``` ::: [Node.js]: https://nodejs.org/ [Bun]: https://bun.sh/ ### Using Homebrew on macOS and Linux If you are using macOS or Linux and have [Homebrew] installed, you can install `fedify` by running the following command: ```sh brew install fedify ``` [Homebrew]: https://brew.sh/ ### Using Scoop on Windows If you are using Windows and have [Scoop] installed, you can install `fedify` by running the following command: ```powershell scoop install fedify ``` [Scoop]: https://scoop.sh/ ### Using Deno If you have [Deno] installed, you can install `fedify` by running the following command: ::: code-group ```sh [Linux/macOS] deno install \ -g \ -A \ --unstable-fs --unstable-kv --unstable-temporal \ -n fedify \ jsr:@fedify/cli ``` ```powershell [Windows] deno install ` -g ` -A ` --unstable-fs --unstable-kv --unstable-temporal ` -n fedify ` jsr:@fedify/cli ``` ::: [Deno]: https://deno.com/ ### Downloading the executable You can download the pre-built executables from the [releases] page. Download the appropriate executable for your platform and put it in your `PATH`. [releases]: https://github.com/fedify-dev/fedify/releases ## `fedify init`: Initializing a Fedify project *This command is available since Fedify 0.12.0.* [](https://asciinema.org/a/671658) The `fedify init` command is used to initialize a new Fedify project. It creates a new directory with the necessary files and directories for a Fedify project. To create a new Fedify project, run the below command: ```sh fedify init my-fedify-project ``` The above command will start the interactive prompt to initialize a new Fedify project. It will ask you a few questions to set up the project: * JavaScript runtime: [Deno], [Bun], or [Node.js] * Package manager (if Node.js): [npm], [pnpm], or [Yarn] * Web framework: Bare-bones, [Fresh] (if Deno), [Hono], [Express] (unless Deno), or [Nitro] (unless Deno) * Key-value store: In-memory, [Redis], [PostgreSQL], or [Deno KV] (if Deno) * Message queue: In-memory, [Redis], [PostgreSQL], [AMQP] (e.g., [RabbitMQ]), or [Deno KV] (if Deno) Alternatively, you can specify the options in the command line to skip some of interactive prompts: [npm]: https://www.npmjs.com/ [pnpm]: https://pnpm.io/ [Yarn]: https://yarnpkg.com/ [Fresh]: https://fresh.deno.dev/ [Hono]: https://hono.dev/ [Express]: https://expressjs.com/ [Nitro]: https://nitro.unjs.io/ [Redis]: https://redis.io/ [PostgreSQL]: https://www.postgresql.org/ [AMQP]: https://www.amqp.org/ [RabbitMQ]: https://www.rabbitmq.com/ [Deno KV]: https://deno.com/kv ### `-r`/`--runtime`: JavaScript runtime You can specify the JavaScript runtime by using the `-r`/`--runtime` option. The available options are: * `deno`: [Deno] * `bun`: [Bun] * `node`: [Node.js] ### `-p`/`--package-manager`: Node.js package manager If you choose Node.js as the JavaScript runtime, you can specify the package manager by using the `-p`/`--package-manager` option. The available options are: * `npm`: [npm] * `pnpm`: [pnpm] * `yarn`: [Yarn] It's ignored if you choose Deno or Bun as the JavaScript runtime. ### `-w`/`--web-framework`: Web framework You can specify the web framework to integrate with Fedify by using the `-w`/`--web-framework` option. The available options are: * `fresh`: [Fresh] (if Deno) * `hono`: [Hono] * `express`: [Express] (unless Deno) * `nitro`: [Nitro] (unless Deno) If it's omitted, no web framework will be integrated. ### `-k`/`--kv-store`: Key-value store You can specify the key-value store to use by using the `-k`/`--kv-store` option. The available options are: * `redis`: [Redis] * `postgres`: [PostgreSQL] * `denokv`: [Deno KV] (if Deno) If it's omitted, the in-memory key-value store (which is for development purpose) will be used. ### `-q`/`--message-queue`: Message queue You can specify the message queue to use by using the `-q`/`--message-queue` option. The available options are: * `redis`: [Redis] * `postgres`: [PostgreSQL] * `amqp`: [AMQP] (e.g., [RabbitMQ]) * `denokv`: [Deno KV] (if Deno) If it's omitted, the in-process message queue (which is for development purpose) will be used. ## `fedify lookup`: Looking up an ActivityPub object The `fedify lookup` command is used to look up an ActivityPub object by its URL or an actor by its handle. For example, the below command looks up a `Note` object with the given URL: ```sh fedify lookup https://todon.eu/@hongminhee/112341925069749583 ``` The output will be like the below: ``` Note { id: URL "https://todon.eu/users/hongminhee/statuses/112341925069749583", attachments: [ Document { name: "The demo video on my terminal", url: URL "https://todon.eu/system/media_attachments/files/112/341/916/300/016/369/original/f83659866f94054f.mp"... 1 more character, mediaType: "video/mp4" } ], attribution: URL "https://todon.eu/users/hongminhee", contents: [ '
I'm working on adding a CLI toolchain to \[!NOTE]
> The `fedify lookup` command cannot take multiple argument if
> [`-t`/`--traverse`](#t-traverse-traverse-the-collection) option is turned
> on.
### `-t`/`--traverse`: Traverse the collection
*This option is available since Fedify 0.14.0.*
The `-t`/`--traverse` option is used to traverse the collection when looking up
a collection object. For example, the below command looks up a collection
object:
```sh
fedify lookup --traverse https://fosstodon.org/users/hongminhee/outbox
```
The difference between with and without the `-t`/`--traverse` option is that
the former will output the objects in the collection, while the latter will
output the collection object itself.
This option only works with a single argument, and it has to be a collection.
### `-S`/`--suppress-errors`: Suppress partial errors during traversal
*This option is available since Fedify 0.14.0.*
The `-S`/`--suppress-errors` option is used to suppress partial errors during
traversal. For example, the below command looks up a collection object with
the `-t`/`--traverse` option:
```sh
fedify lookup --traverse --suppress-errors https://fosstodon.org/users/hongminhee/outbox
```
The difference between with and without the `-S`/`--suppress-errors` option is
that the former will suppress the partial errors during traversal, while the
latter will stop the traversal when an error occurs.
This option depends on the `-t`/`--traverse` option.
### `-c`/`--compact`: Compact JSON-LD
> \[!NOTE]
> This option is mutually exclusive with `-e`/`--expanded` and `-r`/`--raw`.
You can also output the object in the [compacted JSON-LD] format by using the
`-c`/`--compact` option:
```sh
fedify lookup --compact https://todon.eu/@hongminhee/112341925069749583
```
The output will be like the below:
```json
{
"@context": "https://www.w3.org/ns/activitystreams",
"id": "https://todon.eu/users/hongminhee/statuses/112341925069749583",
"type": "Note",
"attachment": {
"type": "Document",
"mediaType": "video/mp4",
"name": "The demo video on my terminal",
"url": "https://todon.eu/system/media_attachments/files/112/341/916/300/016/369/original/f83659866f94054f.mp4"
},
"attributedTo": "https://todon.eu/users/hongminhee",
"cc": "https://todon.eu/users/hongminhee/followers",
"content": " I'm working on adding a CLI toolchain to #Fedify to help with debugging. The first feature I implemented is the ActivityPub object lookup. Here's a demo. I'm working on adding a CLI toolchain to #Fedify to help with debugging. The first feature I implemented is the ActivityPub object lookup. Here's a demo. I'm working on adding a CLI toolchain to #Fedify to help with debugging. The first feature I implemented is the ActivityPub object lookup. Here's a demo. I'm working on adding a CLI toolchain to #Fedify to help with debugging. The first feature I implemented is the ActivityPub object lookup. Here's a demo. I'm working on adding a CLI toolchain to #Fedify to help with debugging. The first feature I implemented is the ActivityPub object lookup. Here's a demo. I'm working on adding a CLI toolchain to #Fedify to help with debugging. The first feature I implemented is the ActivityPub object lookup. Here's a demo.