A Python API v2 wrapper for Tumblr providing comprehensive methods for user, blog, and post operations with OAuth authentication
npx @tessl/cli install tessl/pypi-pytumblr@0.1.0A comprehensive Python client library for the Tumblr API v2, providing OAuth authentication and complete access to user, blog, and post operations. PyTumblr enables developers to build applications that can authenticate users, manage blog content, and perform social media operations programmatically.
pip install pytumblrimport pytumblrDirect class import:
from pytumblr import TumblrRestClientCreating a client:
client = pytumblr.TumblrRestClient(
consumer_key='<consumer_key>',
consumer_secret='<consumer_secret>',
oauth_token='<oauth_token>',
oauth_secret='<oauth_secret>'
)import pytumblr
# Create authenticated client
client = pytumblr.TumblrRestClient(
consumer_key='your_consumer_key',
consumer_secret='your_consumer_secret',
oauth_token='your_oauth_token',
oauth_secret='your_oauth_secret'
)
# Get current user info
user_info = client.info()
print(f"User: {user_info['response']['user']['name']}")
# Get user's dashboard
dashboard = client.dashboard(limit=10)
# Get blog information
blog_info = client.blog_info('codingjester.tumblr.com')
# Create a text post
client.create_text(
'your-blog.tumblr.com',
title='Hello World',
body='This is my first post using PyTumblr!',
state='published',
tags=['python', 'tumblr', 'api']
)
# Like a post
client.like(post_id, reblog_key)PyTumblr is built around three core components:
The client wraps the complete Tumblr API v2 surface, organizing functionality into logical groups: user operations, blog management, and post creation/editing. All methods return parsed JSON responses from the Tumblr API.
Core functionality for authenticated user operations including account information, dashboard access, likes management, following/unfollowing blogs, and social interactions.
def info(self) -> dict:
"""Get information about the current authenticated user"""
def dashboard(self, **kwargs) -> dict:
"""Get dashboard posts for authenticated user"""
def likes(self, **kwargs) -> dict:
"""Get liked posts for authenticated user"""
def following(self, **kwargs) -> dict:
"""Get blogs followed by authenticated user"""
def follow(self, blogname: str) -> dict:
"""Follow a blog"""
def unfollow(self, blogname: str) -> dict:
"""Unfollow a blog"""
def like(self, id: int, reblog_key: str) -> dict:
"""Like a post"""
def unlike(self, id: int, reblog_key: str) -> dict:
"""Unlike a post"""Comprehensive blog management including information retrieval, post access, follower management, queue and draft handling, and blog-specific content operations.
def blog_info(self, blogname: str) -> dict:
"""Get information about a specific blog"""
def posts(self, blogname: str, type: str = None, **kwargs) -> dict:
"""Get posts from a blog"""
def avatar(self, blogname: str, size: int = 64) -> dict:
"""Get blog's avatar URL"""
def followers(self, blogname: str, **kwargs) -> dict:
"""Get followers of a blog"""
def blog_following(self, blogname: str, **kwargs) -> dict:
"""Get publicly exposed blogs that a blog follows"""
def blog_likes(self, blogname: str, **kwargs) -> dict:
"""Get liked posts from a blog"""
def queue(self, blogname: str, **kwargs) -> dict:
"""Get queued posts for a blog"""
def drafts(self, blogname: str, **kwargs) -> dict:
"""Get draft posts for a blog"""
def submission(self, blogname: str, **kwargs) -> dict:
"""Get submission posts for a blog"""Complete post lifecycle management including creation of all Tumblr post types (text, photo, quote, link, chat, audio, video), editing, reblogging, deletion, and notes retrieval.
def create_text(self, blogname: str, **kwargs) -> dict:
"""Create a text post"""
def create_photo(self, blogname: str, **kwargs) -> dict:
"""Create a photo post"""
def create_quote(self, blogname: str, **kwargs) -> dict:
"""Create a quote post"""
def create_link(self, blogname: str, **kwargs) -> dict:
"""Create a link post"""
def create_chat(self, blogname: str, **kwargs) -> dict:
"""Create a chat post"""
def create_audio(self, blogname: str, **kwargs) -> dict:
"""Create an audio post"""
def create_video(self, blogname: str, **kwargs) -> dict:
"""Create a video post"""
def edit_post(self, blogname: str, **kwargs) -> dict:
"""Edit an existing post"""
def reblog(self, blogname: str, **kwargs) -> dict:
"""Reblog a post"""
def delete_post(self, blogname: str, id: int) -> dict:
"""Delete a post"""
def notes(self, blogname: str, id: str, **kwargs) -> dict:
"""Get notes for a specific post"""Discovery and retrieval of posts by tags across the entire Tumblr platform.
def tagged(self, tag: str, **kwargs) -> dict:
"""Get posts with a specific tag"""Direct access to the underlying API request mechanism for custom operations and endpoints not covered by the high-level methods.
def send_api_request(self, method: str, url: str, params: dict = {},
valid_parameters: list = [], needs_api_key: bool = False) -> dict:
"""
Send a direct API request to Tumblr endpoints.
Args:
method (str): HTTP method ('get', 'post', 'delete')
url (str): API endpoint URL (relative to base URL)
params (dict): Request parameters
valid_parameters (list): List of allowed parameter names
needs_api_key (bool): Whether to inject API key for public access
Returns:
dict: Parsed JSON response from API
"""class TumblrRestClient:
"""
Main client class for Tumblr API v2 operations.
Args:
consumer_key (str): Consumer key from Tumblr application
consumer_secret (str): Consumer secret from Tumblr application
oauth_token (str): User-specific OAuth token
oauth_secret (str): User-specific OAuth secret
host (str): API host URL, defaults to https://api.tumblr.com
"""
def __init__(self, consumer_key: str, consumer_secret: str = "",
oauth_token: str = "", oauth_secret: str = "",
host: str = "https://api.tumblr.com"): ...Common parameter types used across post creation methods:
# Common post parameters (available for all post creation methods)
PostCommonParams = {
'state': str, # Post state: 'published', 'draft', 'queue', 'private'
'tags': list, # List of tag strings
'tweet': str, # Custom tweet text
'date': str, # GMT date and time
'format': str, # Post format: 'html' or 'markdown'
'slug': str # URL slug for the post
}
# Pagination parameters
PaginationParams = {
'limit': int, # Number of results to return
'offset': int, # Starting offset for pagination
'before': int, # Timestamp for posts before this time
'after': int # Timestamp for posts after this time
}