{ "info": { "author": "Tomas Basham", "author_email": "me@tomasbasham.co.uk", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python", "Topic :: Software Development" ], "description": "ratelimit |build| |maintainability|\n===================================\n\n.. |build| image:: https://travis-ci.org/tomasbasham/ratelimit.svg?branch=master\n :target: https://travis-ci.org/tomasbasham/ratelimit\n\n.. |maintainability| image:: https://api.codeclimate.com/v1/badges/21dc7c529c35cd7ef732/maintainability\n :target: https://codeclimate.com/github/tomasbasham/ratelimit/maintainability\n :alt: Maintainability\n\nAPIs are a very common way to interact with web services. As the need to\nconsume data grows, so does the number of API calls necessary to remain up to\ndate with data sources. However many API providers constrain developers from\nmaking too many API calls. This is know as rate limiting and in a worst case\nscenario your application can be banned from making further API calls if it\nabuses these limits.\n\nThis packages introduces a function decorator preventing a function from being\ncalled more often than that allowed by the API provider. This should prevent\nAPI providers from banning your applications by conforming to their rate\nlimits.\n\nInstallation\n------------\n\nPyPi\n~~~~\n\nTo install ratelimit, simply:\n\n.. code:: bash\n\n $ pip install ratelimit\n\nGitHub\n~~~~~~\n\nInstalling the latest version from Github:\n\n.. code:: bash\n\n $ git clone https://github.com/tomasbasham/ratelimit\n $ cd ratelimit\n $ python setup.py install\n\nUsage\n-----\n\nTo use this package simply decorate any function that makes an API call:\n\n.. code:: python\n\n from ratelimit import limits\n\n import requests\n\n FIFTEEN_MINUTES = 900\n\n @limits(calls=15, period=FIFTEEN_MINUTES)\n def call_api(url):\n response = requests.get(url)\n\n if response.status_code != 200:\n raise Exception('API response: {}'.format(response.status_code))\n return response\n\nThis function will not be able to make more then 15 API call within a 15 minute\ntime period.\n\nThe arguments passed into the decorator describe the number of function\ninvocation allowed over a specified time period (in seconds). If no time period\nis specified then it defaults to 15 minutes (the time window imposed by\nTwitter).\n\nIf a decorated function is called more times than that allowed within the\nspecified time period then a ``ratelimit.RateLimitException`` is raised. This\nmay be used to implement a retry strategy such as an `expoential backoff\n`_\n\n.. code:: python\n\n from ratelimit import limits, RateLimitException\n from backoff import on_exception, expo\n\n import requests\n\n FIFTEEN_MINUTES = 900\n\n @on_exception(expo, RateLimitException, max_tries=8)\n @limits(calls=15, period=FIFTEEN_MINUTES)\n def call_api(url):\n response = requests.get(url)\n\n if response.status_code != 200:\n raise Exception('API response: {}'.format(response.status_code))\n return response\n\nAlternatively to cause the current thread to sleep until the specified time\nperiod has ellapsed and then retry the function use the ``sleep_and_retry``\ndecorator. This ensures that every function invocation is successful at the\ncost of halting the thread.\n\n.. code:: python\n\n from ratelimit import limits, sleep_and_retry\n\n import requests\n\n FIFTEEN_MINUTES = 900\n\n @sleep_and_retry\n @limits(calls=15, period=FIFTEEN_MINUTES)\n def call_api(url):\n response = requests.get(url)\n\n if response.status_code != 200:\n raise Exception('API response: {}'.format(response.status_code))\n return response\n\nContributing\n------------\n\n1. Fork it (https://github.com/tomasbasham/ratelimit/fork)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/tomasbasham/ratelimit", "keywords": "ratelimit,api,decorator", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "ratelimit", "package_url": "https://pypi.org/project/ratelimit/", "platform": "", "project_url": "https://pypi.org/project/ratelimit/", "project_urls": { "Homepage": "https://github.com/tomasbasham/ratelimit" }, "release_url": "https://pypi.org/project/ratelimit/2.2.1/", "requires_dist": null, "requires_python": "", "summary": "API rate limit decorator", "version": "2.2.1" }, "last_serial": 4609145, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "91453169365356a088e64de7200a2222", "sha256": "a7d663ccdba7c546c293f33cf16e3228c105404937b08c9cddd12f65548b1bdc" }, "downloads": -1, "filename": "ratelimit-0.0.1.tar.gz", "has_sig": false, "md5_digest": "91453169365356a088e64de7200a2222", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2699, "upload_time": "2015-08-26T21:37:00", "url": "https://files.pythonhosted.org/packages/ae/f1/dae1e1501e4b73e4ad161638a9ae4f450b79620aa4f7025105f828ea75d4/ratelimit-0.0.1.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "6e80b45b1e4a967ac893b8089edfd6fe", "sha256": "9caffd13bd0e49cc3dc155a7c1d5816ba929522ce7372968d3177d17e0bff7c9" }, "downloads": -1, "filename": "ratelimit-1.0.1.tar.gz", "has_sig": false, "md5_digest": "6e80b45b1e4a967ac893b8089edfd6fe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3523, "upload_time": "2016-05-22T12:54:34", "url": "https://files.pythonhosted.org/packages/65/90/9f43fda88fecbada2cb3bdc531562c67800c9ffb4f2b407d6766fa3c39e6/ratelimit-1.0.1.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "456a0c76fe33a8f325d43e9967f74686", "sha256": "a64faacd9ac4a79a3cb274b43e0160c25c96724156f606525ed8d2d924991cf6" }, "downloads": -1, "filename": "ratelimit-1.1.0.tar.gz", "has_sig": false, "md5_digest": "456a0c76fe33a8f325d43e9967f74686", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3478, "upload_time": "2016-05-24T19:18:22", "url": "https://files.pythonhosted.org/packages/d8/86/3fed15cc23cc139b3f2fd8c92d78c93df70dea10cd7c058758b23c1a2144/ratelimit-1.1.0.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "b26c1a0df0f4e5850ea11685c25341a3", "sha256": "83b7fd39105dba2279554c93b5ea6681ca1599e59b887fe518501394142a0a9a" }, "downloads": -1, "filename": "ratelimit-1.2.0.tar.gz", "has_sig": false, "md5_digest": "b26c1a0df0f4e5850ea11685c25341a3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3846, "upload_time": "2017-02-13T16:42:41", "url": "https://files.pythonhosted.org/packages/b7/b6/cfb77fb0df650b0f30ebdd9d18095b61ad0869647d3bde75d68c9d005662/ratelimit-1.2.0.tar.gz" } ], "1.3.0": [ { "comment_text": "", "digests": { "md5": "f620e775ec16f682f5b867f0db325a28", "sha256": "8d7195466a60e34cab90aef8e14428abd98e66a41b2cb6e1d4c253396d8ed013" }, "downloads": -1, "filename": "ratelimit-1.3.0.tar.gz", "has_sig": false, "md5_digest": "f620e775ec16f682f5b867f0db325a28", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3840, "upload_time": "2017-05-31T12:55:46", "url": "https://files.pythonhosted.org/packages/3a/f0/be0555df8813e0b3b92d2c51bcca00d645da9b07d453054643e9580bcaa8/ratelimit-1.3.0.tar.gz" } ], "1.4.0": [ { "comment_text": "", "digests": { "md5": "2046fa31d6cfdda8e4bca21c15884164", "sha256": "2a791bdf4b5050a409f9e6fe806f45743f7987562fdfe7d242f921a293946aea" }, "downloads": -1, "filename": "ratelimit-1.4.0.tar.gz", "has_sig": false, "md5_digest": "2046fa31d6cfdda8e4bca21c15884164", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3956, "upload_time": "2017-08-05T15:44:19", "url": "https://files.pythonhosted.org/packages/f0/e8/a56a32baab4da0773fd222891b0c22a4920c8f8f41191c837073e48bd821/ratelimit-1.4.0.tar.gz" } ], "1.4.1": [ { "comment_text": "", "digests": { "md5": "a96c9dfd9065ec35d4840dd43bdd5a53", "sha256": "d001f4dacf4880f64dafb5bc6ef0cc882aa94f291c623bbcf080e0a882e62351" }, "downloads": -1, "filename": "ratelimit-1.4.1.tar.gz", "has_sig": false, "md5_digest": "a96c9dfd9065ec35d4840dd43bdd5a53", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3992, "upload_time": "2017-08-06T19:24:20", "url": "https://files.pythonhosted.org/packages/8c/d0/5bae27276cf5de5cbec5a60195d4bfdc4bcecc9098f8e171634b5a5353bb/ratelimit-1.4.1.tar.gz" } ], "2.0.0": [ { "comment_text": "", "digests": { "md5": "21565f7cb94cbed011a220c96b4be69e", "sha256": "0511927643ba6cca206c5487cf19700efea7d198e09b456d982d1058bfcb1247" }, "downloads": -1, "filename": "ratelimit-2.0.0.tar.gz", "has_sig": false, "md5_digest": "21565f7cb94cbed011a220c96b4be69e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4547, "upload_time": "2018-04-21T17:11:38", "url": "https://files.pythonhosted.org/packages/5a/d3/b135d645f90dcb0423e19e9bc1e9463f91712b0c8e3ea50b6e25650bcaf0/ratelimit-2.0.0.tar.gz" } ], "2.1.0": [ { "comment_text": "", "digests": { "md5": "aa33444ee4432163a86146b35eedde40", "sha256": "e349d96c70232b3ac1fe7a7db81bcfa32d0a19e03c3731a6cf85310a4ee55fb1" }, "downloads": -1, "filename": "ratelimit-2.1.0.tar.gz", "has_sig": false, "md5_digest": "aa33444ee4432163a86146b35eedde40", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5016, "upload_time": "2018-04-21T21:09:42", "url": "https://files.pythonhosted.org/packages/e1/78/7d789dfc6c2d93ec98e9698f71dcc3276184205aa1831dcf34baad5891ea/ratelimit-2.1.0.tar.gz" } ], "2.2.0": [ { "comment_text": "", "digests": { "md5": "cd709bcd8ff40848752aa36e60c7d566", "sha256": "200020fb1e15cd8d145aa99e4c02afa6fd5bd786c914225056b7bcfb5c5a7e32" }, "downloads": -1, "filename": "ratelimit-2.2.0.tar.gz", "has_sig": false, "md5_digest": "cd709bcd8ff40848752aa36e60c7d566", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5096, "upload_time": "2018-04-26T20:26:21", "url": "https://files.pythonhosted.org/packages/b5/73/956d739706da2f74891ba46391381ce7e680dce27cce90df7c706512d5bf/ratelimit-2.2.0.tar.gz" } ], "2.2.1": [ { "comment_text": "", "digests": { "md5": "1e183851a8703a755ceddd05d446e608", "sha256": "af8a9b64b821529aca09ebaf6d8d279100d766f19e90b5059ac6a718ca6dee42" }, "downloads": -1, "filename": "ratelimit-2.2.1.tar.gz", "has_sig": false, "md5_digest": "1e183851a8703a755ceddd05d446e608", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5251, "upload_time": "2018-12-17T18:55:49", "url": "https://files.pythonhosted.org/packages/ab/38/ff60c8fc9e002d50d48822cc5095deb8ebbc5f91a6b8fdd9731c87a147c9/ratelimit-2.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1e183851a8703a755ceddd05d446e608", "sha256": "af8a9b64b821529aca09ebaf6d8d279100d766f19e90b5059ac6a718ca6dee42" }, "downloads": -1, "filename": "ratelimit-2.2.1.tar.gz", "has_sig": false, "md5_digest": "1e183851a8703a755ceddd05d446e608", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5251, "upload_time": "2018-12-17T18:55:49", "url": "https://files.pythonhosted.org/packages/ab/38/ff60c8fc9e002d50d48822cc5095deb8ebbc5f91a6b8fdd9731c87a147c9/ratelimit-2.2.1.tar.gz" } ] }