Client¶
The client classes provide full coverage of the Harvest Forecast API. The async client
(AsyncForecastClient, exported as ForecastClient) is the canonical implementation; the sync client
(SyncForecastClient) is generated from it via unasync.
Both clients share identical method signatures — the only difference is await for async methods.
Async client¶
AsyncForecastClient ¶
AsyncForecastClient(
access_token: str,
account_id: str,
user_agent: str,
*,
base_url: str = "https://api.forecastapp.com",
timeout: float = 30.0,
retry: RetryPolicy | None = None,
)
Async client for the Harvest Forecast API.
Example
async with AsyncForecastClient( access_token="token", account_id="123", user_agent="my-app (you@example.com)", ) as client: people = await client.list_people()
Initialize the async Forecast client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
access_token
|
str
|
Forecast personal access token. |
required |
account_id
|
str
|
Forecast account ID. |
required |
user_agent
|
str
|
User-Agent header value sent with every request. |
required |
base_url
|
str
|
Forecast API base URL. |
'https://api.forecastapp.com'
|
timeout
|
float
|
Request timeout in seconds. |
30.0
|
retry
|
RetryPolicy | None
|
Retry policy for transient failures. |
None
|
Source code in src/harvest_forecast/_async/client.py
__aenter__
async
¶
__aexit__
async
¶
aclose
async
¶
list_assignments
async
¶
List assignments, optionally filtered.
The Forecast API requires start_date and end_date parameters for the assignments endpoint. Large date ranges are automatically chunked into windows and results are deduplicated by id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter
|
AssignmentFilter | None
|
Filter criteria. Must include start_date and end_date. |
None
|
Returns:
| Type | Description |
|---|---|
list[Assignment]
|
List of Assignment objects. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If filter is None or lacks start_date/end_date. |
Source code in src/harvest_forecast/_async/client.py
list_clients
async
¶
List all clients in the Forecast account.
Returns:
| Type | Description |
|---|---|
list[Client]
|
List of Client objects. |
Source code in src/harvest_forecast/_async/client.py
list_milestones
async
¶
List all milestones in the Forecast account.
Returns:
| Type | Description |
|---|---|
list[Milestone]
|
List of Milestone objects. |
Source code in src/harvest_forecast/_async/client.py
list_people
async
¶
List all people being scheduled in Forecast.
Returns:
| Type | Description |
|---|---|
list[Person]
|
List of Person objects. |
Source code in src/harvest_forecast/_async/client.py
list_placeholders
async
¶
List all placeholders being scheduled in Forecast.
Returns:
| Type | Description |
|---|---|
list[Placeholder]
|
List of Placeholder objects. |
Source code in src/harvest_forecast/_async/client.py
list_projects
async
¶
List all projects in the Forecast account.
Returns:
| Type | Description |
|---|---|
list[Project]
|
List of Project objects. |
Source code in src/harvest_forecast/_async/client.py
list_roles
async
¶
list_repeated_assignment_sets
async
¶
List all repeated assignment sets in the Forecast account.
Returns:
| Type | Description |
|---|---|
list[RepeatedAssignmentSet]
|
List of RepeatedAssignmentSet objects. |
Source code in src/harvest_forecast/_async/client.py
list_user_connections
async
¶
List all current user connections.
Returns:
| Type | Description |
|---|---|
list[UserConnection]
|
List of UserConnection objects. |
Source code in src/harvest_forecast/_async/client.py
get_person
async
¶
Retrieve a single person by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Person ID (must be >= 1). |
required |
Returns:
| Type | Description |
|---|---|
Person
|
Person object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If id < 1. |
ForecastHTTPError
|
On HTTP errors (e.g. 404). |
Source code in src/harvest_forecast/_async/client.py
get_placeholder
async
¶
Retrieve a single placeholder by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Placeholder ID (must be >= 1). |
required |
Returns:
| Type | Description |
|---|---|
Placeholder
|
Placeholder object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If id < 1. |
ForecastHTTPError
|
On HTTP errors (e.g. 404). |
Source code in src/harvest_forecast/_async/client.py
get_project
async
¶
Retrieve a single project by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Project ID (must be >= 1). |
required |
Returns:
| Type | Description |
|---|---|
Project
|
Project object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If id < 1. |
ForecastHTTPError
|
On HTTP errors (e.g. 404). |
Source code in src/harvest_forecast/_async/client.py
get_role
async
¶
Retrieve a single role by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Role ID (must be >= 1). |
required |
Returns:
| Type | Description |
|---|---|
Role
|
Role object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If id < 1. |
ForecastHTTPError
|
On HTTP errors (e.g. 404). |
Source code in src/harvest_forecast/_async/client.py
get_repeated_assignment_set
async
¶
Retrieve a single repeated assignment set by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Repeated assignment set ID (must be >= 1). |
required |
Returns:
| Type | Description |
|---|---|
RepeatedAssignmentSet
|
RepeatedAssignmentSet object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If id < 1. |
ForecastHTTPError
|
On HTTP errors (e.g. 404). |
Source code in src/harvest_forecast/_async/client.py
create_assignment
async
¶
Create a new assignment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
req
|
AssignmentRequest
|
Assignment creation request payload. |
required |
Returns:
| Type | Description |
|---|---|
Assignment
|
The created Assignment object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If req.project_id < 1. |
ForecastHTTPError
|
On HTTP errors. |
Source code in src/harvest_forecast/_async/client.py
update_assignment
async
¶
Update an existing assignment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Assignment ID (must be >= 1). |
required |
req
|
AssignmentRequest
|
Assignment update request payload. |
required |
Returns:
| Type | Description |
|---|---|
Assignment
|
The updated Assignment object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If id < 1 or req.project_id < 1. |
ForecastHTTPError
|
On HTTP errors. |
Source code in src/harvest_forecast/_async/client.py
delete_assignment
async
¶
Delete an assignment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Assignment ID (must be >= 1). |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If id < 1. |
ForecastHTTPError
|
On HTTP errors. |
Source code in src/harvest_forecast/_async/client.py
whoami
async
¶
get_account
async
¶
get_subscription
async
¶
Retrieve the Forecast subscription details.
Returns:
| Type | Description |
|---|---|
Subscription
|
Subscription object. |
Source code in src/harvest_forecast/_async/client.py
remaining_budgeted_hours
async
¶
Retrieve remaining budgeted hours for all projects.
Returns:
| Type | Description |
|---|---|
list[RemainingBudgetedHoursItem]
|
List of RemainingBudgetedHoursItem objects. |
Source code in src/harvest_forecast/_async/client.py
future_scheduled_hours
async
¶
Retrieve future scheduled hours starting from a date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_date
|
str | date
|
Starting date (ISO string or date object). |
required |
Returns:
| Type | Description |
|---|---|
list[FutureScheduledHoursItem]
|
List of FutureScheduledHoursItem objects. |
Source code in src/harvest_forecast/_async/client.py
future_scheduled_hours_for_project
async
¶
future_scheduled_hours_for_project(
from_date: str | date, project_id: int
) -> list[FutureScheduledHoursItem]
Retrieve future scheduled hours for a specific project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_date
|
str | date
|
Starting date (ISO string or date object). |
required |
project_id
|
int
|
Project ID to filter by. |
required |
Returns:
| Type | Description |
|---|---|
list[FutureScheduledHoursItem]
|
List of FutureScheduledHoursItem objects. |
Source code in src/harvest_forecast/_async/client.py
assigned_people
async
¶
Retrieve a mapping of project IDs to assigned person IDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_date
|
str | date
|
Start date (ISO string or date object). |
required |
end_date
|
str | date
|
End date (ISO string or date object). |
required |
Returns:
| Type | Description |
|---|---|
dict[str, list[int]]
|
Dict mapping project ID strings to lists of person IDs. |
Source code in src/harvest_forecast/_async/client.py
project_heatmap
async
¶
project_heatmap(
from_: str | date,
to: str | date,
project_id: int,
scale: str = "daily",
) -> list[ProjectHeatmapItem]
Retrieve a project heatmap for a time period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_
|
str | date
|
Start date (ISO string or date object). |
required |
to
|
str | date
|
End date (ISO string or date object). |
required |
project_id
|
int
|
Project ID. |
required |
scale
|
str
|
Time scale (e.g. "daily", "weekly"). |
'daily'
|
Returns:
| Type | Description |
|---|---|
list[ProjectHeatmapItem]
|
List of ProjectHeatmapItem objects. |
Source code in src/harvest_forecast/_async/client.py
person_heatmap
async
¶
person_heatmap(
from_: str | date,
to: str | date,
person_id: int,
scale: str = "daily",
) -> list[PersonHeatmapItem]
Retrieve a person heatmap for a time period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_
|
str | date
|
Start date (ISO string or date object). |
required |
to
|
str | date
|
End date (ISO string or date object). |
required |
person_id
|
int
|
Person ID. |
required |
scale
|
str
|
Time scale (e.g. "daily", "weekly"). |
'daily'
|
Returns:
| Type | Description |
|---|---|
list[PersonHeatmapItem]
|
List of PersonHeatmapItem objects. |
Source code in src/harvest_forecast/_async/client.py
placeholder_heatmap
async
¶
placeholder_heatmap(
from_: str | date,
to: str | date,
placeholder_id: int,
scale: str = "daily",
) -> list[PlaceholderHeatmapItem]
Retrieve a placeholder heatmap for a time period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_
|
str | date
|
Start date (ISO string or date object). |
required |
to
|
str | date
|
End date (ISO string or date object). |
required |
placeholder_id
|
int
|
Placeholder ID. |
required |
scale
|
str
|
Time scale (e.g. "daily", "weekly"). |
'daily'
|
Returns:
| Type | Description |
|---|---|
list[PlaceholderHeatmapItem]
|
List of PlaceholderHeatmapItem objects. |
Source code in src/harvest_forecast/_async/client.py
Sync client¶
SyncForecastClient ¶
SyncForecastClient(
access_token: str,
account_id: str,
user_agent: str,
*,
base_url: str = "https://api.forecastapp.com",
timeout: float = 30.0,
retry: RetryPolicy | None = None,
)
Async client for the Harvest Forecast API.
Example
async with AsyncForecastClient( access_token="token", account_id="123", user_agent="my-app (you@example.com)", ) as client: people = await client.list_people()
Initialize the async Forecast client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
access_token
|
str
|
Forecast personal access token. |
required |
account_id
|
str
|
Forecast account ID. |
required |
user_agent
|
str
|
User-Agent header value sent with every request. |
required |
base_url
|
str
|
Forecast API base URL. |
'https://api.forecastapp.com'
|
timeout
|
float
|
Request timeout in seconds. |
30.0
|
retry
|
RetryPolicy | None
|
Retry policy for transient failures. |
None
|
Source code in src/harvest_forecast/_sync/client.py
__enter__ ¶
__exit__ ¶
close ¶
list_assignments ¶
List assignments, optionally filtered.
The Forecast API requires start_date and end_date parameters for the assignments endpoint. Large date ranges are automatically chunked into windows and results are deduplicated by id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter
|
AssignmentFilter | None
|
Filter criteria. Must include start_date and end_date. |
None
|
Returns:
| Type | Description |
|---|---|
list[Assignment]
|
List of Assignment objects. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If filter is None or lacks start_date/end_date. |
Source code in src/harvest_forecast/_sync/client.py
list_clients ¶
List all clients in the Forecast account.
Returns:
| Type | Description |
|---|---|
list[Client]
|
List of Client objects. |
list_milestones ¶
List all milestones in the Forecast account.
Returns:
| Type | Description |
|---|---|
list[Milestone]
|
List of Milestone objects. |
Source code in src/harvest_forecast/_sync/client.py
list_people ¶
List all people being scheduled in Forecast.
Returns:
| Type | Description |
|---|---|
list[Person]
|
List of Person objects. |
list_placeholders ¶
List all placeholders being scheduled in Forecast.
Returns:
| Type | Description |
|---|---|
list[Placeholder]
|
List of Placeholder objects. |
Source code in src/harvest_forecast/_sync/client.py
list_projects ¶
List all projects in the Forecast account.
Returns:
| Type | Description |
|---|---|
list[Project]
|
List of Project objects. |
Source code in src/harvest_forecast/_sync/client.py
list_repeated_assignment_sets ¶
List all repeated assignment sets in the Forecast account.
Returns:
| Type | Description |
|---|---|
list[RepeatedAssignmentSet]
|
List of RepeatedAssignmentSet objects. |
Source code in src/harvest_forecast/_sync/client.py
list_user_connections ¶
List all current user connections.
Returns:
| Type | Description |
|---|---|
list[UserConnection]
|
List of UserConnection objects. |
Source code in src/harvest_forecast/_sync/client.py
get_person ¶
Retrieve a single person by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Person ID (must be >= 1). |
required |
Returns:
| Type | Description |
|---|---|
Person
|
Person object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If id < 1. |
ForecastHTTPError
|
On HTTP errors (e.g. 404). |
Source code in src/harvest_forecast/_sync/client.py
get_placeholder ¶
Retrieve a single placeholder by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Placeholder ID (must be >= 1). |
required |
Returns:
| Type | Description |
|---|---|
Placeholder
|
Placeholder object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If id < 1. |
ForecastHTTPError
|
On HTTP errors (e.g. 404). |
Source code in src/harvest_forecast/_sync/client.py
get_project ¶
Retrieve a single project by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Project ID (must be >= 1). |
required |
Returns:
| Type | Description |
|---|---|
Project
|
Project object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If id < 1. |
ForecastHTTPError
|
On HTTP errors (e.g. 404). |
Source code in src/harvest_forecast/_sync/client.py
get_role ¶
Retrieve a single role by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Role ID (must be >= 1). |
required |
Returns:
| Type | Description |
|---|---|
Role
|
Role object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If id < 1. |
ForecastHTTPError
|
On HTTP errors (e.g. 404). |
Source code in src/harvest_forecast/_sync/client.py
get_repeated_assignment_set ¶
Retrieve a single repeated assignment set by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Repeated assignment set ID (must be >= 1). |
required |
Returns:
| Type | Description |
|---|---|
RepeatedAssignmentSet
|
RepeatedAssignmentSet object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If id < 1. |
ForecastHTTPError
|
On HTTP errors (e.g. 404). |
Source code in src/harvest_forecast/_sync/client.py
create_assignment ¶
Create a new assignment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
req
|
AssignmentRequest
|
Assignment creation request payload. |
required |
Returns:
| Type | Description |
|---|---|
Assignment
|
The created Assignment object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If req.project_id < 1. |
ForecastHTTPError
|
On HTTP errors. |
Source code in src/harvest_forecast/_sync/client.py
update_assignment ¶
Update an existing assignment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Assignment ID (must be >= 1). |
required |
req
|
AssignmentRequest
|
Assignment update request payload. |
required |
Returns:
| Type | Description |
|---|---|
Assignment
|
The updated Assignment object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If id < 1 or req.project_id < 1. |
ForecastHTTPError
|
On HTTP errors. |
Source code in src/harvest_forecast/_sync/client.py
delete_assignment ¶
Delete an assignment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Assignment ID (must be >= 1). |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If id < 1. |
ForecastHTTPError
|
On HTTP errors. |
Source code in src/harvest_forecast/_sync/client.py
whoami ¶
get_account ¶
get_subscription ¶
Retrieve the Forecast subscription details.
Returns:
| Type | Description |
|---|---|
Subscription
|
Subscription object. |
Source code in src/harvest_forecast/_sync/client.py
remaining_budgeted_hours ¶
Retrieve remaining budgeted hours for all projects.
Returns:
| Type | Description |
|---|---|
list[RemainingBudgetedHoursItem]
|
List of RemainingBudgetedHoursItem objects. |
Source code in src/harvest_forecast/_sync/client.py
future_scheduled_hours ¶
Retrieve future scheduled hours starting from a date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_date
|
str | date
|
Starting date (ISO string or date object). |
required |
Returns:
| Type | Description |
|---|---|
list[FutureScheduledHoursItem]
|
List of FutureScheduledHoursItem objects. |
Source code in src/harvest_forecast/_sync/client.py
future_scheduled_hours_for_project ¶
future_scheduled_hours_for_project(
from_date: str | date, project_id: int
) -> list[FutureScheduledHoursItem]
Retrieve future scheduled hours for a specific project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_date
|
str | date
|
Starting date (ISO string or date object). |
required |
project_id
|
int
|
Project ID to filter by. |
required |
Returns:
| Type | Description |
|---|---|
list[FutureScheduledHoursItem]
|
List of FutureScheduledHoursItem objects. |
Source code in src/harvest_forecast/_sync/client.py
assigned_people ¶
Retrieve a mapping of project IDs to assigned person IDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_date
|
str | date
|
Start date (ISO string or date object). |
required |
end_date
|
str | date
|
End date (ISO string or date object). |
required |
Returns:
| Type | Description |
|---|---|
dict[str, list[int]]
|
Dict mapping project ID strings to lists of person IDs. |
Source code in src/harvest_forecast/_sync/client.py
project_heatmap ¶
project_heatmap(
from_: str | date,
to: str | date,
project_id: int,
scale: str = "daily",
) -> list[ProjectHeatmapItem]
Retrieve a project heatmap for a time period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_
|
str | date
|
Start date (ISO string or date object). |
required |
to
|
str | date
|
End date (ISO string or date object). |
required |
project_id
|
int
|
Project ID. |
required |
scale
|
str
|
Time scale (e.g. "daily", "weekly"). |
'daily'
|
Returns:
| Type | Description |
|---|---|
list[ProjectHeatmapItem]
|
List of ProjectHeatmapItem objects. |
Source code in src/harvest_forecast/_sync/client.py
person_heatmap ¶
person_heatmap(
from_: str | date,
to: str | date,
person_id: int,
scale: str = "daily",
) -> list[PersonHeatmapItem]
Retrieve a person heatmap for a time period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_
|
str | date
|
Start date (ISO string or date object). |
required |
to
|
str | date
|
End date (ISO string or date object). |
required |
person_id
|
int
|
Person ID. |
required |
scale
|
str
|
Time scale (e.g. "daily", "weekly"). |
'daily'
|
Returns:
| Type | Description |
|---|---|
list[PersonHeatmapItem]
|
List of PersonHeatmapItem objects. |
Source code in src/harvest_forecast/_sync/client.py
placeholder_heatmap ¶
placeholder_heatmap(
from_: str | date,
to: str | date,
placeholder_id: int,
scale: str = "daily",
) -> list[PlaceholderHeatmapItem]
Retrieve a placeholder heatmap for a time period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_
|
str | date
|
Start date (ISO string or date object). |
required |
to
|
str | date
|
End date (ISO string or date object). |
required |
placeholder_id
|
int
|
Placeholder ID. |
required |
scale
|
str
|
Time scale (e.g. "daily", "weekly"). |
'daily'
|
Returns:
| Type | Description |
|---|---|
list[PlaceholderHeatmapItem]
|
List of PlaceholderHeatmapItem objects. |