# The Forecasting Company Python SDK
[](https://pypi.org/project/theforecastingcompany/)
[](https://status.retrocast.com)
The python SDK provides a simple interface to make forecasts using the TFC API.
## Documentation
The REST API documentation can be found on [https://api.retrocast.com/docs](https://api.retrocast.com/docs).
To get an API key, visit the [Authentication docs](https://api.retrocast.com/docs/routes#authentication). In the **API Keys** section you will find an option to _Sign in_ or, if you already signed in, a box containing your API key.
## Installation
```sh
# install from PyPI
pip install theforecastingcompany
```
## Usage
```python
# By default it will look for api_key in os.getenv("TFC_API_KEY"). Otherwise you can explicity set the api_key argument
client = TFCClient()
# Compute forecast for a single model
timesfm_df = client.forecast(
train_df,
model=TFCModels.TimesFM_2 # StrEnum defined in utils. You can also pass the model name as a string, eg timesfm-2
horizon=12,
freq="W",
)
# Global Model with static variables
tfc_global_df = client.forecast(
train_df,
model=TFCModels.TFCGlobal,
horizon=12,
freq="W",
static_variables=["unique_id","Group","Vendor","Category"],
add_holidays=True,
add_events=True,
country_isocode = "US"
)
```
If future_variables are available, make sure to pass also a `future_df` when forecasting, and setting the `future_variables` argument. All future variables must be present in the `future_df`.
The `cross_validate` function is basically the same, but takes a `fcds` argument to define the FCDs to use for cross-validation. It also returns the target column in the output dataframe.
`train_df` and `future_df` should have `id_col` (default "unique_id"), `date_col` (default "ds"), and `target_col` (default "target"). You can set the corresponding arguments if column names are different from default ones.
## Versioning
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
1. Changes that only affect static types, without breaking runtime behavior.
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
3. Changes that we do not expect to impact the vast majority of users in practice.
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
We are keen for your feedback; please open an [issue](https://www.github.com/openai/openai-python/issues) with questions, bugs, or suggestions.
### Determining the installed version
If you've upgraded to the latest version but aren't seeing any new features you were expecting then your python environment is likely still using an older version.
You can determine the version that is being used at runtime with:
```py
import theforecastingcompany
print(theforecastingcompany.__version__)
```
## Requirements
Python 3.11 or higher.
Raw data
{
"_id": null,
"home_page": null,
"name": "theforecastingcompany",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "api, artificial-intelligence, data-science, deep-learning, forecasting, foundation-model, machine-learning, prediction, python-sdk, tfc, time-series, time-series-forecasting",
"author": null,
"author_email": "The Forecasting Company <support@theforecastingcompany.com>",
"download_url": "https://files.pythonhosted.org/packages/7b/6e/a4478c7ee36b31bdcbc0f1b1857af91ffaf90722fb8126e4f9dc6debacf3/theforecastingcompany-0.1.2.tar.gz",
"platform": null,
"description": "# The Forecasting Company Python SDK\n\n[](https://pypi.org/project/theforecastingcompany/)\n[](https://status.retrocast.com)\n\nThe python SDK provides a simple interface to make forecasts using the TFC API.\n\n## Documentation\n\nThe REST API documentation can be found on [https://api.retrocast.com/docs](https://api.retrocast.com/docs).\n\nTo get an API key, visit the [Authentication docs](https://api.retrocast.com/docs/routes#authentication). In the **API Keys** section you will find an option to _Sign in_ or, if you already signed in, a box containing your API key.\n\n## Installation\n\n```sh\n# install from PyPI\npip install theforecastingcompany\n```\n\n## Usage\n\n```python\n# By default it will look for api_key in os.getenv(\"TFC_API_KEY\"). Otherwise you can explicity set the api_key argument\nclient = TFCClient()\n\n# Compute forecast for a single model\ntimesfm_df = client.forecast(\n train_df,\n model=TFCModels.TimesFM_2 # StrEnum defined in utils. You can also pass the model name as a string, eg timesfm-2\n horizon=12,\n freq=\"W\",\n)\n\n# Global Model with static variables\ntfc_global_df = client.forecast(\n train_df,\n model=TFCModels.TFCGlobal,\n horizon=12,\n freq=\"W\",\n static_variables=[\"unique_id\",\"Group\",\"Vendor\",\"Category\"],\n add_holidays=True,\n add_events=True,\n country_isocode = \"US\"\n )\n```\n\nIf future_variables are available, make sure to pass also a `future_df` when forecasting, and setting the `future_variables` argument. All future variables must be present in the `future_df`.\n\nThe `cross_validate` function is basically the same, but takes a `fcds` argument to define the FCDs to use for cross-validation. It also returns the target column in the output dataframe. \n\n`train_df` and `future_df` should have `id_col` (default \"unique_id\"), `date_col` (default \"ds\"), and `target_col` (default \"target\"). You can set the corresponding arguments if column names are different from default ones.\n\n## Versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/openai/openai-python/issues) with questions, bugs, or suggestions.\n\n### Determining the installed version\n\nIf you've upgraded to the latest version but aren't seeing any new features you were expecting then your python environment is likely still using an older version.\n\nYou can determine the version that is being used at runtime with:\n\n```py\nimport theforecastingcompany\nprint(theforecastingcompany.__version__)\n```\n\n## Requirements\n\nPython 3.11 or higher.\n",
"bugtrack_url": null,
"license": null,
"summary": "The official Python library for The Forecasting Company API",
"version": "0.1.2",
"project_urls": {
"docs": "https://api.retrocast.com/docs",
"homepage": "https://theforecastingcompany.com",
"repository": "https://github.com/theforecastingcompany/theforecastingcompany-sdk-python"
},
"split_keywords": [
"api",
" artificial-intelligence",
" data-science",
" deep-learning",
" forecasting",
" foundation-model",
" machine-learning",
" prediction",
" python-sdk",
" tfc",
" time-series",
" time-series-forecasting"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "907f0dbd01b626f894e3c6a7e8a46f6d379c0014dd8f442b9c4ca00545f42fa2",
"md5": "9da34df5e8b337230800820d1a934b67",
"sha256": "d56a0b0ef2239b0e543853c3c5fe46c97fdac06cad445637a2d64fb8b43b4499"
},
"downloads": -1,
"filename": "theforecastingcompany-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9da34df5e8b337230800820d1a934b67",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 20338,
"upload_time": "2025-07-24T15:39:23",
"upload_time_iso_8601": "2025-07-24T15:39:23.873868Z",
"url": "https://files.pythonhosted.org/packages/90/7f/0dbd01b626f894e3c6a7e8a46f6d379c0014dd8f442b9c4ca00545f42fa2/theforecastingcompany-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "7b6ea4478c7ee36b31bdcbc0f1b1857af91ffaf90722fb8126e4f9dc6debacf3",
"md5": "cd88c7a1cf5719888113f75a619883a1",
"sha256": "a081d411e31319dfa3f5092250ce3869262ed4d7ce93f6e57c82cf7a7c9e8c37"
},
"downloads": -1,
"filename": "theforecastingcompany-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "cd88c7a1cf5719888113f75a619883a1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 39605,
"upload_time": "2025-07-24T15:39:24",
"upload_time_iso_8601": "2025-07-24T15:39:24.638389Z",
"url": "https://files.pythonhosted.org/packages/7b/6e/a4478c7ee36b31bdcbc0f1b1857af91ffaf90722fb8126e4f9dc6debacf3/theforecastingcompany-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-24 15:39:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "theforecastingcompany",
"github_project": "theforecastingcompany-sdk-python",
"github_not_found": true,
"lcname": "theforecastingcompany"
}