aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2016-11-25 15:39:53 +0100
committerLorenz Diener <[email protected]>2016-11-25 15:39:53 +0100
commit2729ca19319edcc7a0d8df3e211010ccf857b211 (patch)
tree62246a87aa1286933c9d82b217445a9634bb4fcc
parent2a63df2b63d6339e8b6cf75182271caa745ddf5b (diff)
downloadmastodon.py-2729ca19319edcc7a0d8df3e211010ccf857b211.tar.gz
More "timeline" functions, "notifications"
-rw-r--r--CHANGELOG.rst13
-rw-r--r--docs/conf.py2
-rw-r--r--docs/index.rst16
-rw-r--r--mastodon/Mastodon.py44
-rw-r--r--setup.py2
5 files changed, 71 insertions, 6 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
new file mode 100644
index 0000000..e099b66
--- /dev/null
+++ b/CHANGELOG.rst
@@ -0,0 +1,13 @@
1A note on versioning: This librarys major version will grow with the APIs
2version number. Breaking changes will be avoided as far as at all possible.
3
4v.1.0.1
5-------
6 * Added timeline_*() functions for consistency. timeline() functions as before.
7 * Clarified documentation in various places.
8 * Added previously-undocumented notifications() - API that gets a users notifications.
9
10v.1.0.0
11-------
12
13 * Initial Release
diff --git a/docs/conf.py b/docs/conf.py
index 2914f78..a893c03 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -68,7 +68,7 @@ author = u'Lorenz Diener'
68# The short X.Y version. 68# The short X.Y version.
69version = u'1.0' 69version = u'1.0'
70# The full version, including alpha/beta/rc tags. 70# The full version, including alpha/beta/rc tags.
71release = u'1.0.0' 71release = u'1.0.1'
72 72
73# The language for content autogenerated by Sphinx. Refer to documentation 73# The language for content autogenerated by Sphinx. Refer to documentation
74# for a list of supported languages. 74# for a list of supported languages.
diff --git a/docs/index.rst b/docs/index.rst
index 6439f69..a91cfb7 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -37,8 +37,11 @@ as a single python module. By default, it talks to the
37`Mastodon flagship instance`_, but it can be set to talk to any 37`Mastodon flagship instance`_, but it can be set to talk to any
38node running Mastodon. 38node running Mastodon.
39 39
40Unless otherwise specified, all data is returned as python
41dictionaries, matching the JSON format used by the API.
40For complete documentation on what every function returns, 42For complete documentation on what every function returns,
41check the `Mastodon API docs`_, or just play around a bit. 43check the `Mastodon API docs`_, or just play around a bit - the
44format of the data is generally very easy to understand.
42 45
43.. py:module:: mastodon 46.. py:module:: mastodon
44.. py:class: Mastodon 47.. py:class: Mastodon
@@ -68,6 +71,10 @@ This function allows you to access the timelines a logged in
68user could see, as well as hashtag timelines and the public timeline. 71user could see, as well as hashtag timelines and the public timeline.
69 72
70.. automethod:: Mastodon.timeline 73.. automethod:: Mastodon.timeline
74.. automethod:: Mastodon.timeline_home
75.. automethod:: Mastodon.timeline_mentions
76.. automethod:: Mastodon.timeline_public
77.. automethod:: Mastodon.timeline_hashtag
71 78
72Reading data: Statuses 79Reading data: Statuses
73---------------------- 80----------------------
@@ -78,6 +85,13 @@ These functions allow you to get information about single statuses.
78.. automethod:: Mastodon.status_reblogged_by 85.. automethod:: Mastodon.status_reblogged_by
79.. automethod:: Mastodon.status_favourited_by 86.. automethod:: Mastodon.status_favourited_by
80 87
88Reading data: Notifications
89---------------------------
90This function allows you to get information about a users notifications.
91
92.. automethod:: Mastodon.notifications
93
94
81Reading data: Accounts 95Reading data: Accounts
82---------------------- 96----------------------
83These functions allow you to get information about accounts and 97These functions allow you to get information about accounts and
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index e3aac69..7bd6473 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -122,14 +122,40 @@ class Mastodon:
122 ### 122 ###
123 # Reading data: Timelines 123 # Reading data: Timelines
124 ## 124 ##
125 def timeline(self, timeline = 'home', max_id = None, since_id = None, limit = None): 125 def timeline(self, timeline = "home", max_id = None, since_id = None, limit = None):
126 """ 126 """
127 Returns statuses, most recent ones first. Timeline can be home, mentions, public 127 Returns statuses, most recent ones first. Timeline can be home, mentions, public
128 or tag/:hashtag 128 or tag/hashtag. See the following functions documentation for what those do.
129
130 The default timeline is the "home" timeline.
129 """ 131 """
130 params = self.__generate_params(locals(), ['timeline']) 132 params = self.__generate_params(locals(), ['timeline'])
131 return self.__api_request('GET', '/api/v1/timelines/' + timeline, params) 133 return self.__api_request('GET', '/api/v1/timelines/' + timeline, params)
132 134
135 def timeline_home(self, max_id = None, since_id = None, limit = None):
136 """
137 Returns the authenticated users home timeline (i.e. followed users and self).
138 """
139 return self.timeline('home', max_id = max_id, since_id = since_id, limit = limit)
140
141 def timeline_mentions(self, max_id = None, since_id = None, limit = None):
142 """
143 Returns the authenticated users mentions.
144 """
145 return self.timeline('mentions', max_id = max_id, since_id = since_id, limit = limit)
146
147 def timeline_public(self, max_id = None, since_id = None, limit = None):
148 """
149 Returns the public / visible-network timeline.
150 """
151 return self.timeline('public', max_id = max_id, since_id = since_id, limit = limit)
152
153 def timeline_hashtag(self, hashtag, max_id = None, since_id = None, limit = None):
154 """
155 Returns all toots with a given hashtag.
156 """
157 return self.timeline('tag/' + str(hashtag), max_id = max_id, since_id = since_id, limit = limit)
158
133 ### 159 ###
134 # Reading data: Statuses 160 # Reading data: Statuses
135 ### 161 ###
@@ -158,6 +184,16 @@ class Mastodon:
158 return self.__api_request('GET', '/api/v1/statuses/' + str(id) + '/favourited_by') 184 return self.__api_request('GET', '/api/v1/statuses/' + str(id) + '/favourited_by')
159 185
160 ### 186 ###
187 # Reading data: Notifications
188 ###
189 def notifications(self):
190 """
191 Returns notifications (mentions, favourites, reblogs, follows) for the authenticated
192 user.
193 """
194 return self.__api_request('GET', '/api/v1/notifications')
195
196 ###
161 # Reading data: Accounts 197 # Reading data: Accounts
162 ### 198 ###
163 def account(self, id): 199 def account(self, id):
@@ -312,7 +348,9 @@ class Mastodon:
312 type has to be specified manually, otherwise, it is 348 type has to be specified manually, otherwise, it is
313 determined from the file name. 349 determined from the file name.
314 350
315 Returns the ID of the media that can then be used in status_post(). 351 Returns the uploaded media metadata object. Importantly, this contains
352 the ID that can then be used in status_post() to attach the media to
353 a toot.
316 354
317 Throws a ValueError if the mime type of the passed data or file can 355 Throws a ValueError if the mime type of the passed data or file can
318 not be determined properly. 356 not be determined properly.
diff --git a/setup.py b/setup.py
index 6a4df40..74292fd 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
1from setuptools import setup, find_packages 1from setuptools import setup, find_packages
2 2
3setup(name='Mastodon.py', 3setup(name='Mastodon.py',
4 version='1.0.0', 4 version='1.0.1',
5 description='Python wrapper for the Mastodon API', 5 description='Python wrapper for the Mastodon API',
6 packages=['mastodon'], 6 packages=['mastodon'],
7 install_requires=['requests'], 7 install_requires=['requests'],
Powered by cgit v1.2.3 (git 2.41.0)