Sybilion R SDK

Official R client for the Sybilion API.

Install

From a local checkout:

install.packages(c("jsonlite", "httr2", "R6", "base64enc", "stringr"))
install.packages("path/to/developers-portal-api-sdk-r", repos = NULL, type = "source")

Configuration

Quick use (me)

library(sybilion)

cl <- sybilion_client(
  token = Sys.getenv("SYBILION_API_TOKEN"),
  base_url = "https://api.sybilion.dev"
)
me <- cl$raw$ApiV1MeGet()

Use Client/sybilion_client() for Bearer setup; iter_usage_pages and iter_jobs_pages mirror Go/Python pagination helpers; wait_forecast polls until settled.

Forecasting (end-to-end)

library(jsonlite)
library(sybilion)

cl <- sybilion_client(token = Sys.getenv("SYBILION_API_TOKEN"))
cl$raw$ApiV1MeGet()

payload <- jsonlite::fromJSON("forecast_post_example.json")

req <- ForecastRequestV1$new(
  frequency = payload$frequency,
  pipeline_version = payload$pipeline_version,
  recency_factor = payload$recency_factor,
  timeseries = payload$timeseries,
  timeseries_metadata = TimeseriesMetadata$new(
    title = payload$timeseries_metadata$title,
    description = payload$timeseries_metadata$description,
    keywords = payload$timeseries_metadata$keywords
  ),
  backtest = payload$backtest,
  hard_horizon = payload$hard_horizon,
  soft_horizon = payload$soft_horizon,
  strictly_positive = payload$strictly_positive
)

if (!is.null(payload$filters)) {
  req$filters <- Filters$new(
    categories = payload$filters$categories,
    regions = payload$filters$regions,
    limit = payload$filters$limit
  )
}

started <- cl$raw$ApiV1ForecastsPost(req)
job <- cl$wait_forecast(started$job_id, poll_s = 2, timeout_s = 1800)

To bring your own forecast drivers, set ForecastRequestV1$aux_timeseries to a list of 1–10 series, each a named numeric list keyed on the same dates as timeseries:

ForecastRequestV1$new(
  pipeline_version = "v1", frequency = "monthly", recency_factor = 0.5,
  soft_horizon = 12, timeseries_metadata = meta, timeseries = ts,
  aux_timeseries = list(
    list(`2015-01-01` = 1.2, `2015-02-01` = 1.4),
    list(`2015-01-01` = 9.0, `2015-02-01` = 8.7)
  )
)

Discover categories and regions

library(sybilion)

cl <- sybilion_client(token = Sys.getenv("SYBILION_API_TOKEN"))

cats <- cl$raw$ApiV1CategoriesGet()
# cats$content is a CategoryListResponse; each item has $id and $name
for (cat in cats$content$items) {
  cat(sprintf("category id=%d  name=%s\n", cat$id, cat$name))
}

regions <- cl$raw$ApiV1RegionsGet()
# regions$content is a RegionListResponse; each item has $id, $name, $latitude, $longitude
for (r in regions$content$items) {
  cat(sprintf("region id=%d  name=%s  lat=%.2f  lon=%.2f\n",
              r$id, r$name, r$latitude, r$longitude))
}

Download an artifact

a <- job$artifacts[[1]]
cl$raw$ApiV1ForecastsIdArtifactsNameGet(job$job_id, a$name, data_file = file.path("out", a$name))

Maintainer commands

bash scripts/sync-from-api-repo.sh   # copy openapi.public.yaml → openapi/openapi.yaml
bash scripts/sdk-generate-r.sh       # regenerate R + docs (Docker); preserves R/client.R, R/env.R, R/defaults.R
bash scripts/sdk-verify-r.sh
make verify

Documentation

Full guides, feature walkthroughs, API reference, and SDK patterns: https://sybilion.dev/docs/.

Support