0
# User Operations
1
2
Core functionality for authenticated user operations including account information, dashboard access, likes management, following/unfollowing blogs, and social interactions. These methods require valid OAuth credentials and operate on behalf of the authenticated user.
3
4
## Capabilities
5
6
### User Information
7
8
Get information about the currently authenticated user including blog details, follower counts, and account settings.
9
10
```python { .api }
11
def info(self) -> dict:
12
"""
13
Get information about the current authenticated user.
14
15
Returns:
16
dict: User information including name, blogs, follower counts, and preferences
17
"""
18
```
19
20
Usage example:
21
22
```python
23
user_info = client.info()
24
print(f"User: {user_info['response']['user']['name']}")
25
print(f"Blogs: {len(user_info['response']['user']['blogs'])}")
26
```
27
28
### Dashboard Access
29
30
Retrieve posts from the authenticated user's dashboard (home feed) with filtering and pagination options.
31
32
```python { .api }
33
def dashboard(self, **kwargs) -> dict:
34
"""
35
Get dashboard posts for authenticated user.
36
37
Parameters:
38
limit (int, optional): Number of posts to return (default: 20, max: 20)
39
offset (int, optional): Post number to start at for pagination
40
type (str, optional): Filter by post type ('text', 'photo', 'quote', 'link', 'chat', 'audio', 'video')
41
since_id (int, optional): Return posts that have appeared after this ID
42
reblog_info (bool, optional): Include reblog information
43
notes_info (bool, optional): Include notes information
44
45
Returns:
46
dict: Dashboard posts and metadata
47
"""
48
```
49
50
Usage example:
51
52
```python
53
# Get latest 10 posts from dashboard
54
dashboard = client.dashboard(limit=10, reblog_info=True)
55
56
# Get only photo posts
57
photos = client.dashboard(type='photo', limit=5)
58
59
# Get posts since specific ID
60
recent = client.dashboard(since_id=12345)
61
```
62
63
### Likes Management
64
65
Access and manage the authenticated user's liked posts with pagination support.
66
67
```python { .api }
68
def likes(self, **kwargs) -> dict:
69
"""
70
Get liked posts for authenticated user.
71
72
Parameters:
73
limit (int, optional): Number of likes to return (default: 20, max: 20)
74
offset (int, optional): DEPRECATED - Like number to start at for pagination
75
before (int, optional): Timestamp for likes before this time
76
after (int, optional): Timestamp for likes after this time
77
78
Returns:
79
dict: Liked posts and pagination metadata
80
"""
81
```
82
83
Usage example:
84
85
```python
86
# Get recent likes
87
likes = client.likes(limit=10)
88
89
# Get likes before specific timestamp
90
older_likes = client.likes(before=1234567890)
91
```
92
93
### Following Management
94
95
Manage the blogs that the authenticated user follows, including retrieval and follow/unfollow operations.
96
97
```python { .api }
98
def following(self, **kwargs) -> dict:
99
"""
100
Get blogs followed by authenticated user.
101
102
Parameters:
103
limit (int, optional): Number of blogs to return (default: 20, max: 20)
104
offset (int, optional): Blog number to start at for pagination
105
106
Returns:
107
dict: List of followed blogs and total count
108
"""
109
110
def follow(self, blogname: str) -> dict:
111
"""
112
Follow a blog.
113
114
Args:
115
blogname (str): Blog URL to follow (e.g., 'example.tumblr.com' or 'example')
116
117
Returns:
118
dict: Success/failure response
119
"""
120
121
def unfollow(self, blogname: str) -> dict:
122
"""
123
Unfollow a blog.
124
125
Args:
126
blogname (str): Blog URL to unfollow (e.g., 'example.tumblr.com' or 'example')
127
128
Returns:
129
dict: Success/failure response
130
"""
131
```
132
133
Usage examples:
134
135
```python
136
# Get followed blogs
137
followed = client.following(limit=50)
138
print(f"Following {followed['response']['total_blogs']} blogs")
139
140
# Follow a blog
141
client.follow('codingjester.tumblr.com')
142
143
# Unfollow a blog
144
client.unfollow('example-blog') # .tumblr.com suffix is added automatically
145
```
146
147
### Post Interactions
148
149
Like and unlike posts across the Tumblr platform.
150
151
```python { .api }
152
def like(self, id: int, reblog_key: str) -> dict:
153
"""
154
Like a post.
155
156
Args:
157
id (int): The post ID to like
158
reblog_key (str): The reblog key of the post (found in post JSON)
159
160
Returns:
161
dict: Success/failure response
162
"""
163
164
def unlike(self, id: int, reblog_key: str) -> dict:
165
"""
166
Unlike a post.
167
168
Args:
169
id (int): The post ID to unlike
170
reblog_key (str): The reblog key of the post (found in post JSON)
171
172
Returns:
173
dict: Success/failure response
174
"""
175
```
176
177
Usage examples:
178
179
```python
180
# Like a post (ID and reblog_key from post JSON response)
181
response = client.like(123456789, 'abc123def456')
182
183
# Unlike a post
184
response = client.unlike(123456789, 'abc123def456')
185
186
# Example: Like posts from dashboard
187
dashboard = client.dashboard(limit=5)
188
for post in dashboard['response']['posts']:
189
if post['type'] == 'photo': # Only like photo posts
190
client.like(post['id'], post['reblog_key'])
191
```
192
193
## Error Handling
194
195
All user operation methods return JSON responses with standard Tumblr API error handling:
196
197
```python
198
response = client.info()
199
if response.get('meta', {}).get('status') == 200:
200
user_data = response['response']['user']
201
else:
202
print(f"Error: {response.get('meta', {}).get('msg')}")
203
```
204
205
Common error responses:
206
- **401 Unauthorized**: Invalid or expired OAuth credentials
207
- **403 Forbidden**: Action not permitted (e.g., trying to follow private blog)
208
- **404 Not Found**: Blog or post doesn't exist
209
- **429 Too Many Requests**: Rate limit exceeded