Skip to content

heartbeat-sh/heartbeat.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Heartbeat.sh Python Client

This is a Python client library for heartbeat.sh.

Quick start

Install with pip install heartbeat-sh requests

from datetime import timedelta
from heartbeat_sh import HeartbeatClient

HeartbeatClient("example").send_beat(
    "example:python",
    timedelta(days=1, hours=2),
    timedelta(days=2)
)

Use a custom requests library (Dependency Injection)

By default, this module uses the requests library to make HTTP requests. This is not a requirement. You may inject any request library:

from datetime import timedelta
from heartbeat_sh import HeartbeatClient

def request(url: str, method: str):
    return {
        "fake": "json result"
    }

HeartbeatClient(
    subdomain="example",
    request=request,
).send_beat(
    "example:python",
    timedelta(days=1, hours=2),
    timedelta(days=2)
)

Links