Official Python client for the Mployr API
# Using pip
pip install mployr-api
# Using poetry
poetry add mployr-apiInitialize the client and make your first API call:
Use async/await for better performance.
import asyncio
from Mployr import AsyncMployrClient
async def main():
client = AsyncMployrClient(base_url="https://api.mployr.com.au/v1")
await client.auth.login(
email="user@example.com",
password="your-password"
)
# Concurrent requests
people, documents = await asyncio.gather(
client.people.list(per_page=100),
client.documents.list(per_page=100),
)
print(f"Found {len(people.data)} people")
print(f"Found {len(documents.data)} documents")
asyncio.run(main())Create a new employee record.
new_person = client.people.create(
first_name="John",
last_name="Doe",
email="john.doe@example.com",
phone="+61 400 123 456",
date_of_birth="1990-05-15"
)
print(f"Created person: {new_person.data.id}")Handle API errors gracefully.
from mployr.exceptions import ApiError, ValidationError
try:
person = client.people.get(999)
except ValidationError as e:
print("Validation failed:")
for field, messages in e.errors.items():
print(f" {field}: {', '.join(messages)}")
except ApiError as e:
print(f"API Error: {e.message}")
print(f"Status: {e.status_code}")
if e.status_code == 401:
# Re-authenticate
client.auth.login(email=email, password=password)See all available methods and endpoints in the interactive API reference.