0
# User Account Management
1
2
Access authenticated user account information, dashboard content, likes, and following relationships.
3
4
## Capabilities
5
6
### User Information
7
8
Get comprehensive information about the authenticated user and their blogs.
9
10
```javascript { .api }
11
/**
12
* Get information about the authenticating user and their blogs
13
* @returns Promise resolving to user information and blog list
14
*/
15
userInfo(): Promise<any>;
16
```
17
18
**Usage Examples:**
19
20
```javascript
21
// Get user information (requires OAuth authentication)
22
const userInfo = await client.userInfo();
23
24
console.log(userInfo.user.name); // Username
25
console.log(userInfo.user.likes); // Number of likes
26
console.log(userInfo.user.following); // Number of blogs following
27
console.log(userInfo.user.default_post_format); // Default post format
28
29
// Access user's blogs
30
userInfo.user.blogs.forEach(blog => {
31
console.log(`${blog.name}: ${blog.title}`);
32
console.log(` Posts: ${blog.posts}`);
33
console.log(` URL: ${blog.url}`);
34
console.log(` Primary: ${blog.primary}`);
35
});
36
```
37
38
### User Dashboard
39
40
Get dashboard posts for the authenticated user (their personalized feed).
41
42
```javascript { .api }
43
/**
44
* Get dashboard posts for the authenticated user
45
* @param params - Dashboard filtering and pagination parameters
46
* @returns Promise resolving to dashboard posts
47
*/
48
userDashboard(params?: DashboardParams): Promise<any>;
49
```
50
51
**Usage Examples:**
52
53
```javascript
54
// Get recent dashboard posts
55
const dashboard = await client.userDashboard();
56
console.log(`Found ${dashboard.posts.length} posts`);
57
58
// Get dashboard with pagination
59
const olderPosts = await client.userDashboard({
60
limit: 20,
61
offset: 20
62
});
63
64
// Get dashboard posts since a specific time
65
const recentPosts = await client.userDashboard({
66
since_id: 12345,
67
limit: 50
68
});
69
70
// Filter dashboard posts
71
const filteredDashboard = await client.userDashboard({
72
type: 'photo',
73
reblog_info: true,
74
notes_info: true
75
});
76
```
77
78
### User Likes
79
80
Get posts that the authenticated user has liked.
81
82
```javascript { .api }
83
/**
84
* Get likes for the authenticated user
85
* @param params - Likes filtering and pagination parameters
86
* @returns Promise resolving to liked posts
87
*/
88
userLikes(params?: LikesParams): Promise<any>;
89
```
90
91
**Usage Examples:**
92
93
```javascript
94
// Get recent likes
95
const likes = await client.userLikes();
96
console.log(`You have liked ${likes.liked_posts.length} posts`);
97
98
// Get likes with pagination
99
const moreLikes = await client.userLikes({
100
limit: 20,
101
offset: 20
102
});
103
104
// Get likes before/after specific timestamps
105
const olderLikes = await client.userLikes({
106
before: 1461979830, // Unix timestamp
107
limit: 50
108
});
109
110
const newerLikes = await client.userLikes({
111
after: 1461979830,
112
limit: 50
113
});
114
```
115
116
### User Following
117
118
Get the list of blogs that the authenticated user follows.
119
120
```javascript { .api }
121
/**
122
* Get blogs the authenticated user follows
123
* @param params - Following list pagination parameters
124
* @returns Promise resolving to followed blogs list
125
*/
126
userFollowing(params?: FollowingParams): Promise<any>;
127
```
128
129
**Usage Examples:**
130
131
```javascript
132
// Get blogs you're following
133
const following = await client.userFollowing();
134
console.log(`Following ${following.total_blogs} blogs`);
135
136
following.blogs.forEach(blog => {
137
console.log(`${blog.name}: ${blog.title}`);
138
console.log(` URL: ${blog.url}`);
139
console.log(` Updated: ${new Date(blog.updated * 1000)}`);
140
});
141
142
// Get following list with pagination
143
const moreFollowing = await client.userFollowing({
144
limit: 20,
145
offset: 20
146
});
147
```
148
149
## Parameter Types
150
151
### Dashboard Parameters
152
153
```javascript { .api }
154
interface DashboardParams {
155
/** Number of results to return (1-20) */
156
limit?: number;
157
/** Post number to start at (0 for most recent) */
158
offset?: number;
159
/** Filter by post type */
160
type?: PostType;
161
/** Return posts since this ID */
162
since_id?: number;
163
/** Include reblog information */
164
reblog_info?: boolean;
165
/** Include notes information */
166
notes_info?: boolean;
167
}
168
169
type PostType = 'text' | 'quote' | 'link' | 'answer' | 'video' | 'audio' | 'photo' | 'chat';
170
```
171
172
### Likes Parameters
173
174
```javascript { .api }
175
interface LikesParams {
176
/** Number of results to return (1-20) */
177
limit?: number;
178
/** Liked post number to start at */
179
offset?: number;
180
/** Return posts liked before this timestamp */
181
before?: number;
182
/** Return posts liked after this timestamp */
183
after?: number;
184
}
185
```
186
187
### Following Parameters
188
189
```javascript { .api }
190
interface FollowingParams {
191
/** Number of results to return (1-20) */
192
limit?: number;
193
/** Blog number to start at */
194
offset?: number;
195
}
196
```
197
198
## Response Data Examples
199
200
### User Info Response
201
202
```javascript
203
{
204
user: {
205
name: "your-username",
206
likes: 12345,
207
following: 567,
208
default_post_format: "html",
209
blogs: [
210
{
211
name: "your-main-blog",
212
title: "My Main Blog",
213
url: "https://your-main-blog.tumblr.com/",
214
posts: 42,
215
followers: 789,
216
primary: true,
217
admin: true,
218
type: "public",
219
updated: 1461979830
220
},
221
{
222
name: "your-side-blog",
223
title: "My Side Blog",
224
url: "https://your-side-blog.tumblr.com/",
225
posts: 15,
226
followers: 123,
227
primary: false,
228
admin: true,
229
type: "public",
230
updated: 1461979800
231
}
232
]
233
}
234
}
235
```
236
237
### Dashboard Response
238
239
```javascript
240
{
241
posts: [
242
{
243
id: "12345",
244
type: "text",
245
blog_name: "some-blog",
246
timestamp: 1461979830,
247
date: "2016-04-29 22:23:50 GMT",
248
format: "html",
249
reblog_key: "abc123",
250
tags: ["dashboard", "content"],
251
title: "Interesting Post",
252
body: "<p>This appeared in my dashboard...</p>",
253
note_count: 42,
254
can_like: true,
255
can_reblog: true,
256
can_send_in_message: true,
257
can_reply: false,
258
liked: false,
259
followed: true
260
}
261
// ... more posts
262
]
263
}
264
```
265
266
### Likes Response
267
268
```javascript
269
{
270
liked_posts: [
271
{
272
id: "67890",
273
type: "photo",
274
blog_name: "photography-blog",
275
timestamp: 1461979830,
276
liked_timestamp: 1461980000,
277
photos: [
278
{
279
caption: "",
280
original_size: {
281
url: "https://example.com/image.jpg",
282
width: 1280,
283
height: 720
284
}
285
}
286
]
287
}
288
// ... more liked posts
289
],
290
liked_count: 12345
291
}
292
```
293
294
### Following Response
295
296
```javascript
297
{
298
blogs: [
299
{
300
name: "cool-blog",
301
title: "Cool Blog Title",
302
url: "https://cool-blog.tumblr.com/",
303
description: "A really cool blog about interesting things",
304
updated: 1461979830,
305
posts: 456,
306
followers: 789
307
}
308
// ... more followed blogs
309
],
310
total_blogs: 567
311
}
312
```
313
314
## Authentication Requirements
315
316
All user management methods require OAuth authentication with proper user credentials:
317
318
```javascript
319
// Must have all OAuth credentials
320
const client = tumblr.createClient({
321
consumer_key: 'your-consumer-key',
322
consumer_secret: 'your-consumer-secret',
323
token: 'user-oauth-token',
324
token_secret: 'user-oauth-token-secret'
325
});
326
327
// Will fail without proper authentication
328
try {
329
const userInfo = await client.userInfo();
330
} catch (error) {
331
console.error('Authentication required:', error.message);
332
}
333
```
334
335
## Pagination Examples
336
337
### Dashboard Pagination
338
339
```javascript
340
async function getAllDashboard() {
341
const allPosts = [];
342
let offset = 0;
343
const limit = 20;
344
345
while (true) {
346
const dashboard = await client.userDashboard({ limit, offset });
347
348
if (dashboard.posts.length === 0) break;
349
350
allPosts.push(...dashboard.posts);
351
offset += limit;
352
353
if (dashboard.posts.length < limit) break;
354
}
355
356
return allPosts;
357
}
358
```
359
360
### Likes with Timestamp Pagination
361
362
```javascript
363
async function getLikesInRange(startTime, endTime) {
364
const likes = [];
365
let before = endTime;
366
367
while (before > startTime) {
368
const response = await client.userLikes({
369
before: before,
370
limit: 20
371
});
372
373
if (response.liked_posts.length === 0) break;
374
375
const postsInRange = response.liked_posts.filter(
376
post => post.liked_timestamp >= startTime
377
);
378
379
likes.push(...postsInRange);
380
381
const lastPost = response.liked_posts[response.liked_posts.length - 1];
382
before = lastPost.liked_timestamp;
383
384
if (before <= startTime) break;
385
}
386
387
return likes;
388
}
389
```
390
391
### Following List Pagination
392
393
```javascript
394
async function getAllFollowing() {
395
const allBlogs = [];
396
let offset = 0;
397
const limit = 20;
398
399
while (true) {
400
const following = await client.userFollowing({ limit, offset });
401
402
if (following.blogs.length === 0) break;
403
404
allBlogs.push(...following.blogs);
405
offset += limit;
406
407
// Check if we've reached the total
408
if (allBlogs.length >= following.total_blogs) break;
409
}
410
411
return allBlogs;
412
}
413
```
414
415
## Error Handling
416
417
Common authentication and authorization errors:
418
419
```javascript
420
try {
421
const userInfo = await client.userInfo();
422
} catch (error) {
423
if (error.message.includes('401')) {
424
console.error('Authentication failed - check OAuth credentials');
425
} else if (error.message.includes('403')) {
426
console.error('Access forbidden - token may be expired');
427
} else if (error.message.includes('429')) {
428
console.error('Rate limit exceeded - wait before retrying');
429
} else {
430
console.error('Request failed:', error.message);
431
}
432
}
433
434
// Handle specific dashboard errors
435
try {
436
const dashboard = await client.userDashboard({ limit: 100 }); // Invalid limit
437
} catch (error) {
438
if (error.message.includes('400')) {
439
console.error('Invalid parameters - limit must be 1-20');
440
}
441
}
442
```