1Net::Twitter::Role::RatUesLeirmiCto(n3t)ributed Perl DocNuemte:n:tTawtiitotner::Role::RateLimit(3)
2
3
4

NAME

6       Net::Twitter::Role::RateLimit - Rate limit features for Net::Twitter
7

VERSION

9       version 4.01043
10

SYNOPSIS

12           use Net::Twitter;
13           my $nt = Net::Twitter->new(
14               traits => [qw/API::REST RateLimit/],
15               %other_options,
16           );
17
18           #...later
19
20           sleep $nt->until_rate(1.0) || $minimum_wait;
21

NOTE!

23       RateLimit only works with Twitter API v1. The rate limiting strategy of
24       Twitter API v1.1 is very different. A v1.1 compatible RateLimit role
25       may be coming, but isn't available, yet. It's interface will
26       necessarily be different.
27

DESCRIPTION

29       This provides utility methods that return information about the current
30       rate limit status.
31

METHODS

33       If current rate limit data is not resident, these methods will force a
34       call to "rate_limit_status".  Therefore, any of these methods can throw
35       an error.
36
37       rate_remaining
38           Returns the number of API calls available before the next reset.
39
40       rate_reset
41           Returns the Unix epoch time of the next reset.
42
43       rate_limit
44           Returns the current hourly rate limit.
45
46       rate_ratio
47           Returns remaining API call limit, divided by the time remaining
48           before the next reset, as a ratio of the total rate limit per hour.
49
50           For example, if "rate_limit" is 150, the total rate is 150 API
51           calls per hour.  If "rate_remaining" is 75, and there 1800 seconds
52           (1/2 hour) remaining before the next reset, "rate_ratio" returns
53           1.0, because there are exactly enough API calls remaining to
54           maintain he full rate of 150 calls per hour.
55
56           If "rate_remaining" is 30 and there are 360 seconds remaining
57           before reset, "rate_ratio" returns 2.0, because there are enough
58           API calls remaining to maintain twice the full rate of 150 calls
59           per hour.
60
61           As a final example, if "rate_remaining" is 15, and there are 7200
62           seconds remaining before reset, "rate_ratio" returns 0.5, because
63           there are only enough API calls remaining to maintain half the full
64           rate of 150 calls per hour.
65
66       until_rate($target_ratio)
67           Returns the number of seconds to wait before making another rate
68           limited API call such that $target_ratio of the full rate would be
69           available.  It always returns a number greater than, or equal to
70           zero.
71
72           Use a target rate of 1.0 in a timeline polling loop to get a steady
73           polling rate, using all the allocated calls, and adjusted for other
74           API calls as they occur.
75
76           Use a target rate < 1.0 to allow a process to make calls as fast as
77           possible but not consume all of the calls available, too soon.  For
78           example, if you have a process building a large social graph, you
79           may want to allow it make as many calls as possible, with no wait,
80           until 20% of the available rate remains.  Use a value of 0.2 for
81           that purpose.
82
83           A target rate > than 1.0 can be used for a process that should only
84           use "extra" available API calls.  This is useful for an application
85           that requires most of it's rate limit for normal operation.
86

AUTHOR

88       Marc Mims <marc@questright.com>
89

LICENSE

91       Copyright (c) 2016 Marc Mims
92
93       This library is free software; you can redistribute it and/or modify it
94       under the same terms as Perl itself.
95
96
97
98perl v5.32.0                      2020-07-28  Net::Twitter::Role::RateLimit(3)
Impressum