Reference

This is the complete API reference for the pd4castr-api-sdk Python package. It documents every public class, method, data model, and exception.

Client

The Client class is the main entry point for interacting with the pd4castr API.

Constructor

from pd4castr_api_sdk import Client
 
client = Client(
    *,
    client_id: str,
    client_secret: str,
    timeout: float = 30.0,
    base_url: str | None = None,
    auth0_domain: str | None = None,
    auth0_audience: str | None = None,
)
ParameterTypeDefaultDescription
client_idstr(required)OAuth 2.0 client ID
client_secretstr(required)OAuth 2.0 client secret
timeoutfloat30.0HTTP request timeout in seconds
base_urlstr or Nonehttps://api.v2.pd4castr.com.auAPI base URL override
auth0_domainstr or Nonepdview.au.auth0.comAuth0 tenant domain override
auth0_audiencestr or Nonehttps://api.pd4castr.com.auAuth0 API audience override

All parameters are keyword-only.

The client supports the context manager protocol, so you can use it with a with statement to automatically close the connection:

with Client(client_id="...", client_secret="...") as client:
    models = client.get_models()

Methods

get_models

client.get_models(*, time_horizon: str | None = None) -> list[Model]

Returns a list of all models accessible to the authenticated user, including your organisation’s private models and any public models.

ParameterTypeDefaultDescription
time_horizonstr or NoneNoneFilter models by time horizon

Valid time_horizon values:

  • "day_ahead"
  • "week_ahead"
  • "quarterly"
  • "historical"

When time_horizon is None, all models are returned regardless of their time horizon.

Returns: list[Model]

get_model

client.get_model(model_id: str) -> Model

Fetches a single model by its unique ID.

ParameterTypeDescription
model_idstrThe unique model ID

Returns: Model

Raises: NotFoundError if no model exists with the given ID.

get_current_user

client.get_current_user() -> User

Returns the profile and organisation details for the authenticated user.

Returns: User

close

client.close() -> None

Closes the underlying HTTP connection. After calling close(), the client can’t make further requests. If you use the client as a context manager, this is called automatically.

Data models

All data models use Pydantic and are returned as typed Python objects. Unknown fields from the API are ignored automatically.

Model

Represents a forecast model on the pd4castr platform.

FieldTypeDescription
idstrUnique model identifier
modelGroupIdstrID of the model group this model belongs to
namestrInternal model name
displayNamestrHuman-readable display name
notesstrModel notes or description
revisionintModel revision number
dockerImagestrDocker image used to run the model
createdAtstrISO 8601 creation timestamp
displayTimezonestrTimezone for displaying forecast results
horizonTimeHorizonThe model’s forecast time horizon
modelMetadataModelMetadataAdditional metadata about the model
outputSpecificationlist[ColumnSpecification]Schema of the model’s output columns
tagslist[str]Tags associated with the model
sensitivitieslist[SensitivitySpecification]Sensitivity configurations
outputFileFormatFileFormatOutput file format (json, csv, parquet)
forecastVariableForecastVariableSpecificationThe variable being forecast

TimeHorizon

Describes the forecast time horizon for a model.

FieldTypeDescription
namestrFull name (for example, “Day Ahead”)
shortNamestrAbbreviated name (for example, “DA”)
keystrMachine-readable key (for example, “day_ahead”)

ModelMetadata

Optional metadata associated with a model. All fields are optional and default to None.

FieldTypeDescription
descriptionstr or NoneExtended model description
releaseDatestr or NoneWhen the model was released
resolutionstr or NoneForecast resolution (for example, “30min”)
baseComparisonModelstr or NoneID of the baseline comparison model

ColumnSpecification

Describes a single column in the model’s output data.

FieldTypeDescription
namestrColumn name
typestrData type of the column
uiUISpecification or NoneOptional display configuration

UISpecification

Controls how a column is displayed in the pd4castr web app.

FieldTypeDescription
seriesKeybool or NoneWhether the column is a series key
colourslist[str] or NoneHex color codes for chart rendering

SensitivitySpecification

Defines a sensitivity parameter and its available categories.

FieldTypeDescription
namestrName of the sensitivity parameter
categorieslist[str]Available category values for this sensitivity

ForecastVariableSpecification

Describes the variable that a model forecasts.

FieldTypeDescription
namestrFull variable name (for example, “Price”)
shortNamestrAbbreviated name (for example, “price”)
keystrMachine-readable key

FileFormat

A string enumeration of supported output file formats.

ValueDescription
"json"JSON format
"csv"Comma-separated values
"parquet"Apache Parquet format

FileFormat extends Python’s StrEnum, so you can compare it directly with strings:

if model.outputFileFormat == "parquet":
    print("This model outputs Parquet files")

User

Represents an authenticated user on the pd4castr platform.

FieldTypeDescription
idstrUnique user identifier
emailstrUser’s email address
organisationOrganisation or NoneThe user’s organisation

Organisation

Represents an organisation on the pd4castr platform.

FieldTypeDescription
idstrUnique organisation identifier
displayNamestrOrganisation display name
slugstrURL-friendly organisation slug
domainslist[str]Email domains for the organisation
permissionslist[str]Granted permission strings

Exceptions

The SDK defines a small exception hierarchy for error handling.

ApiError

Raised when the API returns an HTTP 4xx or 5xx response (except 404, which raises NotFoundError instead).

PropertyTypeDescription
status_codeintThe HTTP status code
messagestrA human-readable error message
bodyAny or NoneThe parsed response body, if available

NotFoundError

Raised when the API returns an HTTP 404 response.

Note: NotFoundError does not inherit from ApiError. If you need to catch both, use separate except clauses.

Error handling example

from pd4castr_api_sdk import Client, ApiError, NotFoundError
 
with Client(client_id="...", client_secret="...") as client:
    try:
        model = client.get_model("non-existent-id")
    except NotFoundError:
        print("Model not found")
    except ApiError as e:
        print(f"API error {e.status_code}: {e.message}")

Next steps

  • Quick start — install the SDK and make your first API call
  • Authentication — understand the OAuth 2.0 flow and credential management