diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/index.rst | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/docs/index.rst b/docs/index.rst index 14ec49f..fa021d2 100644 --- a/docs/index.rst +++ b/docs/index.rst | |||
@@ -37,7 +37,7 @@ Mastodon.py | |||
37 | ) | 37 | ) |
38 | mastodon.toot('Tooting from python using #mastodonpy !') | 38 | mastodon.toot('Tooting from python using #mastodonpy !') |
39 | 39 | ||
40 | `Mastodon`_ is an ostatus based twitter-like federated social | 40 | `Mastodon`_ is an ActivityPub and OStatus based twitter-like federated social |
41 | network node. It has an API that allows you to interact with its | 41 | network node. It has an API that allows you to interact with its |
42 | every aspect. This is a simple python wrapper for that api, provided | 42 | every aspect. This is a simple python wrapper for that api, provided |
43 | as a single python module. By default, it talks to the | 43 | as a single python module. By default, it talks to the |
@@ -112,23 +112,23 @@ Error handling | |||
112 | When Mastodon.py encounters an error, it will raise an exception, generally with | 112 | When Mastodon.py encounters an error, it will raise an exception, generally with |
113 | some text included to tell you what went wrong. | 113 | some text included to tell you what went wrong. |
114 | 114 | ||
115 | The base class that all mastodon exceptions inherit from is the MastodonError | 115 | The base class that all mastodon exceptions inherit from is `MastodonError`. |
116 | class. If you are only interested in the fact an error was raised somewhere in | 116 | If you are only interested in the fact an error was raised somewhere in |
117 | Mastodon.py, and not the details, this is the exception you can catch. | 117 | Mastodon.py, and not the details, this is the exception you can catch. |
118 | 118 | ||
119 | MastodonIllegalArgumentError is generally a programming problem - you asked the | 119 | `MastodonIllegalArgumentError` is generally a programming problem - you asked the |
120 | API to do something obviously invalid (i.e. specify a privacy scope that does | 120 | API to do something obviously invalid (i.e. specify a privacy scope that does |
121 | not exist). | 121 | not exist). |
122 | 122 | ||
123 | MastodonFileNotFoundError and MastodonNetworkError are IO errors - could be you | 123 | `MastodonFileNotFoundError` and `MastodonNetworkError` are IO errors - could be you |
124 | specified a wrong URL, could be the internet is down or your hard drive is | 124 | specified a wrong URL, could be the internet is down or your hard drive is |
125 | dying. They inherit from MastodonIOError, for easy catching. | 125 | dying. They inherit from MastodonIOError, for easy catching. |
126 | 126 | ||
127 | MastodonAPIError is an error returned from the Mastodon instance - the server | 127 | `MastodonAPIError` is an error returned from the Mastodon instance - the server |
128 | has decided it can't fullfill your request (i.e. you requested info on a user that | 128 | has decided it can't fullfill your request (i.e. you requested info on a user that |
129 | does not exist). | 129 | does not exist). |
130 | 130 | ||
131 | MastodonRatelimitError is raised when you hit an API rate limit. You should try | 131 | `MastodonRatelimitError` is raised when you hit an API rate limit. You should try |
132 | again after a while (see the rate limiting section above). | 132 | again after a while (see the rate limiting section above). |
133 | 133 | ||
134 | Return values | 134 | Return values |
@@ -172,10 +172,10 @@ Toot dicts | |||
172 | 'uri': # Descriptor for the toot | 172 | 'uri': # Descriptor for the toot |
173 | # EG 'tag:mastodon.social,2016-11-25:objectId=<id>:objectType=Status' | 173 | # EG 'tag:mastodon.social,2016-11-25:objectId=<id>:objectType=Status' |
174 | 'url': # URL of the toot | 174 | 'url': # URL of the toot |
175 | 'account': # Account dict for the account which posted the status | 175 | 'account': # User dict for the account which posted the status |
176 | 'in_reply_to_id': # Numerical id of the toot this toot is in response to | 176 | 'in_reply_to_id': # Numerical id of the toot this toot is in response to |
177 | 'in_reply_to_account_id': # Numerical id of the account this toot is in response to | 177 | 'in_reply_to_account_id': # Numerical id of the account this toot is in response to |
178 | 'reblog': # Denotes whether the toot is a reblog | 178 | 'reblog': # Denotes whether the toot is a reblog. If so, set to the original toot dict. |
179 | 'content': # Content of the toot, as HTML: '<p>Hello from Python</p>' | 179 | 'content': # Content of the toot, as HTML: '<p>Hello from Python</p>' |
180 | 'created_at': # Creation time | 180 | 'created_at': # Creation time |
181 | 'reblogs_count': # Number of reblogs | 181 | 'reblogs_count': # Number of reblogs |
@@ -531,10 +531,35 @@ Streaming | |||
531 | --------- | 531 | --------- |
532 | These functions allow access to the streaming API. | 532 | These functions allow access to the streaming API. |
533 | 533 | ||
534 | .. automethod:: Mastodon.user_stream | 534 | If async is False, these methods block forever (or until an |
535 | .. automethod:: Mastodon.public_stream | 535 | exception is raised). |
536 | .. automethod:: Mastodon.hashtag_stream | ||
537 | 536 | ||
537 | If async is True, the listener will listen on another thread and these methods | ||
538 | will return a handle corresponding to the open connection. The | ||
539 | connection may be closed at any time by calling its close() method. | ||
540 | |||
541 | The streaming functions take instances of `StreamListener` as a parameter. | ||
542 | A `CallbackStreamListener` class that allows you to specify function callbacks | ||
543 | directly is included for convenience. | ||
544 | |||
545 | .. automethod:: Mastodon.stream_user | ||
546 | .. automethod:: Mastodon.stream_public | ||
547 | .. automethod:: Mastodon.stream_local | ||
548 | .. automethod:: Mastodon.stream_hashtag | ||
549 | |||
550 | StreamListener | ||
551 | ~~~~~~~~~~~~~~ | ||
552 | |||
553 | .. autoclass:: StreamListener | ||
554 | .. automethod:: StreamListener.on_update | ||
555 | .. automethod:: StreamListener.on_notification | ||
556 | .. automethod:: StreamListener.on_delete | ||
557 | .. automethod:: StreamListener.handle_heartbeat | ||
558 | |||
559 | CallbackStreamListener | ||
560 | ~~~~~~~~~~~~~~~~~~~~~~ | ||
561 | |||
562 | .. autoclass:: CallbackStreamListener | ||
538 | 563 | ||
539 | .. _Mastodon: https://github.com/tootsuite/mastodon | 564 | .. _Mastodon: https://github.com/tootsuite/mastodon |
540 | .. _Mastodon flagship instance: http://mastodon.social/ | 565 | .. _Mastodon flagship instance: http://mastodon.social/ |