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 python-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_sdk import AdvisorCore

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

Examples

Get data from different routes with theses examples

Chart

from payloads import WeatherPayload

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

from payloads import ClimatologyPayload

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

from payloads import CurrentWeatherPayload

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

from payloads import WeatherPayload

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

from payloads import (WeatherPayload, StationPayload, RadiusPayload, GeometryPayload)

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
)

# 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 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)

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

Plan Information

response = advisor.plan.get_info()

if response['error']:
  print('Error trying to get data!')
  print(response['error'])
else:
  print(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)

from payloads import TmsPayload

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"])

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
  • variables: List[str]
  • start_date: str
  • end_date: 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

TmsPayload

  • server: str
  • mode: str
  • variable: str
  • aggregation: str
  • x: int
  • y: int
  • z: int
  • istep: str
  • fstep: 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-0.1.0.tar.gz (8.8 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-0.1.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file stormgeo.advisor-core-0.1.0.tar.gz.

File metadata

  • Download URL: stormgeo.advisor-core-0.1.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for stormgeo.advisor-core-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3f9b85002b7041fb3759941c3a02f111cc2409ecc4042a971b42e7ce5310ace0
MD5 8251f33e29815d99abfc8a831ffbd984
BLAKE2b-256 0ebd484eb8a5c4161f260b5ed1f35870b9a3408f89fa1bdfe84d3337cc96dc8f

See more details on using hashes here.

File details

Details for the file stormgeo.advisor_core-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for stormgeo.advisor_core-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7db7ff94e7301d57f0b1cb054a44a2519539f128e1f68dc062a9053f4aa9fbd8
MD5 1c5384293500a00a98a5f917c3327dbe
BLAKE2b-256 f3970da7b5c086bd74414eaba68eeba0a69cb75a70cd7f82a06dafbcf8f281a2

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