aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2016-11-24 03:03:52 +0100
committerLorenz Diener <[email protected]>2016-11-24 03:03:52 +0100
commit04406738f2a99f8acc8c7edb8c552712a12e4d0a (patch)
treebf9f543b3d06af9069be128c769bb0b4e028f0f9
parent27c343a5b164f8063470c8e76c6963fd067dd3d6 (diff)
downloadmastodon.py-04406738f2a99f8acc8c7edb8c552712a12e4d0a.tar.gz
Docs are now good
-rw-r--r--docs/index.rst130
-rw-r--r--mastodon/Mastodon.py2
2 files changed, 116 insertions, 16 deletions
diff --git a/docs/index.rst b/docs/index.rst
index 2780eaa..06c3678 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -1,25 +1,125 @@
1.. py:currentmodule:: mastodon
2.. py:class:: Mastodon
3
4Mastodon.py 1Mastodon.py
5=========== 2===========
6 3
7App creation and auth 4.. code-block:: python
8--------------------- 5
6 from mastodon import Mastodon
7
8 # Register app - only once!
9 '''
10 Mastodon.create_app(
11 'pytooterapp',
12 to_file = 'pytooter_clientcred.txt'
13 )
14 '''
15
16 # Log in - either every time, or use persisted
17 '''
18 mastodon = Mastodon(client_id = 'pytooter_clientcred.txt')
19 mastodon.log_in(
20 'pytooter',
21 'incrediblygoodpassword',
22 to_file = 'pytooter_usercred.txt'
23 )
24 '''
25
26 # Create actual instance
27 mastodon = Mastodon(
28 client_id = 'pytooter_clientcred.txt',
29 access_token = 'pytooter_usercred.txt'
30 )
31 mastodon.toot('Tooting from python!')
9 32
10Before you can use the mastodon API, you have to register your application (which gets you a client key and client secret) 33`Mastodon`_ is an ostatus based twitter-like federated social
11and then log in (which gets you an access token). These functions allow you to do those things. 34network node. It has an API that allows you to interact with its
12For convenience, once you have a client id, secret and access token, you can simply pass them to the constructor of the class, too! 35every aspect. This is a simple python wrapper for that api, provided
36as a single python module. By default, it talks to the
37`Mastodon flagship instance`_, but it can be set to talk to any
38node running Mastodon.
13 39
14Note that while it is perfectly reasonable to log back in whenever your app starts, registering a new application on every 40For complete documentation on what every function returns,
15startup is not, so don't do that - instead, register an application once, and then persist your client id and secret. Convenience 41check the `Mastodon API docs`_, or just play around a bit.
42
43.. py:module:: mastodon
44.. py:class: Mastodon
45
46App registration and user authentication
47----------------------------------------
48Before you can use the mastodon API, you have to register your
49application (which gets you a client key and client secret)
50and then log in (which gets you an access token). These functions
51allow you to do those things.
52For convenience, once you have a client id, secret and access token,
53you can simply pass them to the constructor of the class, too!
54
55Note that while it is perfectly reasonable to log back in whenever
56your app starts, registering a new application on every
57startup is not, so don't do that - instead, register an application
58once, and then persist your client id and secret. Convenience
16methods for this are provided. 59methods for this are provided.
17 60
18.. autofunction:: create_app 61.. automethod:: Mastodon.create_app
19.. automethod:: __init__ 62.. automethod:: Mastodon.__init__
20.. automethod:: log_in 63.. automethod:: Mastodon.log_in
64
65Reading data: Timelines
66-----------------------
67This function allows you to access the timelines a logged in
68user could see, as well as hashtag timelines and the public timeline.
69
70.. automethod:: Mastodon.timeline
71
72Reading data: Statuses
73----------------------
74These functions allow you to get information about single statuses.
75
76.. automethod:: Mastodon.status
77.. automethod:: Mastodon.status_context
78.. automethod:: Mastodon.status_reblogged_by
79.. automethod:: Mastodon.status_favourited_by
80
81Reading data: Accounts
82----------------------
83These functions allow you to get information about accounts and
84their relationships.
85
86.. automethod:: Mastodon.account
87.. automethod:: Mastodon.account_statuses
88.. automethod:: Mastodon.account_following
89.. automethod:: Mastodon.account_followers
90.. automethod:: Mastodon.account_relationships
91.. automethod:: Mastodon.account_suggestions
92.. automethod:: Mastodon.account_search
93
94Writing data: Statuses
95----------------------
96These functions allow you to post statuses to Mastodon and to
97interact with already posted statuses.
98
99.. automethod:: Mastodon.status_post
100.. automethod:: Mastodon.toot
101.. automethod:: Mastodon.status_delete
102.. automethod:: Mastodon.status_reblog
103.. automethod:: Mastodon.status_unreblog
104.. automethod:: Mastodon.status_favourite
105.. automethod:: Mastodon.status_unfavourite
106
107Writing data: Accounts
108----------------------
109These functions allow you to interact with other accounts: To (un)follow and
110(un)block.
21 111
22Reading timelines 112.. automethod:: Mastodon.account_follow
23----------------- 113.. automethod:: Mastodon.account_unfollow
114.. automethod:: Mastodon.account_block
115.. automethod:: Mastodon.account_unblock
24 116
117Writing data: Media
118-------------------
119This function allows you to upload media to Mastodon. Except it
120doesn't, because it is currently broken. But it will.
121.. automethod:: media_post
25 122
123.. _Mastodon: https://github.com/Gargron/mastodon
124.. _Mastodon flagship instance: http://mastodon.social/
125.. _Mastodon api docs: https://github.com/Gargron/mastodon/wiki/API
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index 8d54455..558d1c1 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -253,7 +253,7 @@ class Mastodon:
253 return self.__api_request('POST', '/api/v1/statuses/' + str(id) + "/unfavourite") 253 return self.__api_request('POST', '/api/v1/statuses/' + str(id) + "/unfavourite")
254 254
255 ### 255 ###
256 # Writing data: Statuses 256 # Writing data: Accounts
257 ### 257 ###
258 def account_follow(self, id): 258 def account_follow(self, id):
259 """ 259 """
Powered by cgit v1.2.3 (git 2.41.0)