aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2016-11-25 23:18:51 +0100
committerGitHub <[email protected]>2016-11-25 23:18:51 +0100
commit3ce225dbeff8dc81539108cad376c0ab7db2125f (patch)
tree8c8994ea4021902b329f8c79a4318f691cbbad36 /docs
parentb958ce54ba32968ef159bda91c8f480c74374f68 (diff)
parent61775d90831704d012b9f3d6c5453ca738bc0724 (diff)
downloadmastodon.py-3ce225dbeff8dc81539108cad376c0ab7db2125f.tar.gz
Merge pull request #3 from halcy/ratelimits
Implement ratelimiting
Diffstat (limited to 'docs')
-rw-r--r--docs/index.rst27
1 files changed, 27 insertions, 0 deletions
diff --git a/docs/index.rst b/docs/index.rst
index e7c9366..02676a4 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -39,6 +39,33 @@ as a single python module. By default, it talks to the
39`Mastodon flagship instance`_, but it can be set to talk to any 39`Mastodon flagship instance`_, but it can be set to talk to any
40node running Mastodon. 40node running Mastodon.
41 41
42A note about rate limits
43------------------------
44Mastodons API rate limits per IP. Mastodon.py has three modes for dealing
45with rate limiting that you can pass to the constructor, "throw", "wait"
46and "pace", "wait" being the default.
47
48In "throw" mode, Mastodon.py makes no attempt to stick to rate limits. When
49a request hits the rate limit, it simply throws a MastodonRateLimitError. This is
50for applications that need to handle all rate limiting themselves (i.e. interactive apps),
51or applications wanting to use Mastodon.py in a multi-threaded context ("wait" and "pace"
52modes are not thread safe).
53
54In "wait" mode, once a request hits the rate limit, Mastodon.py will wait until
55the rate limit resets and then try again, until the request succeeds or an error
56is encountered. This mode is for applications that would rather just not worry about rate limits
57much, don't poll the api all that often, and are okay with a call sometimes just taking
58a while.
59
60In "pace" mode, Mastodon.py will delay each new request after the first one such that,
61if requests were to continue at the same rate, only a certain fraction (set in the
62constructor as ratelimit_pacefactor) of the rate limit will be used up. The fraction can
63be (and by default, is) greater than one. If the rate limit is hit, "pace" behaves like
64"wait". This mode is probably the most advanced one and allows you to just poll in
65a loop without ever sleeping at all yourself. It is for applications that would rather
66just pretend there is no such thing as a rate limit and are fine with sometimes not
67being very interactive.
68
42A note about IDs 69A note about IDs
43---------------- 70----------------
44Mastodons API uses IDs in several places: User IDs, Toot IDs, ... 71Mastodons API uses IDs in several places: User IDs, Toot IDs, ...
Powered by cgit v1.2.3 (git 2.41.0)