Retrieve comprehensive blog information, posts, and various blog-specific content including queue, drafts, submissions, and avatars.
Get detailed information about a specific blog.
/**
* Get information about a blog
* @param blogIdentifier - Blog name or URL
* @param params - Optional field selection parameters
* @returns Promise resolving to blog information
*/
blogInfo(blogIdentifier: string, params?: { 'fields[blogs]'?: string }): Promise<any>;Usage Examples:
// Get basic blog information
const blogInfo = await client.blogInfo('staff');
console.log(blogInfo.blog.title); // "Tumblr Staff"
console.log(blogInfo.blog.description); // Blog description
console.log(blogInfo.blog.total_posts); // Total post count
// Get specific fields only
const limitedInfo = await client.blogInfo('staff', {
'fields[blogs]': 'name,title,description,url'
});Retrieve posts from a blog with extensive filtering and pagination options.
/**
* Get posts for a blog
* @param blogIdentifier - Blog name or URL
* @param params - Post filtering and pagination parameters
* @returns Promise resolving to blog posts
*/
blogPosts(blogIdentifier: string, params?: BlogPostsParams): Promise<any>;Usage Examples:
// Get recent posts
const recentPosts = await client.blogPosts('staff');
console.log(recentPosts.posts.length);
// Get specific post by ID
const specificPost = await client.blogPosts('staff', {
id: '12345'
});
// Filter by post type
const photoPosts = await client.blogPosts('staff', {
type: 'photo',
limit: 20
});
// Filter by tags (posts must have ALL specified tags)
const taggedPosts = await client.blogPosts('staff', {
tag: ['announcement', 'features'],
limit: 10
});
// Get posts with additional metadata
const detailedPosts = await client.blogPosts('staff', {
reblog_info: true,
notes_info: true,
npf: true // Return NPF format instead of legacy
});
// Pagination
const olderPosts = await client.blogPosts('staff', {
limit: 20,
offset: 20
});Get queued posts for a blog (requires authentication and blog ownership).
/**
* Get the queue for a blog
* @param blogIdentifier - Blog name or URL
* @param params - Queue filtering parameters
* @returns Promise resolving to queued posts
*/
blogQueue(blogIdentifier: string, params?: QueueParams): Promise<any>;Usage Examples:
// Get all queued posts
const queuedPosts = await client.blogQueue('myblog');
// Get limited queue with filtering
const queue = await client.blogQueue('myblog', {
limit: 10,
offset: 0,
filter: 'text' // 'text' or 'raw'
});Get draft posts for a blog (requires authentication and blog ownership).
/**
* Get drafts for a blog
* @param blogIdentifier - Blog name or URL
* @param params - Draft filtering parameters
* @returns Promise resolving to draft posts
*/
blogDrafts(blogIdentifier: string, params?: DraftsParams): Promise<any>;Usage Examples:
// Get all drafts
const drafts = await client.blogDrafts('myblog');
// Get drafts with filtering
const recentDrafts = await client.blogDrafts('myblog', {
before_id: 67890,
filter: 'text'
});Get submission posts for a blog (requires authentication and blog ownership).
/**
* Get submissions for a blog
* @param blogIdentifier - Blog name or URL
* @param params - Submission filtering parameters
* @returns Promise resolving to submission posts
*/
blogSubmissions(blogIdentifier: string, params?: SubmissionsParams): Promise<any>;Usage Examples:
// Get all submissions
const submissions = await client.blogSubmissions('myblog');
// Get submissions with pagination
const pagedSubmissions = await client.blogSubmissions('myblog', {
offset: 10,
filter: 'raw'
});Get the avatar URL for a blog in various sizes.
/**
* Get avatar URL for a blog
* @param blogIdentifier - Blog name or URL
* @param size - Avatar size in pixels
* @returns Promise resolving to avatar URL data
*/
blogAvatar(blogIdentifier: string, size?: AvatarSize): Promise<any>;Usage Examples:
// Get default avatar size
const avatar = await client.blogAvatar('staff');
console.log(avatar.avatar_url);
// Get specific avatar size
const largeAvatar = await client.blogAvatar('staff', 512);
const smallAvatar = await client.blogAvatar('staff', 64);interface BlogPostsParams {
/** Specific post ID - returns single post or 404 */
id?: string;
/** Filter by tags - posts must have ALL specified tags (max 4) */
tag?: string | string[];
/** Filter by post type */
type?: PostType;
/** Number of posts to return (1-20) */
limit?: number;
/** Offset for pagination (0 to start from first post) */
offset?: number;
/** Include reblog information */
reblog_info?: boolean;
/** Include notes information and metadata */
notes_info?: boolean;
/** Return NPF format instead of legacy format */
npf?: boolean;
}
type PostType = 'text' | 'quote' | 'link' | 'answer' | 'video' | 'audio' | 'photo' | 'chat';interface QueueParams {
/** Number of posts to return */
limit?: number;
/** Offset for pagination */
offset?: number;
/** Post format filter */
filter?: PostFormatFilter;
}
type PostFormatFilter = 'text' | 'raw';interface DraftsParams {
/** Return drafts before this post ID */
before_id?: number;
/** Post format filter */
filter?: PostFormatFilter;
}interface SubmissionsParams {
/** Offset for pagination */
offset?: number;
/** Post format filter */
filter?: PostFormatFilter;
}type AvatarSize = 16 | 24 | 30 | 40 | 48 | 64 | 96 | 128 | 512;{
blog: {
title: "Tumblr Staff",
name: "staff",
total_posts: 1682,
posts: 1682,
url: "https://staff.tumblr.com/",
updated: 1461979830,
description: "The world's *first* content-free social network",
is_nsfw: false,
ask: false,
ask_anon: false,
followed: true,
can_send_fan_mail: true,
share_likes: false,
subscribed: false,
can_subscribe: true
}
}{
posts: [
{
id: "12345",
type: "text",
blog_name: "staff",
timestamp: 1461979830,
date: "2016-04-29 22:23:50 GMT",
format: "html",
reblog_key: "abc123",
tags: ["announcement", "features"],
title: "New Features!",
body: "<p>We've added some great new features...</p>",
note_count: 42,
summary: "New features announcement"
}
// ... more posts
],
total_posts: 1682
}blogInfo() - Basic blog informationblogPosts() - Public blog postsblogAvatar() - Blog avatar URLsblogInfo() - Enhanced blog informationblogPosts() - Enhanced post data and filteringblogQueue() - Requires blog ownershipblogDrafts() - Requires blog ownershipblogSubmissions() - Requires blog ownershipCommon error scenarios and handling:
try {
const posts = await client.blogPosts('nonexistent-blog');
} catch (error) {
if (error.message.includes('404')) {
console.error('Blog not found');
} else if (error.message.includes('403')) {
console.error('Blog is private or restricted');
}
}
try {
const queue = await client.blogQueue('someone-elses-blog');
} catch (error) {
if (error.message.includes('401')) {
console.error('Authentication required');
} else if (error.message.includes('403')) {
console.error('Not authorized to access this blog\'s queue');
}
}async function getAllPosts(blogName) {
const allPosts = [];
let offset = 0;
const limit = 20;
while (true) {
const response = await client.blogPosts(blogName, { limit, offset });
if (response.posts.length === 0) {
break; // No more posts
}
allPosts.push(...response.posts);
offset += limit;
if (response.posts.length < limit) {
break; // Last page
}
}
return allPosts;
}async function getAllDrafts(blogName) {
const allDrafts = [];
let beforeId = null;
while (true) {
const params = beforeId ? { before_id: beforeId } : {};
const response = await client.blogDrafts(blogName, params);
if (response.posts.length === 0) {
break;
}
allDrafts.push(...response.posts);
beforeId = response.posts[response.posts.length - 1].id;
}
return allDrafts;
}