0
# User Operations
1
2
Methods for accessing user information, dashboard content, likes, following operations, and user-specific actions. All methods require OAuth authentication.
3
4
## Capabilities
5
6
### User Information
7
8
Gets comprehensive information about the authenticating user and their blogs.
9
10
```javascript { .api }
11
/**
12
* Gets information about the authenticating user and their blogs
13
* @returns Promise resolving to user information including blog list
14
*/
15
userInfo(callback?: TumblrClientCallback): Promise<any>;
16
```
17
18
**Usage Examples:**
19
20
```javascript
21
// Get user info
22
const userInfo = await client.userInfo();
23
console.log(userInfo.user.name);
24
console.log(userInfo.user.blogs.length);
25
26
// Access user's blogs
27
userInfo.user.blogs.forEach(blog => {
28
console.log(`Blog: ${blog.name} - ${blog.title}`);
29
});
30
```
31
32
### User Dashboard
33
34
Retrieves dashboard posts for the authenticating user with optional filtering parameters.
35
36
```javascript { .api }
37
/**
38
* Gets the dashboard posts for the authenticating user
39
* @param params - Optional query parameters for filtering dashboard content
40
* @returns Promise resolving to dashboard posts and metadata
41
*/
42
userDashboard(params?: UserDashboardParams): Promise<any>;
43
44
interface UserDashboardParams {
45
/** The number of results to return: 1–20, inclusive */
46
limit?: number;
47
/** Post number to start at */
48
offset?: number;
49
/** The type of post to return */
50
type?: 'text' | 'quote' | 'link' | 'answer' | 'video' | 'audio' | 'photo' | 'chat';
51
/** Return posts since this timestamp */
52
since_id?: number;
53
/** Indicates whether to return reblog information */
54
reblog_info?: boolean;
55
/** Indicates whether to return notes information */
56
notes_info?: boolean;
57
}
58
```
59
60
**Usage Examples:**
61
62
```javascript
63
// Get recent dashboard posts
64
const dashboard = await client.userDashboard({ limit: 10 });
65
console.log(dashboard.posts);
66
67
// Get photo posts from dashboard
68
const photosPosts = await client.userDashboard({
69
type: 'photo',
70
limit: 5,
71
});
72
73
// Get dashboard with reblog info
74
const detailedDashboard = await client.userDashboard({
75
reblog_info: true,
76
notes_info: true,
77
});
78
```
79
80
### User Likes
81
82
Gets the posts liked by the authenticating user with pagination support.
83
84
```javascript { .api }
85
/**
86
* Gets the likes for the authenticating user
87
* @param params - Optional query parameters for pagination and filtering
88
* @returns Promise resolving to liked posts and metadata
89
*/
90
userLikes(params?: UserLikesParams): Promise<any>;
91
92
interface UserLikesParams {
93
/** The number of results to return: 1–20, inclusive */
94
limit?: number;
95
/** Liked post number to start at */
96
offset?: number;
97
/** Return posts liked before this timestamp */
98
before?: number;
99
/** Return posts liked after this timestamp */
100
after?: number;
101
}
102
```
103
104
**Usage Examples:**
105
106
```javascript
107
// Get user's liked posts
108
const likes = await client.userLikes({ limit: 20 });
109
console.log(`You have liked ${likes.liked_count} posts total`);
110
likes.liked_posts.forEach(post => {
111
console.log(`Liked: ${post.blog_name} - ${post.type} post`);
112
});
113
114
// Get likes with timestamp filtering
115
const recentLikes = await client.userLikes({
116
after: Date.now() - (7 * 24 * 60 * 60 * 1000), // Last week
117
});
118
```
119
120
### User Following
121
122
Retrieves the list of blogs that the authenticating user follows.
123
124
```javascript { .api }
125
/**
126
* Gets the blogs the authenticating user follows
127
* @param params - Optional query parameters for pagination
128
* @returns Promise resolving to list of followed blogs
129
*/
130
userFollowing(params?: UserFollowingParams): Promise<any>;
131
132
interface UserFollowingParams {
133
/** The number of results to return: 1–20, inclusive */
134
limit?: number;
135
/** Result number to start at */
136
offset?: number;
137
}
138
```
139
140
**Usage Examples:**
141
142
```javascript
143
// Get followed blogs
144
const following = await client.userFollowing({ limit: 50 });
145
console.log(`Following ${following.total_blogs} blogs`);
146
following.blogs.forEach(blog => {
147
console.log(`Following: ${blog.name} - ${blog.title}`);
148
});
149
150
// Paginate through all followed blogs
151
let offset = 0;
152
let allBlogs = [];
153
while (true) {
154
const batch = await client.userFollowing({ limit: 20, offset });
155
if (batch.blogs.length === 0) break;
156
allBlogs.push(...batch.blogs);
157
offset += 20;
158
}
159
```
160
161
### Follow Blog
162
163
Follows a blog as the authenticating user using either URL or email.
164
165
```javascript { .api }
166
/**
167
* Follows a blog as the authenticating user
168
* @param params - Blog identification by URL or email
169
* @returns Promise resolving when follow action completes
170
*/
171
followBlog(params: {url: string} | {email: string}): Promise<any>;
172
```
173
174
**Usage Examples:**
175
176
```javascript
177
// Follow blog by URL
178
await client.followBlog({ url: 'https://example.tumblr.com' });
179
180
// Follow blog by short name
181
await client.followBlog({ url: 'example' });
182
183
// Follow blog by email (if supported)
184
await client.followBlog({ email: 'user@example.com' });
185
```
186
187
### Unfollow Blog
188
189
Unfollows a blog as the authenticating user.
190
191
```javascript { .api }
192
/**
193
* Unfollows a blog as the authenticating user
194
* @param params - Blog identification by URL
195
* @returns Promise resolving when unfollow action completes
196
*/
197
unfollowBlog(params: {url: string}): Promise<any>;
198
```
199
200
**Usage Examples:**
201
202
```javascript
203
// Unfollow blog
204
await client.unfollowBlog({ url: 'https://example.tumblr.com' });
205
206
// Unfollow blog by short name
207
await client.unfollowBlog({ url: 'example' });
208
```
209
210
### Like Post
211
212
Likes a specific post as the authenticating user.
213
214
```javascript { .api }
215
/**
216
* Likes a post as the authenticating user
217
* @param postId - ID of the post to like
218
* @param reblogKey - Reblog key of the post to like
219
* @returns Promise resolving when like action completes
220
*/
221
likePost(postId: string, reblogKey: string): Promise<any>;
222
```
223
224
**Usage Examples:**
225
226
```javascript
227
// Like a post (requires post ID and reblog key)
228
await client.likePost('12345678901', 'AbCdEfGh');
229
230
// Like a post from dashboard response
231
const dashboard = await client.userDashboard({ limit: 1 });
232
const post = dashboard.posts[0];
233
await client.likePost(post.id.toString(), post.reblog_key);
234
```
235
236
### Unlike Post
237
238
Removes a like from a specific post as the authenticating user.
239
240
```javascript { .api }
241
/**
242
* Unlikes a post as the authenticating user
243
* @param postId - ID of the post to unlike
244
* @param reblogKey - Reblog key of the post to unlike
245
* @returns Promise resolving when unlike action completes
246
*/
247
unlikePost(postId: string, reblogKey: string): Promise<any>;
248
```
249
250
**Usage Examples:**
251
252
```javascript
253
// Unlike a post (requires post ID and reblog key)
254
await client.unlikePost('12345678901', 'AbCdEfGh');
255
256
// Unlike a post from likes response
257
const likes = await client.userLikes({ limit: 1 });
258
const post = likes.liked_posts[0];
259
await client.unlikePost(post.id.toString(), post.reblog_key);
260
```
261
262
## Authentication Requirements
263
264
All user operations require full OAuth authentication with all four credentials:
265
- `consumer_key`
266
- `consumer_secret`
267
- `token`
268
- `token_secret`
269
270
Public API key authentication will not work for these methods.