Add your description here
Project description
adpapi
Minimal Python client for the ADP Workforce Now API using OAuth2 client credentials + mutual TLS (mTLS).
Install
uv add adpapi
or
pip install adpapi
Configuration
Provide credentials via environment variables (or a .env file):
CLIENT_ID=...
CLIENT_SECRET=...
CERT_PATH=certificate.pem
KEY_PATH=adp.key
Quickstart
import os
from dotenv import load_dotenv
from adpapi.client import AdpApiClient, AdpCredentials
from adpapi.logger import configure_logging
# Optional helper: Configure logger with file handlers and stream handling
configure_logging()
load_dotenv()
# Decide which OData columnns are required from your pull
cols = [
"workers/person/legalName",
"workers/person/birthDate",
"workers/workAssignments/reportsTo",
"workers/associateOID",
"workers/businessCommunication/emails",
]
# Load API Credentials from environment
credentials = AdpCredentials.from_env()
# Define your API Client
with AdpApiClient(
client_id=os.environ["CLIENT_ID"],
client_secret=os.environ["CLIENT_SECRET"],
cert_path=os.getenv("CERT_PATH", "certificate.pem"),
key_path=os.getenv("KEY_PATH", "adp.key"),
) as api:
workers = api.call_endpoint(
endpoint="/hr/v2/workers",
select=cols,
masked=True, # set False to request unmasked fields if your tenant allows it
page_size=100, # ADP max
max_requests=1, # increase/remove for full exports
)
Filtering with OData
Use FilterExpression to build OData $filter parameters. Pass filters to call_endpoint() using the filters parameter:
from adpapi.odata_filters import FilterExpression
# Simple equality
filter1 = FilterExpression.field("workers.status").eq("Active")
# Combine conditions with logical operators
filter2 = (
FilterExpression.field("workers.status").eq("Active")
& FilterExpression.field("workers.hireDate").ge("2020-01-01")
)
# Multiple values (IN operator)
filter3 = FilterExpression.field("workers.status").isin(["Active", "OnLeave", "Pending"])
# String search
filter4 = FilterExpression.field("workers.person.legalName.familyName").contains("Smith")
# Pass to API call
workers = api.call_endpoint(
endpoint="/hr/v2/workers",
filters=filter2,
select=cols,
masked=True,
)
Supported Operators:
- Comparison:
eq,ne,gt,ge,lt,le - String functions:
contains(),startswith(),endswith() - Logical:
&(and),|(or),~(not) - IN operator:
isin([...])
Notes:
- Field paths use dots in Python code (e.g.,
workers.status) but convert to forward slashes in OData syntax (workers/status) - Not all operators are supported by all endpoints; check ADP API documentation
- You can also pass OData filter strings directly:
filters="workers/status eq 'Active'"
Notes
- Uses OData-style pagination (
$top,$skip,$select) and stops on HTTP 204 (No Content). masked=FalserequestsAccept: application/json;masked=false(subject to tenant permissions).- Logging writes DEBUG output to
app.logand to the console.
Monofile.ipynb
For clients such as Microsoft Fabric, Azure Databricks, or other notebook-driven programming environments, running a single notebook with magic commands may be more efficient than creating a custom runtime with the pip version of the package. To allow for this, monofile.ipynb can simply be uploaded to the desired location and ran there.
Import Syntax Changes to
%run monofile.ipynb # Or whatever monofile has been renamed to in the notebook client
# Now, imports are no longer necessary and the top-level Api objects are exposed at top-level
configure_logging()
with AdpApiClient(...) as api:
api.call_endpoint(...)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file adpapi-1.3.1.tar.gz.
File metadata
- Download URL: adpapi-1.3.1.tar.gz
- Upload date:
- Size: 26.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50a7131efcadcfb4cc71076cf21707cd2747406c122e09fcf951e356e437cd28
|
|
| MD5 |
b0d773bb91dfe41ceec4c348fb1d464d
|
|
| BLAKE2b-256 |
421fd3656b5ede97ea8d4d7679f8dbd3fe0f552e4d08588e07e36d470c352197
|
File details
Details for the file adpapi-1.3.1-py3-none-any.whl.
File metadata
- Download URL: adpapi-1.3.1-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9b7093ba7165a2ff383816ad1d334e7dba740816e6aebb6acb56a2db2e645fa
|
|
| MD5 |
89c78d5c55ccf665b7234c72be256892
|
|
| BLAKE2b-256 |
84a68d561b52b5fa3dc57e159d14473e4e4c2d0ab7451098a06fd5fee5847d42
|