Skip to main content

SDK to access the advisor core API.

Project description

Python SDK

Advisor Software Development Kit for python.

Contents


Importing

To install this package, use the following command:`

pip install stormgeo.advisor-core

Make sure you're using python 3.8 or higher.

Routes

First you need to import the SDK on your application and instancy the AdvisorCore class setting up your access token and needed configurations:

from advisor_core import *

advisor = AdvisorCore("<your_token>", retries=5, delay=5)

Examples

Get data from different routes with theses examples

Chart

payload = WeatherPayload(
  locale_id=1234,
  variables=["temperature", "precipitation"]
)

# requesting daily forecast chart image
response = advisor.chart.get_forecast_daily(payload)

# requesting hourly forecast chart image
response = advisor.chart.get_forecast_hourly(payload)

# requesting daily observed chart image
response = advisor.chart.get_observed_daily(payload)

# requesting hourly observed chart image
response = advisor.chart.get_observed_hourly(payload)

if response['error']:
  print('Error trying to get data!')
  print(response['error'])
else:
  with open("response.png", "wb") as f:
    f.write(response["data"])

Climatology

payload = ClimatologyPayload(
  locale_id=1234,
  variables=["temperature", "precipitation"]
)

# requesting daily climatology data
response = advisor.climatology.get_daily(payload)

# requesting monthly climatology data
response = advisor.climatology.get_monthly(payload)

if response['error']:
  print('Error trying to get data!')
  print(response['error'])
else:
  print(response['data'])

Current Weather

payload = CurrentWeatherPayload(
  locale_id=1234
)

response = advisor.current_weather.get(payload)

if response['error']:
  print('Error trying to get data!')
  print(response['error'])
else:
  print(response['data'])

Forecast

payload = WeatherPayload(
  locale_id=1234,
  variables=["temperature", "precipitation"]
)

# requesting daily forecast data
response = advisor.forecast.get_daily(payload)

# requesting hourly forecast data
response = advisor.forecast.get_hourly(payload)

# requesting period forecast data
response = advisor.forecast.get_period(payload)

if response['error']:
  print('Error trying to get data!')
  print(response['error'])
else:
  print(response['data'])

Monitoring

response = advisor.monitoring.get_alerts()

if response['error']:
  print('Error trying to get data!')
  print(response['error'])
else:
  print(response['data'])

Observed

payload = WeatherPayload(
  locale_id=1234,
)

payload_for_station = StationPayload(
  station_id="ABC123abc321CBA"
)

payload_for_radius = RadiusPayload(
  locale_id=1234,
  radius=1000
)

payload_for_geometry = GeometryPayload(
  geometry="{\"type\": \"MultiPoint\", \"coordinates\": [[-41.88, -22.74]]}",
  radius=10000
)

payload_for_lightning_lite = LightningLitePayload(
  geometry="{\"type\": \"MultiPoint\", \"coordinates\": [[-41.88, -22.74]]}",
  radius=10000,
  page=1,
  page_size=10
)

# requesting daily observed data
response = advisor.observed.get_daily(payload)

# requesting hourly observed data
response = advisor.observed.get_hourly(payload)

# requesting period observed data
response = advisor.observed.get_period(payload)

# requesting station observed data
response = advisor.observed.get_station_data(payload_for_station)

# requesting fire-focus observed data
response = advisor.observed.get_fire_focus(payload_for_radius)

# requesting lightning observed data
response = advisor.observed.get_lightning(payload_for_radius)

# requesting lightning observed details data
response = advisor.observed.get_lightning_details(payload_for_radius)

# requesting fire-focus observed data by geometry
response = advisor.observed.get_fire_focus_by_geometry(payload_for_geometry)

# requesting lightning observed data by geometry
response = advisor.observed.get_lightning_by_geometry(payload_for_geometry)

# requesting lightning lite observed data by geometry
response = advisor.observed.get_lightning_lite(payload_for_lightning_lite)

if response['error']:
  print('Error trying to get data!')
  print(response['error'])
else:
  print(response['data'])

Stations

payload = StationsLastDataPayload(
  station_ids=["ABC123abc321CBA", "XYZ789xyz987ZYX"], # optional
  variables=["temperature", "humidity"] # optional
)

# requesting last observed data for multiple stations
response = advisor.stations.get_last_data(payload)

if response['error']:
  print('Error trying to get data!')
  print(response['error'])
else:
  print(response['data'])

Storage

payload = StorageListPayload(
  page=1,
  page_size=10,
  file_types=["pdf", "csv"]
)

payload_for_download = StorageDownloadPayload(
  file_name="Example.pdf",
  access_key="a1b2c3d4-0010"
)

# requesting the files list
response = advisor.storage.list_files(payload)

if response['error']:
  print('Error trying to get data!')
  print(response['error'])
else:
  print(response['data'])

# downloading a file from the list
response = advisor.storage.download_file(payload_for_download)

if response['error']:
    print('Error trying to get data')
    print(response['error'])
else:
    with open(payload_for_download.file_name, "wb") as f:
        f.write(response["data"])

# downloading a file by stream
response = advisor.storage.download_file_by_stream(payload_for_download)

if response['error']:
    print('Error trying to get data')
    print(response['error'])
else:
    with open(payload_for_download.file_name, "wb") as f:
        for chunk in response['data']:
            if chunk:
                f.write(chunk)

Plan Information

# requesting plan information
plan_info_payload = PlanInfoPayload(
    timezone=-3
)

plan_info_response = advisor.plan.get_info(plan_info_payload)

if plan_info_response['error']:
    print('Error trying to get plan information!')
    print(plan_info_response['error'])
else:
    print(plan_info_response['data'])

# requesting locale details
plan_locale_payload = PlanLocalePayload(
    locale_id=1234,
    # You can also set Latitude/Longitude or StationId instead of LocaleId
)

plan_locale_response = advisor.plan.get_locale(plan_locale_payload)

if plan_locale_response['error']:
    print('Error trying to get plan locale!')
    print(plan_locale_response['error'])
else:
    print(plan_locale_response['data'])

# requesting access history
request_details_payload = RequestDetailsPayload(
    page=1,
    page_size=10
)

request_details_response = advisor.plan.get_request_details(request_details_payload)

if request_details_response['error']:
    print('Error trying to get request details!')
    print(request_details_response['error'])
else:
    print(request_details_response['data'])

Static Map

payload = StaticMapPayload(
    type="periods",
    category="observed",
    variable="temperature",
    aggregation="max",
    start_date="2025-07-01 00:00:00",
    end_date="2025-07-05 23:59:59",
    dpi=50,
    title=True,
    titlevariable="Static Map",
)

response = advisor.static_map.get_static_map(payload)

if response['error']:
    print('Error trying to get data!')
    print(response['error'])
else:
    with open("response.png", "wb") as f:
        f.write(response["data"])

Schema/Parameter

# Arbitrary example on how to define a schema
payload_schema_definition = {
  "identifier": "arbitraryIdentifier",
  "arbitraryField1": {
      "type": "boolean",
      "required": True,
      "length": 125,
  },
  "arbitraryField2": {
      "type": "number",
      "required": True,
  },
  "arbitraryField3": {
      "type": "string",
      "required": False,
  }
}

# Arbitrary example on how to upload data to parameters from schema 
payload_schema_parameters = {
  "identifier": "arbitraryIdentifier",
  "arbitraryField1": True,
  "arbitraryField2": 15
}

# requesting all schemas from token
response = advisor.schema.get_definition()

# requesting to upload a new schema
response = advisor.schema.post_definition(payload_schema_definition)

# requesting to upload data to parameters from schema
response = advisor.schema.post_parameters(payload_schema_parameters)

if response['error']:
  print('Error trying to get data!')
  print(response['error'])
else:
  print(response['data'])

Tms (Tiles Map Server)

payload = TmsPayload(
  istep="2024-12-25 10:00:00",
  fstep="2024-12-25 12:00:00",
  server="a",
  mode="forecast",
  variable="precipitation",
  aggregation="sum",
  x=2,
  y=3,
  z=4
)

response = advisor.tms.get(payload)

if response['error']:
  print('Error trying to get data!')
  print(response['error'])
else:
  with open("response.png", "wb") as f:
    f.write(response["data"])

Pmtiles

payload = PmtilesPayload(
  mode="forecast",
  model="ct2w15_as",
  variable="precipitation",
  aggregation="sum",
  istep="2026-03-02 00:00:00",
  fstep="2026-03-02 01:00:00",
  max_zoom=4,
)

response = advisor.pmtiles.get(payload)

if response['error']:
  print('Error trying to get data!')
  print(response['error'])
else:
  with open("response.pmtiles", "wb") as f:
    f.write(response["data"])

Headers Configuration

You can also set headers to translate the error descriptions or to receive the response in a different format type. This functionality is only available for some routes, consult the API documentation to find out which routes have this functionality.

Available languages:

  • en-US (default)
  • pt-BR
  • es-ES

Available response types:

  • application/json (default)
  • application/xml
  • text/csv

Example:

advisor = AdvisorCore("invalid-token")

advisor.setHeaderAccept("application/xml")
advisor.setHeaderAcceptLanguage("es-ES")

response = advisor.plan.get_info()

print(response["error"])

// <response>
//   <error>
//     <type>UNAUTHORIZED_ACCESS</type>
//     <message>UNAUTHORIZED_REQUEST</message>
//     <description>La solicitud no está autorizada.</description>
//   </error>
// </response>

Response Format

All the methods will return the same pattern:

{
  "data": Any | None,
  "error": Any | None,
}

Payload Types

WeatherPayload

  • locale_id: int
  • station_id: str
  • latitude: float
  • longitude: float
  • timezone: int
  • variables: List[str]
  • start_date: str
  • end_date: str

StationPayload

  • station_id: str
  • layer: str
  • timezone: int
  • variables: List[str]
  • start_date: str
  • end_date: str

StationsLastDataPayload

  • station_ids: List[str]
  • variables: List[str]

ClimatologyPayload

  • locale_id: int
  • station_id: str
  • latitude: float
  • longitude: float
  • variables: List[str]

CurrentWeatherPayload

  • locale_id: int
  • station_id: str
  • latitude: float
  • longitude: float
  • timezone: int
  • variables: List[str]

RadiusPayload

  • locale_id: int
  • station_id: str
  • latitude: float
  • longitude: float
  • start_date: str
  • end_date: str
  • radius: int

GeometryPayload

  • start_date: str
  • end_date: str
  • radius: int
  • geometry: str

LightningLitePayload

  • start_date: str
  • end_date: str
  • radius: int
  • geometry: str
  • page: number
  • page_size: number
  • sources: List[str]

TmsPayload

  • server: str
  • mode: str
  • variable: str
  • aggregation: str
  • x: int
  • y: int
  • z: int
  • istep: str
  • fstep: str
  • timezone: int

PmtilesPayload

  • mode: str
  • model: str
  • variable: str
  • aggregation: str
  • istep: str
  • fstep: str
  • timezone: int
  • max_zoom: int
  • cmap: str
  • dynamic_elevation: str
  • dynamic_type: str
  • dynamic_variable: str

PlanInfoPayload

  • timezone: int

PlanLocalePayload

  • locale_id: int
  • station_id: str
  • latitude: str
  • longitude: str

RequestDetailsPayload

  • page: int
  • page_size: int
  • path: str
  • status: int
  • start_date: str
  • end_date: str

StorageListPayload

  • page: int
  • page_size: int
  • start_date: str
  • end_date: str
  • file_name: str
  • file_extension: str
  • file_types: List[str]

StorageDownloadPayload

  • file_name: str
  • access_key: str

StaticMapPayload

  • start_date: str
  • end_date: str
  • aggregation: str
  • model: str
  • lonmin: float
  • latmin: float
  • lonmax: float
  • latmax: float
  • dpi: int
  • title: bool
  • titlevariable: str
  • hours: int
  • type: str
  • category: str
  • variable: str

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

stormgeo_advisor_core-1.6.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

stormgeo_advisor_core-1.6.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file stormgeo_advisor_core-1.6.0.tar.gz.

File metadata

  • Download URL: stormgeo_advisor_core-1.6.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for stormgeo_advisor_core-1.6.0.tar.gz
Algorithm Hash digest
SHA256 59b40bdac66938ab183f79bc24a05e24300ea94b400db2dd5fd0bdee126b67c7
MD5 b33a7568ebca80f9a931266c6527d555
BLAKE2b-256 bebb89f8a91b60ffe66b7005a94fddb477586b1baa13497b9de21aca1b4e0bf4

See more details on using hashes here.

File details

Details for the file stormgeo_advisor_core-1.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for stormgeo_advisor_core-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fb3987af5c5756b881759c6b7782e4805d46db46cea37d4b09552469c81ddbbe
MD5 32079a2e2877a8f861a618f32e175ad1
BLAKE2b-256 8649bfc6b20548c96b66b3c5f4045763be7a237b74dc58f695d9babcbe991941

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