API Reference
Credential Management
To use the AdpApiClient you first must configure your API credentials. These credentials are managed through an AdpCredentials object, which can be configured manually or from environment variables.
Source code in src/adpapi/client.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
Client
The main entry point for interacting with the ADP API. Using a context manager is recommended so the HTTP session is always closed cleanly:
from adpapi.client import AdpApiClient, AdpCredentials
credentials = AdpCredentials(
client_id, client_secret, key_path, cert_path
)
with AdpApiClient(credentials) as api:
api.call_endpoint(...)
api.call_rest_endpoint(...)
The AdpApiClient surfaces two main entry points:
.call_endpoint()— for paginated OData queries (lists, searches).call_rest_endpoint()— for direct resource lookups by ID, with path parameter substitution
Call any Registered ADP Endpoint
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API Endpoint or qualified URL to call |
required |
select
|
List[str]
|
Table Columns to pull |
None
|
masked
|
bool
|
Mask Sensitive Columns Containing Personally Identifiable Information. Defaults to True. |
True
|
filters
|
str | FilterExpression
|
OData Filter Expression. Strings will be passed directly,
or OData strings can be automatically created from |
None
|
timeout
|
int
|
Time to wait on. Defaults to 30. |
DEFAULT_TIMEOUT
|
page_size
|
int
|
Amount of records to pull per API call (max 100). Defaults to 100. |
100
|
max_requests
|
Optional[int]
|
Maximum number of requests to make (for quick testing). Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
When given an endpoint not following the call convention |
Returns:
| Type | Description |
|---|---|
list[dict]
|
List[Dict]: The collection of API responses |
Source code in src/adpapi/client.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | |
Call a RestAPI Endpoint
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
the endpoint path template (e.g. '/hr/workers/{workerId}') |
required |
method
|
Optional[str]
|
the HTTP method to use for the request. Defaults to 'GET'. |
'GET'
|
masked
|
Optional[bool]
|
whether to use masked headers. Defaults to True. |
True
|
timeout
|
Optional[int]
|
the request timeout in seconds. Defaults to DEFAULT_TIMEOUT. |
DEFAULT_TIMEOUT
|
params
|
Optional[dict]
|
query parameters for the request. Defaults to None. |
None
|
max_workers
|
int
|
maximum number of threads for parallel requests. Defaults to 1 (sequential). |
1
|
inject_path_params
|
bool
|
when True, merge the resolved path parameters into each response dict. Useful when the API does not echo back identifiers (e.g. AOIDs) in the response body. Defaults to False. |
False
|
**kwargs
|
Any
|
path parameters to substitute into the endpoint template (e.g workerId=['123', '456']) - can be single values or lists of values for batch requests |
{}
|
Raises: ValueError: if required path parameters are missing or if endpoint format is incorrect
Returns:
| Type | Description |
|---|---|
list[dict]
|
List[Dict]: the collection of API responses for each substituted endpoint |
Source code in src/adpapi/client.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | |
Filters
OData filter expressions for querying. Use FilterExpression.field() as the primary entry point:
from adpapi.odata_filters import FilterExpression
# Recommended: use FilterExpression.field()
filter = FilterExpression.field('fieldName').eq('targetValue')
# Advanced: construct a Field directly for reuse
from adpapi.odata_filters import Field
field = Field('fieldName')
See full details on supported OData operations:
Bases: Expr
Represents a field reference in an OData filter expression.
Fields are identified by their path (e.g., 'worker.person.firstName'). This class provides a fluent API for building filter conditions on fields.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
str
|
The dot-separated path to the field, supporting nested properties. |
Example
field = Field('worker.hireDate') field.eq('2020-01-01').to_odata() "(worker/hireDate eq '2020-01-01')"
Source code in src/adpapi/odata_filters.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
contains(val)
Create a substring contains filter for string fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val
|
Any
|
The substring to search for within the field value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Func |
Func
|
A function call representing the contains operation. |
Example
FilterExpression.field('lastName').contains('Smith').to_odata() "contains(lastName, 'Smith')"
Source code in src/adpapi/odata_filters.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
endswith(val)
Create a string ends-with filter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val
|
Any
|
The suffix to search for at the end of the field value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Func |
Func
|
A function call representing the endswith operation. |
Example
FilterExpression.field('email').endswith('@company.com').to_odata() "endswith(email, '@company.com')"
Source code in src/adpapi/odata_filters.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
eq(val)
Create an equality comparison filter (field = value).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val
|
Any
|
The value to compare against. Can be string, number, boolean, or None. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BinaryOp |
BinaryOp
|
A binary operation representing the equality condition. |
Example
FilterExpression.field('status').eq('Active').to_odata() "(status eq 'Active')"
Source code in src/adpapi/odata_filters.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
ge(val)
Create a greater-than-or-equal comparison filter (field >= value).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val
|
Any
|
The value to compare against. Typically a number or date string. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BinaryOp |
BinaryOp
|
A binary operation representing the greater-than-or-equal condition. |
Example
FilterExpression.field('hireDate').ge('2020-01-01').to_odata() "(hireDate ge '2020-01-01')"
Source code in src/adpapi/odata_filters.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
gt(val)
Create a greater-than comparison filter (field > value).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val
|
Any
|
The value to compare against. Typically a number or date string. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BinaryOp |
BinaryOp
|
A binary operation representing the greater-than condition. |
Example
FilterExpression.field('salary').gt(50000).to_odata() "(salary gt 50000)"
Source code in src/adpapi/odata_filters.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
isin(values)
Create an IN filter for multiple values (field IN (val1, val2, ...)).
Since OData v4 doesn't have a native IN operator, this is implemented as a series of OR conditions joined together.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
list[Any]
|
A list of values to check against. If empty, returns false. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Expr |
Expr
|
An expression representing the IN operation. For empty lists, returns an always-false condition (1 eq 0). |
Example
statuses = ['Active', 'OnLeave', 'Pending'] FilterExpression.field('status').isin(statuses).to_odata() "((status eq 'Active') or ((status eq 'OnLeave') or (status eq 'Pending')))"
Source code in src/adpapi/odata_filters.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
le(val)
Create a less-than-or-equal comparison filter (field <= value).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val
|
Any
|
The value to compare against. Typically a number or date string. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BinaryOp |
BinaryOp
|
A binary operation representing the less-than-or-equal condition. |
Example
FilterExpression.field('retirementDate').le('2025-12-31').to_odata() "(retirementDate le '2025-12-31')"
Source code in src/adpapi/odata_filters.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
lt(val)
Create a less-than comparison filter (field < value).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val
|
Any
|
The value to compare against. Typically a number or date string. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BinaryOp |
BinaryOp
|
A binary operation representing the less-than condition. |
Example
FilterExpression.field('salary').lt(100000).to_odata() "(salary lt 100000)"
Source code in src/adpapi/odata_filters.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
ne(val)
Create a not-equal comparison filter (field != value).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val
|
Any
|
The value to compare against. Can be string, number, boolean, or None. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BinaryOp |
BinaryOp
|
A binary operation representing the not-equal condition. |
Example
FilterExpression.field('status').ne('Inactive').to_odata() "(status ne 'Inactive')"
Source code in src/adpapi/odata_filters.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
startswith(val)
Create a string starts-with filter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val
|
Any
|
The prefix to search for at the start of the field value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Func |
Func
|
A function call representing the startswith operation. |
Example
FilterExpression.field('firstName').startswith('John').to_odata() "startswith(firstName, 'John')"
Source code in src/adpapi/odata_filters.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
to_odata()
Convert this field reference to an OData path string.
Converts dot notation to forward slash notation for OData v4 compliance.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The OData-compliant field path. |
Example
Field('worker.person.firstName').to_odata() 'worker/person/firstName'
Source code in src/adpapi/odata_filters.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
Logging
Quick basic logging configuration with a rotating file handler and stream handling.
Source code in src/adpapi/logger.py
10 11 12 13 14 15 16 17 18 19 20 21 | |