Skip to main content

Official Python SDK for the Factorial API

Project description

factorial-api-client (Python)

Official Python SDK for the Factorial API.

Versioning

The SDK uses standard semver (MAJOR.MINOR.PATCH), independent of the Factorial API version date.

SDK version Factorial API version
1.x.y 2026-04-01

Factorial releases new API versions quarterly (Jan/Apr/Jul/Oct).

See the Factorial API versioning docs for details.

Installation

pip install factorial-api-client

Quick start

from factorial_api_client import FactorialClient

client = FactorialClient(api_key="YOUR_KEY")

# First page only
result = client.employees.employee.list()
employees = result.data

# Cursor-paginated iterator (sync)
for emp in client.employees.employee.paginate(max_items=100):
    print(emp.full_name)

# Collect all pages into a list
all_employees = client.employees.employee.all()

# Async iterator
import asyncio

async def main():
    async for emp in await client.employees.employee.paginate_async(max_items=100):
        print(emp.full_name)

asyncio.run(main())

Authentication

Pass your API key via api_key= or an OAuth2 bearer token via token=:

# API key (sent as x-api-key header)
client = FactorialClient(api_key="YOUR_KEY")

# OAuth2 bearer token
client = FactorialClient(token="YOUR_BEARER_TOKEN")

Environment variables

When an argument is omitted, the client falls back to environment variables. Explicit arguments always take precedence.

Variable Maps to Sent as
FACTORIAL_API_KEY api_key x-api-key header
FACTORIAL_OAUTH_TOKEN token Authorization: Bearer
FACTORIAL_BASE_URL base_url — (defaults to https://api.factorialhr.com)
# No arguments needed — reads FACTORIAL_API_KEY / FACTORIAL_OAUTH_TOKEN / FACTORIAL_BASE_URL
client = FactorialClient()

Error handling

The client fails loudly on non-2xx responses (bad/expired token, wrong base URL, 4xx/5xx) instead of silently returning None. These raise UnexpectedStatus:

from factorial_api_client.generated.errors import UnexpectedStatus

try:
    employees = client.employees.employee.list()
except UnexpectedStatus as e:
    print(e.status_code)  # e.g. 401
    print(e.content)      # raw response body (bytes)

Domain namespaces

The client is organised as client.{domain}.{resource}.{method}().

Domain Example
employees client.employees.employee.list()
ats client.ats.application.list()
attendance client.attendance.shift.list()
timeoff client.timeoff.leave.list()
contracts client.contracts.contract_version.list()
payroll client.payroll.supplement.list()
documents client.documents.document.list()
performance client.performance.review_process.list()
... 36 domains total

Available methods per resource: list, get, create, update, delete, paginate, paginate_async, all, plus any custom action endpoints.

Pagination

All list endpoints support cursor-based pagination via paginate() / paginate_async() / all():

# Stop after 50 items
for emp in client.employees.employee.paginate(max_items=50):
    ...

# Collect everything (use carefully on large datasets)
all_leaves = client.timeoff.leave.all()

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

factorial_api_client-1.1.0.tar.gz (442.1 kB view details)

Uploaded Source

Built Distribution

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

factorial_api_client-1.1.0-py3-none-any.whl (1.7 MB view details)

Uploaded Python 3

File details

Details for the file factorial_api_client-1.1.0.tar.gz.

File metadata

  • Download URL: factorial_api_client-1.1.0.tar.gz
  • Upload date:
  • Size: 442.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for factorial_api_client-1.1.0.tar.gz
Algorithm Hash digest
SHA256 195b198accba09b9b34b5522f8ecea75abb9df0d98e477f969c8fbd0a52df86c
MD5 de66b85aa1179ab26656d58a139a682d
BLAKE2b-256 51241fff0009737980ea20bc84cd6f84ba458f501261ed6463ddee142df1f175

See more details on using hashes here.

File details

Details for the file factorial_api_client-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: factorial_api_client-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for factorial_api_client-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1b47ea6654f726e6b7f15c92256e6348b742c5a386f926cc96eabd9b0c02f825
MD5 8ceeced1f11ff8cacf88a6596fe9475f
BLAKE2b-256 6fadb00806221e3c2be02227bfbb3b330459769f16ba60593ec6099969e7f465

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