Skip to main content

Official Python client for the DutyBeat public API.

Project description

dutybeat (Python)

Official Python client for the DutyBeat public API.

Install

pip install dutybeat

Usage

from dutybeat import DutyBeat

client = DutyBeat(api_key="db_live_...")          # or set DUTYBEAT_API_KEY
user = client.users.get("9f1c...", include_folders=True)

print(user.full_name, user.email)
print(user.department.name)
print(user.profile.iban)
for folder in user.folders or []:
    print(folder.name, folder.document_count)

# List users (paginated, filterable)
page = client.users.list(page_size=50, status="active", role="member")
for u in page:                       # UserPage is iterable
    print(u.full_name, u.email)
print("total:", page.total)

# List an employee's workdays (marks, worked minutes, balance). `from_` because `from` is reserved.
days = client.attendance.list("9f1c...", from_="2026-06-01", to="2026-06-30")
for day in days:                     # AttendancePage is iterable
    print(day.date, day.worked_minutes, day.balance_minutes)

# List absences overlapping a range (whole company, or one employee with user_id=...)
for absence in client.absences.list(from_="2026-06-01", to="2026-06-30", status="approved"):
    print(absence.start_date, absence.end_date, absence.type.label)

Create an API key in the app under Configuración → Claves de API, and enable the methods each key may call. Full reference: Configuración → API (or https://app.dutybeat.com/configuracion/api).

Errors

from dutybeat import DutyBeat, AuthenticationError, ForbiddenError, NotFoundError, RateLimitError

try:
    client.users.get("9f1c...")
except NotFoundError:
    ...          # 404
except ForbiddenError:
    ...          # 403 — the key does not have this method enabled
except AuthenticationError:
    ...          # 401 — bad / revoked / expired key
except RateLimitError as e:
    print(e.retry_after)   # 429

Every error exposes .status, .code and .message from the API's error envelope.

Configuration

Argument Default
api_key DUTYBEAT_API_KEY env Your db_live_... key
base_url https://api.dutybeat.com Override for testing
timeout 30.0 Seconds
max_retries 2 Retries on 429/5xx, honouring Retry-After

Development

pip install -e ".[dev]"
pytest

License

MIT

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

dutybeat-0.21.0.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

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

dutybeat-0.21.0-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file dutybeat-0.21.0.tar.gz.

File metadata

  • Download URL: dutybeat-0.21.0.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dutybeat-0.21.0.tar.gz
Algorithm Hash digest
SHA256 e2ae972092addb300c2d6ec2e43aba6626a7c12f7445655597253f0455961e9d
MD5 c779e2de13a1f5bd7fc10240d8aac9ca
BLAKE2b-256 c2a28455ff3f82e85af34e2e0b59abe2b99eac54091632f89df12666d20c95e6

See more details on using hashes here.

File details

Details for the file dutybeat-0.21.0-py3-none-any.whl.

File metadata

  • Download URL: dutybeat-0.21.0-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dutybeat-0.21.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ccff1247b8e1fdc0f9ffbb2aa3a2c4c79a898890e6c7855dcefd5d25a0afa3bc
MD5 c6f3b35c542181c0139b3b7d8bc7efb0
BLAKE2b-256 00b48fd2ef87887bb5eb10766d60432ea5098f9e43740bbf92fcff35e00eb2cb

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