aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLydia <[email protected]>2016-11-25 12:52:55 -0500
committerLydia <[email protected]>2016-11-25 12:52:55 -0500
commit0524dd1f2b130fdaddd2d209716bf99236b02a22 (patch)
treef6cdbbf1a4c18f6173beb8ecd3b526d341aec3ad
parent2729ca19319edcc7a0d8df3e211010ccf857b211 (diff)
downloadmastodon.py-0524dd1f2b130fdaddd2d209716bf99236b02a22.tar.gz
Add documentation examples
-rw-r--r--docs/index.rst91
1 files changed, 90 insertions, 1 deletions
diff --git a/docs/index.rst b/docs/index.rst
index a91cfb7..85f1982 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -81,7 +81,20 @@ Reading data: Statuses
81These functions allow you to get information about single statuses. 81These functions allow you to get information about single statuses.
82 82
83.. automethod:: Mastodon.status 83.. automethod:: Mastodon.status
84
85Returns a single toot dict for the given status.
86
84.. automethod:: Mastodon.status_context 87.. automethod:: Mastodon.status_context
88
89.. code-block:: python
90 mastodon.status_context(<numerical id>)
91 # Returns
92 {
93 'descendants': A list of toot dicts
94 'ancestors': A list of toot dicts
95 }
96Note that this can only be called on statuses belonging to the currently logged-in user.
97
85.. automethod:: Mastodon.status_reblogged_by 98.. automethod:: Mastodon.status_reblogged_by
86.. automethod:: Mastodon.status_favourited_by 99.. automethod:: Mastodon.status_favourited_by
87 100
@@ -91,6 +104,8 @@ This function allows you to get information about a users notifications.
91 104
92.. automethod:: Mastodon.notifications 105.. automethod:: Mastodon.notifications
93 106
107Returns a list of toot dicts for toots mentioning the current logged-in user.
108
94 109
95Reading data: Accounts 110Reading data: Accounts
96---------------------- 111----------------------
@@ -99,13 +114,37 @@ their relationships.
99 114
100.. automethod:: Mastodon.account 115.. automethod:: Mastodon.account
101.. automethod:: Mastodon.account_verify_credentials 116.. automethod:: Mastodon.account_verify_credentials
117
118These methods return an account dict:
119.. code-block:: python
120 mastodon.account(<numerical id>)
121 # Returns
122 {
123 'display_name': The user's display name
124 'acct': The user's account name (what you @ them with)
125 'following_count': How many people they follow
126 'url': Their URL; usually 'https://mastodon.social/users/<acct>'
127 'statuses_count': How many statuses they have
128 'followers_count': How many followers they have
129 'avatar': URL for their avatar
130 'note': Their bio
131 'header': URL for their header image
132 'id': Same as <numerical id>
133 'username': Usually same as acct
134 }
135
102.. automethod:: Mastodon.account_statuses 136.. automethod:: Mastodon.account_statuses
103.. automethod:: Mastodon.account_following 137.. automethod:: Mastodon.account_following
104.. automethod:: Mastodon.account_followers 138.. automethod:: Mastodon.account_followers
105.. automethod:: Mastodon.account_relationships 139.. automethod:: Mastodon.account_relationships
140
141See following below for format of relationship dicts.
142
106.. automethod:: Mastodon.account_suggestions 143.. automethod:: Mastodon.account_suggestions
107.. automethod:: Mastodon.account_search 144.. automethod:: Mastodon.account_search
108 145
146Returns a list of user dicts.
147
109Writing data: Statuses 148Writing data: Statuses
110---------------------- 149----------------------
111These functions allow you to post statuses to Mastodon and to 150These functions allow you to post statuses to Mastodon and to
@@ -113,17 +152,56 @@ interact with already posted statuses.
113 152
114.. automethod:: Mastodon.status_post 153.. automethod:: Mastodon.status_post
115.. automethod:: Mastodon.toot 154.. automethod:: Mastodon.toot
116.. automethod:: Mastodon.status_delete
117.. automethod:: Mastodon.status_reblog 155.. automethod:: Mastodon.status_reblog
118.. automethod:: Mastodon.status_unreblog 156.. automethod:: Mastodon.status_unreblog
119.. automethod:: Mastodon.status_favourite 157.. automethod:: Mastodon.status_favourite
120.. automethod:: Mastodon.status_unfavourite 158.. automethod:: Mastodon.status_unfavourite
121 159
160These methods return a toot dict:
161.. code-block:: python
162 mastodon.toot("Hello from Python")
163 # Returns the following dictionary:
164 {
165 'sensitive': Denotes whether the toot is marked sensitive
166 'created_at': Creation time
167 'mentions': A list of account dicts mentioned in the toot
168 'uri': Descriptor for the toot
169 EG 'tag:mastodon.social,2016-11-25:objectId=<id>:objectType=Status'
170 'tags': A list of hashtag dicts used in the toot
171 'in_reply_to_id': Numerical id of the toot this toot is in response to
172 'id': Numerical id of this toot
173 'reblogs_count': Number of reblogs
174 'favourites_count': Number of favourites
175 'reblog': Denotes whether the toot is a reblog
176 'url': URL of the toot
177 'content': Content of the toot, as HTML: '<p>Hello from Python</p>'
178 'favourited': Denotes whether the logged in user has favourited this toot
179 'account': Account dict for the logged in account
180 }
181
182.. automethod:: Mastodon.status_delete
183Returns an empty dict:
184.. code-block:: python
185 mastodon.delete_status(<numerical id>)
186 # Returns
187 {}
188
122Writing data: Accounts 189Writing data: Accounts
123---------------------- 190----------------------
124These functions allow you to interact with other accounts: To (un)follow and 191These functions allow you to interact with other accounts: To (un)follow and
125(un)block. 192(un)block.
126 193
194They return a relationship dict:
195.. code-block:: python
196 mastodon.account_follow(<numerical id>)
197 # Returns
198 {
199 'followed_by': Boolean denoting whether they follow you back
200 'following': Boolean denoting whether you follow them
201 'id': Numerical id (same one as <numerical id>)
202 'blocking': Boolean denoting whether you are blocking them
203 }
204
127.. automethod:: Mastodon.account_follow 205.. automethod:: Mastodon.account_follow
128.. automethod:: Mastodon.account_unfollow 206.. automethod:: Mastodon.account_unfollow
129.. automethod:: Mastodon.account_block 207.. automethod:: Mastodon.account_block
@@ -137,6 +215,17 @@ to attach media to statuses.
137 215
138.. automethod:: Mastodon.media_post 216.. automethod:: Mastodon.media_post
139 217
218Returns a media dict:
219.. code-block:: python
220 mastodon.media_post("image.jpg", "image/jpeg")
221 # Returns
222 {
223 'text_url': The display text for the media (what shows up in toots)
224 'preview_url': The URL for the media preview on Amazon S3
225 'type': Media type, EG 'image'
226 'url': The URL for the media on Amazon S3
227 }
228
140.. _Mastodon: https://github.com/Gargron/mastodon 229.. _Mastodon: https://github.com/Gargron/mastodon
141.. _Mastodon flagship instance: http://mastodon.social/ 230.. _Mastodon flagship instance: http://mastodon.social/
142.. _Mastodon api docs: https://github.com/Gargron/mastodon/wiki/API 231.. _Mastodon api docs: https://github.com/Gargron/mastodon/wiki/API
Powered by cgit v1.2.3 (git 2.41.0)