How to Create a Tumblr Blog and Post via API (Step-by-Step Guide)

How to Create a Tumblr Blog and Post via API (Step-by-Step Guide)

AI Reading

Quick summary of this article

This guide explains how to create a Tumblr blog and connect it to the Tumblr API for automated posting. It covers setting up an account, registering an app to get API keys, using OAuth to obtain access tokens, and making a test post with Python code.

  • Start by creating a Tumblr account and confirming your email to activate posting features.
  • Register your app in the Tumblr API Console using http://localhost/ as the callback URL to get your consumer key and secret.
  • Use the OAuth PIN flow to authorize your app and receive access tokens — the article includes a complete Python script for this process.
  • Once authenticated, you can post text, images, or videos programmatically using the pytumblr library.
  • After setup, you can fully automate content publishing, schedule posts, and manage your blog via the API.

How to Create a Tumblr Blog and Post via API

This guide walks you through the full process of creating a Tumblr blog and connecting it to the API for posting content automatically.

Step 1: Create Your Tumblr Account

  • Go to Tumblr and sign up.
  • Choose your blog name and theme.
  • Confirm your email to activate posting features.

Step 2: Register Your App

  • Go to Tumblr API Console.
  • Click + Register application.
  • Fill in the app name, description, and http://localhost/ as the callback URL.

Example OAuth Keys


CONSUMER_KEY = "your_consumer_key_here"
CONSUMER_SECRET = "your_consumer_secret_here"
    

Step 3: Get OAuth Access Tokens

You’ll need to authenticate via OAuth to get your access tokens.
Here’s a sample Python script:


import pytumblr
from requests_oauthlib import OAuth1Session

# Connect to Tumblr API
client = pytumblr.TumblrRestClient(
    CONSUMER_KEY,
    CONSUMER_SECRET,
    ACCESS_TOKEN,
    ACCESS_TOKEN_SECRET
)

print(client.info())
    

Step 4: Make a Test Post

Once authenticated, post something simple to verify your connection.


client.create_text("your-blog-name", state="published", title="Test Post", body="Hello from the API!")
    

Step 5: Done!

Your blog is now connected to the Tumblr API. You can automate posts, schedule content, and even upload images or videos.


import pytumblr
import webbrowser
from requests_oauthlib import OAuth1Session

# ================= CONFIG =================
CONSUMER_KEY = "<YOUR_CONSUMER_KEY>"
CONSUMER_SECRET = "<YOUR_CONSUMER_SECRET>"
# ===========================================

# Step 1: Get request token with out-of-band (PIN) flow
request_token_url = 'https://www.tumblr.com/oauth/request_token'
oauth = OAuth1Session(
    CONSUMER_KEY,
    client_secret=CONSUMER_SECRET,
    callback_uri='oob'  # This tells Tumblr to show PIN instead of redirect
)
fetch_response = oauth.fetch_request_token(request_token_url)

resource_owner_key = fetch_response.get('oauth_token')
resource_owner_secret = fetch_response.get('oauth_token_secret')

# Step 2: Authorize
base_authorization_url = 'https://www.tumblr.com/oauth/authorize'
authorization_url = oauth.authorization_url(base_authorization_url)
print("\nGo to the following URL to authorize this app:")
print(authorization_url)
webbrowser.open(authorization_url)

# Step 3: Get verifier (PIN) code from user
verifier = input("\nEnter the PIN code shown by Tumblr: ").strip()

# Step 4: Get the access token
access_token_url = 'https://www.tumblr.com/oauth/access_token'
oauth = OAuth1Session(
    CONSUMER_KEY,
    client_secret=CONSUMER_SECRET,
    resource_owner_key=resource_owner_key,
    resource_owner_secret=resource_owner_secret,
    verifier=verifier
)
oauth_tokens = oauth.fetch_access_token(access_token_url)

access_token = oauth_tokens['oauth_token']
access_token_secret = oauth_tokens['oauth_token_secret']

print("\n✅ Access Token:", access_token)
print("✅ Access Token Secret:", access_token_secret)

# Step 5: Use pytumblr to make a test post
client = pytumblr.TumblrRestClient(
    CONSUMER_KEY,
    CONSUMER_SECRET,
    access_token,
    access_token_secret
)

print("\nPosting test post to your Tumblr...")
client.create_text("your-blog-name", state="published", title="Test Post", body="Hello from the API!")
print("✅ Post created successfully!")

Leave a Reply

Your email address will not be published. Required fields are marked *