SDKs overview
Storm Glass offers Software Development Kits (SDKs) to simplify interaction with its Marine Weather API and Historical Weather Data. These SDKs are designed to reduce boilerplate code, manage authentication, and handle data requests and responses programmatically. By using an SDK, developers can integrate weather data, such as wave height, wind speed, and temperature, into their applications without directly managing HTTP requests, URL construction, or JSON parsing for each API call.
The SDKs provide language-specific interfaces that map directly to the API's functionality, allowing developers to retrieve current conditions, forecasts, and historical data for various marine parameters. This abstraction layer aims to expedite development cycles for applications requiring detailed marine weather information, supporting use cases from maritime logistics to recreational water sports planning. The official Storm Glass documentation provides comprehensive guides for API usage and SDK integration.
Official SDKs by language
Storm Glass currently provides official SDKs for two programming languages, facilitating direct integration into projects built with these environments. These SDKs are maintained by Storm Glass to ensure compatibility with API updates and to offer a consistent developer experience.
| Language | Package Name | Installation Command | Maturity |
|---|---|---|---|
| Python | stormglass.py |
pip install stormglass.py |
Stable |
| Node.js | @stormglass/js-sdk |
npm install @stormglass/js-sdk |
Stable |
These packages are designed to cover the core functionalities of the Storm Glass API, including fetching various marine weather parameters and handling authentication with an API key. Developers can find detailed usage examples and API endpoint mappings within the Storm Glass documentation.
Installation
Installing the Storm Glass SDKs follows standard package management practices for Python and Node.js environments. Ensure you have the respective language runtime and package manager installed before proceeding.
Python
For Python projects, the stormglass.py package can be installed using pip, the standard package installer for Python. Python itself is a widely used general-purpose programming language often employed in data science and web development, as noted by the Mozilla Developer Network's Python overview.
pip install stormglass.py
After installation, you can import the library into your Python scripts.
Node.js
For Node.js applications, the @stormglass/js-sdk package is available via npm, the default package manager for JavaScript runtime environment Node.js.
npm install @stormglass/js-sdk
Once installed, you can import the module into your JavaScript or TypeScript files. Node.js is frequently chosen for its event-driven architecture and non-blocking I/O, which makes it suitable for real-time applications, as documented by Google Cloud's language comparisons.
Quickstart example
This section provides basic quickstart examples for both Python and Node.js, demonstrating how to fetch marine weather data. Ensure you replace YOUR_API_KEY with your actual Storm Glass API key, which can be obtained from the Storm Glass authentication documentation.
Python Quickstart
This Python example demonstrates how to request wave height and wind speed for a specific location and time.
from stormglass import StormGlass
from datetime import datetime
api_key = "YOUR_API_KEY"
lat = 58.7984
lng = 17.8081
# Define parameters to retrieve
params = [
StormGlass.WEATHER_DATA_WAVE_HEIGHT,
StormGlass.WEATHER_DATA_WIND_SPEED
]
# Define the start and end time for the forecast
# Storm Glass API expects times in ISO 8601 format
start_time = datetime.utcnow().isoformat(timespec='minutes') + 'Z'
# You might want to fetch multiple forecast hours, for simplicity, we fetch just one point
# For fetching a range, provide an end_time as well
# Example for fetching a single point in time, using the current UTC time
client = StormGlass(api_key)
try:
# Fetch a single point in time. For a range, you would add end_time parameter.
response = client.get_weather_data(
lat=lat,
lng=lng,
params=params,
start=start_time,
end=start_time # For a single point, start and end are the same
)
if response.status_code == 200:
data = response.json()
if data and 'hours' in data and data['hours']:
print(f"Weather data for {lat}, {lng} at {data['hours'][0]['time']}:")
for param_data in data['hours'][0]['airTemperature']:
print(f" Air Temperature: {param_data['value']} {param_data['unit']}")
for param_data in data['hours'][0]['waveHeight']:
print(f" Wave Height: {param_data['value']} {param_data['unit']}")
for param_data in data['hours'][0]['windSpeed']:
print(f" Wind Speed: {param_data['value']} {param_data['unit']}")
else:
print("No weather data found for the specified parameters.")
else:
print(f"Error fetching data: {response.status_code} - {response.text}")
except Exception as e:
print(f"An error occurred: {e}")
Node.js Quickstart
This Node.js example illustrates how to use the @stormglass/js-sdk to retrieve wave height and wind speed data.
const { Client } = require('@stormglass/js-sdk');
const apiKey = 'YOUR_API_KEY';
const lat = 58.7984;
const lng = 17.8081;
const params = [
Client.WEATHER_DATA_WAVE_HEIGHT,
Client.WEATHER_DATA_WIND_SPEED,
Client.WEATHER_DATA_AIR_TEMPERATURE
];
// Get current UTC time in ISO 8601 format for a single point forecast
const now = new Date();
const start = now.toISOString().slice(0, 16) + 'Z'; // YYYY-MM-DDTHH:MMZ format
const stormglassClient = new Client(apiKey);
async function getWeatherData() {
try {
const response = await stormglassClient.getWeatherData(
lat,
lng,
params,
start,
start // For a single point forecast, start and end are the same
);
if (response && response.data && response.data.hours && response.data.hours.length > 0) {
const firstHourData = response.data.hours[0];
console.log(`Weather data for ${lat}, ${lng} at ${firstHourData.time}:`);
if (firstHourData.airTemperature && firstHourData.airTemperature.length > 0) {
console.log(` Air Temperature: ${firstHourData.airTemperature[0].value} ${firstHourData.airTemperature[0].unit}`);
}
if (firstHourData.waveHeight && firstHourData.waveHeight.length > 0) {
console.log(` Wave Height: ${firstHourData.waveHeight[0].value} ${firstHourData.waveHeight[0].unit}`);
}
if (firstHourData.windSpeed && firstHourData.windSpeed.length > 0) {
console.log(` Wind Speed: ${firstHourData.windSpeed[0].value} ${firstHourData.windSpeed[0].unit}`);
}
} else {
console.log('No weather data found or response format unexpected.');
}
} catch (error) {
console.error('Error fetching weather data:', error.response ? error.response.data : error.message);
}
}
getWeatherData();
Community libraries
While Storm Glass provides official SDKs for Python and Node.js, the API is a RESTful service, meaning it can be accessed using standard HTTP client libraries in any programming language. This flexibility allows the community to develop and maintain unofficial libraries or wrappers, often driven by specific project needs or preferred language ecosystems. These community-contributed tools can sometimes offer additional features, different architectural patterns, or support for languages not covered by official SDKs.
Community libraries are typically found on platforms like GitHub, PyPI (for Python), or npm (for Node.js), and their discovery often involves searching for "Storm Glass" combined with the desired programming language or framework. Developers considering a community library should assess its active maintenance, documentation quality, and community support. The Storm Glass API's adherence to standard HTTP principles means that even without a dedicated SDK, developers can interact with it using generic HTTP client libraries such as requests in Python or axios/fetch in JavaScript, as outlined in the Storm Glass API documentation.
It is important to review the source code and licensing of any community-contributed library before integrating it into a production environment. For direct and officially supported integrations, the official SDKs are recommended due to their guaranteed compatibility and maintenance by Storm Glass.