aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2017-12-13 21:16:02 +0100
committerLorenz Diener <[email protected]>2017-12-13 21:16:02 +0100
commitb840766ed77ea0cac84ada7cb27a9b23ffda0a09 (patch)
treeb273102657ee5070a9101a1f943c2b9c3b54b807
parent7cf813b9744342d0be82330cf5fb81e85fea5642 (diff)
downloadmastodon.py-b840766ed77ea0cac84ada7cb27a9b23ffda0a09.tar.gz
Add more list endpoints
-rw-r--r--docs/index.rst26
-rw-r--r--mastodon/Mastodon.py57
2 files changed, 74 insertions, 9 deletions
diff --git a/docs/index.rst b/docs/index.rst
index 0c05321..9496da6 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -287,12 +287,12 @@ Notification dicts
287 mastodon.notifications()[0] 287 mastodon.notifications()[0]
288 # Returns the following dictionary: 288 # Returns the following dictionary:
289 { 289 {
290 'id': # id of the notification. 290 'id': # id of the notification
291 'type': # "mention", "reblog", "favourite" or "follow". 291 'type': # "mention", "reblog", "favourite" or "follow"
292 'created_at': # The time the notification was created. 292 'created_at': # The time the notification was created
293 'account': # User dict of the user from whom the notification originates. 293 'account': # User dict of the user from whom the notification originates
294 'status': # In case of "mention", the mentioning status. 294 'status': # In case of "mention", the mentioning status
295 # In case of reblog / favourite, the reblogged / favourited status. 295 # In case of reblog / favourite, the reblogged / favourited status
296 } 296 }
297 297
298Context dicts 298Context dicts
@@ -308,6 +308,19 @@ Context dicts
308 'descendants': # A list of toot dicts 308 'descendants': # A list of toot dicts
309 } 309 }
310 310
311List dicts
312~~~~~~~~~~
313.. _list dict:
314
315.. code-block:: python
316
317 mastodon.list(<numerical id>)
318 # Returns the following dictionary:
319 {
320 'id': # id of the list
321 'title': # title of the list
322 }
323
311Media dicts 324Media dicts
312~~~~~~~~~~~ 325~~~~~~~~~~~
313.. _media dict: 326.. _media dict:
@@ -468,6 +481,7 @@ user could see, as well as hashtag timelines and the public timeline.
468.. automethod:: Mastodon.timeline_public 481.. automethod:: Mastodon.timeline_public
469.. _timeline_hashtag(): 482.. _timeline_hashtag():
470.. automethod:: Mastodon.timeline_hashtag 483.. automethod:: Mastodon.timeline_hashtag
484.. automethod:: Mastodon.timeline_list
471 485
472Reading data: Statuses 486Reading data: Statuses
473---------------------- 487----------------------
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index 0df1217..44e0538 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -325,7 +325,7 @@ class Mastodon:
325 def timeline(self, timeline="home", max_id=None, since_id=None, limit=None): 325 def timeline(self, timeline="home", max_id=None, since_id=None, limit=None):
326 """ 326 """
327 Fetch statuses, most recent ones first. `timeline` can be 'home', 'local', 'public', 327 Fetch statuses, most recent ones first. `timeline` can be 'home', 'local', 'public',
328 or 'tag/hashtag'. See the following functions documentation for what those do. 328 'tag/hashtag' or 'list/id'. See the following functions documentation for what those do.
329 Local hashtag timelines are supported via the `timeline_hashtag()`_ function. 329 Local hashtag timelines are supported via the `timeline_hashtag()`_ function.
330 330
331 The default timeline is the "home" timeline. 331 The default timeline is the "home" timeline.
@@ -407,6 +407,17 @@ class Mastodon:
407 407
408 return self.__api_request('GET', url, params) 408 return self.__api_request('GET', url, params)
409 409
410 @api_version("2.1.0")
411 def timeline_list(self, id, max_id=None, since_id=None, limit=None):
412 """
413 Fetches a timeline containing all the toots by users in a given list.
414
415 Returns a list of `toot dicts`_.
416 """
417 id = self.__unpack_id(id)
418 return self.timeline('list/{0}'.format(id), max_id=max_id,
419 since_id=since_id, limit=limit)
420
410 ### 421 ###
411 # Reading data: Statuses 422 # Reading data: Statuses
412 ### 423 ###
@@ -613,8 +624,6 @@ class Mastodon:
613 Get all of the logged in users lists which the specified user is 624 Get all of the logged in users lists which the specified user is
614 a member of. 625 a member of.
615 626
616 TODO: This doesn't work.
617
618 Returns a list of `list dicts`_. 627 Returns a list of `list dicts`_.
619 """ 628 """
620 params = self.__generate_params(locals(), ['id']) 629 params = self.__generate_params(locals(), ['id'])
@@ -647,6 +656,16 @@ class Mastodon:
647 """ 656 """
648 return self.__api_request('GET', '/api/v1/lists') 657 return self.__api_request('GET', '/api/v1/lists')
649 658
659 @api_version("2.1.0")
660 def list(self, id):
661 """
662 Fetch info about a specific list.
663
664 Returns a `list dict`_.
665 """
666 id = self.__unpack_id(id)
667 return self.__api_request('GET', '/api/v1/lists/{0}'.format(id))
668
650 ### 669 ###
651 # Reading data: Mutes and Blocks 670 # Reading data: Mutes and Blocks
652 ### 671 ###
@@ -1036,6 +1055,38 @@ class Mastodon:
1036 return self.__api_request('PATCH', '/api/v1/accounts/update_credentials', params) 1055 return self.__api_request('PATCH', '/api/v1/accounts/update_credentials', params)
1037 1056
1038 ### 1057 ###
1058 # Writing data: Lists
1059 ###
1060 @api_version("2.1.0")
1061 def list_create(self, title):
1062 """
1063 Create a new list with the given `title`.
1064
1065 Returns the `list dict`_ of the created list.
1066 """
1067 params = self.__generate_params(locals())
1068 return self.__api_request('POST', '/api/v1/lists', params)
1069
1070 @api_version("2.1.0")
1071 def list_update(self, id, title):
1072 """
1073 Update info about a list, where "info" is really the lists `title`.
1074
1075 Returns the `list dict`_ of the modified list.
1076 """
1077 id = self.__unpack_id(id)
1078 params = self.__generate_params(locals(), ['id'])
1079 return self.__api_request('PUT', '/api/v1/lists/{0}'.format(id), params)
1080
1081 @api_version("2.1.0")
1082 def list_delete(self, id):
1083 """
1084 Delete a list.
1085 """
1086 id = self.__unpack_id(id)
1087 self.__api_request('DELETE', '/api/v1/lists/{0}'.format(id))
1088
1089 ###
1039 # Writing data: Reports 1090 # Writing data: Reports
1040 ### 1091 ###
1041 @api_version("1.1.0") 1092 @api_version("1.1.0")
Powered by cgit v1.2.3 (git 2.41.0)