Skip to main content

Python client for the Synthefy API forecasting service

Project description

Synthefy Python Client

A Python client for the Synthefy API forecasting service. This package provides an easy-to-use interface for making time series forecasting requests.

Features

  • Simple API Client: Easy-to-use client for making forecasting requests
  • Pandas Integration: Built-in support for pandas DataFrames
  • Type Safety: Full type hints and Pydantic validation
  • Flexible Data Handling: Support for multiple data sources and metadata columns

Installation

pip install synthefy

Quick Start

Basic Usage

from synthefy import SynthefyAPIClient
import pandas as pd

# Initialize the client
client = SynthefyAPIClient(api_key="your_api_key_here")

# Or use environment variable
# export SYNTHEFY_API_KEY="your_api_key_here"
client = SynthefyAPIClient()

Making a Forecast Request

from synthefy import SynthefyAPIClient
from synthefy.data_models import ForecastV2Request
import pandas as pd

# Create sample data
history_data = {
    'timestamp': ['2024-01-01', '2024-01-02', '2024-01-03'],
    'sales': [100, 120, 110],
    'temperature': [20, 22, 21]
}

target_data = {
    'timestamp': ['2024-01-04', '2024-01-05', '2024-01-06'],
    'sales': [None, None, None],  # Values to forecast
    'temperature': [23, 24, 22]   # Known future values
}

history_df = pd.DataFrame(history_data)
target_df = pd.DataFrame(target_data)

# Create request using the convenience method
response = client.forecast_dfs(
    history_dfs=[history_df],
    target_dfs=[target_df],
    target_col='sales',
    timestamp_col='timestamp',
    metadata_cols=['temperature'],
    leak_cols=[],  # No leak columns in this example
    model='sfm_moe'
)

# response is a list of DataFrames with forecasts
forecast_df = response[0]
print(forecast_df)

Advanced Usage with Multiple Data Sources

# Multiple data sources
history_dfs = [history_df1, history_df2, history_df3]
target_dfs = [target_df1, target_df2, target_df3]

response = client.forecast_dfs(
    history_dfs=history_dfs,
    target_dfs=target_dfs,
    target_col='revenue',
    timestamp_col='date',
    metadata_cols=['marketing_spend', 'competitor_price'],
    leak_cols=['marketing_spend'],  # This column is known in the future
    model='sfm_moe'
)

# Each DataFrame in response corresponds to one data source
for i, forecast_df in enumerate(response):
    print(f"Forecast for data source {i}:")
    print(forecast_df)

API Reference

SynthefyAPIClient

The main client class for interacting with the Synthefy API.

Methods

  • forecast(request: ForecastV2Request) -> ForecastV2Response: Make a direct forecast request
  • forecast_dfs(...) -> List[pd.DataFrame]: Convenience method for working with pandas DataFrames

Parameters

  • api_key: Your Synthefy API key (can also be set via SYNTHEFY_API_KEY environment variable)
  • timeout: Request timeout in seconds (default: 120.0)

Configuration

Environment Variables

  • SYNTHEFY_API_KEY: Your Synthefy API key

Support

For support and questions:

License

MIT License - see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

synthefy-0.1.2.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

synthefy-0.1.2-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file synthefy-0.1.2.tar.gz.

File metadata

  • Download URL: synthefy-0.1.2.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for synthefy-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f60e811ef871c295e28359cf49220581e164758014a1c3aa595448d0652307f3
MD5 f8d006f9aba81c0cba060f8f039664a5
BLAKE2b-256 763bdaca20f2cafd88780611858f03190a00948f8c01003c01e9d25edd96b660

See more details on using hashes here.

File details

Details for the file synthefy-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: synthefy-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for synthefy-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ff8c96336872fc7d1da21cd472fcba18269db730fc7d68b42c8a31d962f8d3bc
MD5 ff809c15d1f071ea84ba3e19ba6ba939
BLAKE2b-256 35a292316a3981da8f802a0dcfdce2c3fc80134a200a288c082d429c59549213

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page