Access authenticated user account information, dashboard content, likes, and following relationships.
Get comprehensive information about the authenticated user and their blogs.
/**
* Get information about the authenticating user and their blogs
* @returns Promise resolving to user information and blog list
*/
userInfo(): Promise<any>;Usage Examples:
// Get user information (requires OAuth authentication)
const userInfo = await client.userInfo();
console.log(userInfo.user.name); // Username
console.log(userInfo.user.likes); // Number of likes
console.log(userInfo.user.following); // Number of blogs following
console.log(userInfo.user.default_post_format); // Default post format
// Access user's blogs
userInfo.user.blogs.forEach(blog => {
console.log(`${blog.name}: ${blog.title}`);
console.log(` Posts: ${blog.posts}`);
console.log(` URL: ${blog.url}`);
console.log(` Primary: ${blog.primary}`);
});Get dashboard posts for the authenticated user (their personalized feed).
/**
* Get dashboard posts for the authenticated user
* @param params - Dashboard filtering and pagination parameters
* @returns Promise resolving to dashboard posts
*/
userDashboard(params?: DashboardParams): Promise<any>;Usage Examples:
// Get recent dashboard posts
const dashboard = await client.userDashboard();
console.log(`Found ${dashboard.posts.length} posts`);
// Get dashboard with pagination
const olderPosts = await client.userDashboard({
limit: 20,
offset: 20
});
// Get dashboard posts since a specific time
const recentPosts = await client.userDashboard({
since_id: 12345,
limit: 50
});
// Filter dashboard posts
const filteredDashboard = await client.userDashboard({
type: 'photo',
reblog_info: true,
notes_info: true
});Get posts that the authenticated user has liked.
/**
* Get likes for the authenticated user
* @param params - Likes filtering and pagination parameters
* @returns Promise resolving to liked posts
*/
userLikes(params?: LikesParams): Promise<any>;Usage Examples:
// Get recent likes
const likes = await client.userLikes();
console.log(`You have liked ${likes.liked_posts.length} posts`);
// Get likes with pagination
const moreLikes = await client.userLikes({
limit: 20,
offset: 20
});
// Get likes before/after specific timestamps
const olderLikes = await client.userLikes({
before: 1461979830, // Unix timestamp
limit: 50
});
const newerLikes = await client.userLikes({
after: 1461979830,
limit: 50
});Get the list of blogs that the authenticated user follows.
/**
* Get blogs the authenticated user follows
* @param params - Following list pagination parameters
* @returns Promise resolving to followed blogs list
*/
userFollowing(params?: FollowingParams): Promise<any>;Usage Examples:
// Get blogs you're following
const following = await client.userFollowing();
console.log(`Following ${following.total_blogs} blogs`);
following.blogs.forEach(blog => {
console.log(`${blog.name}: ${blog.title}`);
console.log(` URL: ${blog.url}`);
console.log(` Updated: ${new Date(blog.updated * 1000)}`);
});
// Get following list with pagination
const moreFollowing = await client.userFollowing({
limit: 20,
offset: 20
});interface DashboardParams {
/** Number of results to return (1-20) */
limit?: number;
/** Post number to start at (0 for most recent) */
offset?: number;
/** Filter by post type */
type?: PostType;
/** Return posts since this ID */
since_id?: number;
/** Include reblog information */
reblog_info?: boolean;
/** Include notes information */
notes_info?: boolean;
}
type PostType = 'text' | 'quote' | 'link' | 'answer' | 'video' | 'audio' | 'photo' | 'chat';interface LikesParams {
/** Number of results to return (1-20) */
limit?: number;
/** Liked post number to start at */
offset?: number;
/** Return posts liked before this timestamp */
before?: number;
/** Return posts liked after this timestamp */
after?: number;
}interface FollowingParams {
/** Number of results to return (1-20) */
limit?: number;
/** Blog number to start at */
offset?: number;
}{
user: {
name: "your-username",
likes: 12345,
following: 567,
default_post_format: "html",
blogs: [
{
name: "your-main-blog",
title: "My Main Blog",
url: "https://your-main-blog.tumblr.com/",
posts: 42,
followers: 789,
primary: true,
admin: true,
type: "public",
updated: 1461979830
},
{
name: "your-side-blog",
title: "My Side Blog",
url: "https://your-side-blog.tumblr.com/",
posts: 15,
followers: 123,
primary: false,
admin: true,
type: "public",
updated: 1461979800
}
]
}
}{
posts: [
{
id: "12345",
type: "text",
blog_name: "some-blog",
timestamp: 1461979830,
date: "2016-04-29 22:23:50 GMT",
format: "html",
reblog_key: "abc123",
tags: ["dashboard", "content"],
title: "Interesting Post",
body: "<p>This appeared in my dashboard...</p>",
note_count: 42,
can_like: true,
can_reblog: true,
can_send_in_message: true,
can_reply: false,
liked: false,
followed: true
}
// ... more posts
]
}{
liked_posts: [
{
id: "67890",
type: "photo",
blog_name: "photography-blog",
timestamp: 1461979830,
liked_timestamp: 1461980000,
photos: [
{
caption: "",
original_size: {
url: "https://example.com/image.jpg",
width: 1280,
height: 720
}
}
]
}
// ... more liked posts
],
liked_count: 12345
}{
blogs: [
{
name: "cool-blog",
title: "Cool Blog Title",
url: "https://cool-blog.tumblr.com/",
description: "A really cool blog about interesting things",
updated: 1461979830,
posts: 456,
followers: 789
}
// ... more followed blogs
],
total_blogs: 567
}All user management methods require OAuth authentication with proper user credentials:
// Must have all OAuth credentials
const client = tumblr.createClient({
consumer_key: 'your-consumer-key',
consumer_secret: 'your-consumer-secret',
token: 'user-oauth-token',
token_secret: 'user-oauth-token-secret'
});
// Will fail without proper authentication
try {
const userInfo = await client.userInfo();
} catch (error) {
console.error('Authentication required:', error.message);
}async function getAllDashboard() {
const allPosts = [];
let offset = 0;
const limit = 20;
while (true) {
const dashboard = await client.userDashboard({ limit, offset });
if (dashboard.posts.length === 0) break;
allPosts.push(...dashboard.posts);
offset += limit;
if (dashboard.posts.length < limit) break;
}
return allPosts;
}async function getLikesInRange(startTime, endTime) {
const likes = [];
let before = endTime;
while (before > startTime) {
const response = await client.userLikes({
before: before,
limit: 20
});
if (response.liked_posts.length === 0) break;
const postsInRange = response.liked_posts.filter(
post => post.liked_timestamp >= startTime
);
likes.push(...postsInRange);
const lastPost = response.liked_posts[response.liked_posts.length - 1];
before = lastPost.liked_timestamp;
if (before <= startTime) break;
}
return likes;
}async function getAllFollowing() {
const allBlogs = [];
let offset = 0;
const limit = 20;
while (true) {
const following = await client.userFollowing({ limit, offset });
if (following.blogs.length === 0) break;
allBlogs.push(...following.blogs);
offset += limit;
// Check if we've reached the total
if (allBlogs.length >= following.total_blogs) break;
}
return allBlogs;
}Common authentication and authorization errors:
try {
const userInfo = await client.userInfo();
} catch (error) {
if (error.message.includes('401')) {
console.error('Authentication failed - check OAuth credentials');
} else if (error.message.includes('403')) {
console.error('Access forbidden - token may be expired');
} else if (error.message.includes('429')) {
console.error('Rate limit exceeded - wait before retrying');
} else {
console.error('Request failed:', error.message);
}
}
// Handle specific dashboard errors
try {
const dashboard = await client.userDashboard({ limit: 100 }); // Invalid limit
} catch (error) {
if (error.message.includes('400')) {
console.error('Invalid parameters - limit must be 1-20');
}
}