Files
tumblr-cli/README.md
2025-08-13 16:09:04 -07:00

2.7 KiB

Tumblr CLI

This is a simple Tumblr CLI for making posts. Use this to automate your posting workflow as a bot, or outsource your posts to your favorite editor and post them that way.

NOTE: This is for making posts only. It's not used to read Tumblr posts in the CLI.

Configuring

Before running, you need to get your oauth key/secret and client key/secret from the Tumblr API. Copy config.example.toml:

cp config.example.toml config.toml

And fill out the appropriate values. Don't forget to put your blog name in there.

Setup

This project uses uv. Any other tool that uses pyproject.toml should hypothetically work. The only dependency is pytumblr2, so making a virtualenv and installing that by itself should be sufficient.

With uv

uv sync
source .venv/bin/activate  # or venv/bin/activate.fish if you're using fish

With virtualenv

python3 -m virtualenv venv
source venv/bin/activate  # or venv/bin/activate.fish if you're using fish
pip3 install pytumblr2

Posting

For the moment, only images and text are supported.

The way I use it is by running:

python3 -m tcli post -t "check out this picture I took" -i path_to_image.png

This will create a post with text followed by an image. You can use multiple content types in any order. Each new flag will create a new content block. For example:

python3 -m tcli post -t "This is the first paragraph" -t "This is the second paragraph" -t "This is the third paragraph"

Sometimes, it is desireable to write a big post in your favorite editor, and then attach that. To do this, you can set the -t argument to start with a @, such as:

python3 -m tcli post -t @post.txt

It will read the contents of post.txt and post that instead.

Autoformatting caveats

Tumblr, by default, does not automatically split up text into paragraphs. However, the CLI will do this for you. If your text chunk has two newlines in a row, e.g.:

This is the first paragraph

This is the second paragraph

These will be split up into independent content blocks. Single newlines will remain preserved.

Reblogging

You can also reblog posts from the CLI. To do this, you can use the -r flag with the post ID, and the -p flag for the blog to reblog from. If you are reblogging, both of these flags are required. For example:

python3 -m tcli post -r 678747728380100608 -p intercal -t "wow intercal, you are so wise"

Other

There are some other options that you may find useful, you can find these by running:

# General options
python3 -m tcli --help
# Options for posting
python3 -m tcli post --help

TODO

  • Video uploads
  • Preserving whitespace flag
  • Raw JSON mode
  • Proper logging