Skip to main content

Requests for all

Project description

poet-api

Requests with Limiter.

Uses pyrate_limiter.SQLiteBucket with use_file_lock=True.

It can handle many connections concurrently and respect the chosen limits per_second, per_minute, per_day.

class Communicate

init

  • session: requests.Session (Required)
  • caller_name: str (limiter id) (Required)
  • per_second: int = 1
  • per_minute: int = 56
  • per_day: Optional[int] = None
  • stream: bool = False
  • timeout: Union[float, tuple] = 5
  • allow_redirects: bool = True

send

  • method: str (Required)
  • url: str (Required)
  • headers: Optional[dict] = None (default headers are sent if None)
  • **kwargs (accepted by requests.Request)

Examples

  • Simplest (by default: 56 requests per minute, 1 request per second):

    from api import Communicate
    from requests import Session
    
    session = Session()
    
    response = Communicate(session=session, caller_name="simple_john").send(
        method="GET", url="https://john-site.com"
    )
    
  • With custom limits and custom headers:

    from api import Communicate
    from requests import Session
    
    session = Session()
    headers = {"User-Agent": ("My Dear Agent v.1")}
    
    response = Communicate(session=session, caller_name="John", per_minute=6).send(
        method="GET", url="https://mysite.com", headers=headers
    )
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

poet_api-3.0.4.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

poet_api-3.0.4-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file poet_api-3.0.4.tar.gz.

File metadata

  • Download URL: poet_api-3.0.4.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.9 Linux/6.1.0-40-amd64

File hashes

Hashes for poet_api-3.0.4.tar.gz
Algorithm Hash digest
SHA256 8e9a957f870373a48c1b3ab2b3e6b21cb992bc8767c0a8c67a4801608fc03039
MD5 4d60c36c2cb4c80dad81499f93e4098d
BLAKE2b-256 eb7e7ed543d33bec8d5bc523cb15cd07e3d8805864f78bf60b1e97dd1f489888

See more details on using hashes here.

File details

Details for the file poet_api-3.0.4-py3-none-any.whl.

File metadata

  • Download URL: poet_api-3.0.4-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.9 Linux/6.1.0-40-amd64

File hashes

Hashes for poet_api-3.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 15143a7c77e1f46394950e34d4d515601886dee25c1e75b8b05a1223e5164be3
MD5 18bdc3eb4c138ff8aaa36e6d9ede379e
BLAKE2b-256 05c0900e21da38ef5c35683f6105c94a218732a7f6d74362b0bd4a6f57c81de7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page