SDKs overview

Software Development Kits (SDKs) and client libraries for HG Weather streamline the process of integrating weather data into applications. Rather than constructing HTTP requests directly to the HG Weather API endpoints, developers can use these tools to interact with the API through native language constructs. This approach typically involves functions or methods for common operations like fetching current weather, historical data, or forecasts, abstracting underlying RESTful interactions and JSON parsing.

HG Weather provides official SDKs for several popular programming languages, ensuring direct support and maintenance from the platform. These official libraries are designed to offer a consistent and reliable interface for accessing core HG Weather services, including real-time weather, historical datasets, and predictive models. Additionally, a community of developers contributes unofficial libraries, expanding support to other languages or offering alternative implementations, which can be useful for specific project requirements or niche environments.

The use of an SDK can reduce development time by providing pre-built functionalities for common tasks such as API key management, request serialization, response deserialization, and error handling. This allows developers to focus on application logic rather than the intricacies of API communication. For example, an SDK might include specific methods to retrieve weather by city name, geographic coordinates, or postal code, returning structured data objects that can be easily manipulated within the application's programming language.

Official SDKs by language

HG Weather offers official SDKs for a range of programming languages, developed and maintained to provide direct support for its API. These SDKs are designed to integrate seamlessly with the HG Weather documentation and API structure, ensuring compatibility and access to the full suite of weather data services. Each SDK typically includes client classes, data models, and utility functions specific to its language ecosystem.

The following table outlines the official SDKs provided by HG Weather, including their respective package names and installation commands. These SDKs are the recommended method for integrating HG Weather data into applications built with these languages, as they are regularly updated and supported.

Language Package Name Installation Command Maturity
Python hgweather-python pip install hgweather-python Stable
Node.js @hgweather/nodejs-sdk npm install @hgweather/nodejs-sdk Stable
PHP hgweather/php-sdk composer require hgweather/php-sdk Stable
Ruby hgweather-ruby gem install hgweather-ruby Stable
Java com.hgweather:java-sdk Add to pom.xml or build.gradle Stable
Go github.com/hgweather/go-sdk go get github.com/hgweather/go-sdk Stable

Installation

Installation of HG Weather's official SDKs follows standard package management practices for each respective programming language. Each SDK is distributed through its language's primary package repository, allowing for straightforward integration into existing projects. Developers should ensure they have the appropriate package manager installed and configured for their environment.

Python

The Python SDK can be installed using pip, the Python package installer. It requires Python 3.6 or later.

pip install hgweather-python

Node.js

The Node.js SDK is available via npm. It requires Node.js 12 or later.

npm install @hgweather/nodejs-sdk

Alternatively, if using Yarn:

yarn add @hgweather/nodejs-sdk

PHP

The PHP SDK uses Composer for dependency management. It requires PHP 7.4 or later.

composer require hgweather/php-sdk

Ruby

The Ruby SDK is distributed as a Gem. It requires Ruby 2.5 or later.

gem install hgweather-ruby

Java

For Java projects, the SDK can be included as a dependency using Maven or Gradle. It requires Java 8 or later.

Maven (pom.xml):

<dependency>
    <groupId>com.hgweather</groupId>
    <artifactId>java-sdk</artifactId>
    <version>1.0.0</version> <!-- Replace with the latest version -->
</dependency>

Gradle (build.gradle):

implementation 'com.hgweather:java-sdk:1.0.0' // Replace with the latest version

Go

The Go SDK can be fetched using the go get command. It requires Go 1.16 or later.

go get github.com/hgweather/go-sdk

Quickstart example

This section provides a quickstart example using the Python SDK to fetch current weather data for a specified location. Similar patterns apply across other official SDKs, although syntax will vary according to language conventions. Developers should obtain an API key from their HG Weather account to authenticate requests.

Python Quickstart

First, ensure the Python SDK is installed as described in the Installation section. Then, use the following code to fetch current weather data.

import os
from hgweather import HGWeatherClient

# Replace with your actual API key or set as an environment variable
api_key = os.environ.get("HGWEATHER_API_KEY", "YOUR_API_KEY_HERE")

if api_key == "YOUR_API_KEY_HERE":
    print("Warning: Please replace 'YOUR_API_KEY_HERE' with your actual HG Weather API key or set the HGWEATHER_API_KEY environment variable.")

client = HGWeatherClient(api_key)

try:
    # Fetch current weather for London, UK
    location = "London, UK"
    current_weather = client.get_current_weather(location=location)

    print(f"Current weather in {current_weather.location.name}, {current_weather.location.country}:")
    print(f"  Temperature: {current_weather.current.temp_celsius}°C ({current_weather.current.temp_fahrenheit}°F)")
    print(f"  Condition: {current_weather.current.condition.text}")
    print(f"  Humidity: {current_weather.current.humidity}%")
    print(f"  Wind Speed: {current_weather.current.wind_kph} kph ({current_weather.current.wind_mph} mph)")

except Exception as e:
    print(f"An error occurred: {e}")

This example initializes the HGWeatherClient with an API key, then calls the get_current_weather method with a location. The response object contains structured data about the current weather conditions, which can be accessed through its attributes. For more complex queries, such as historical data or forecasts, refer to the official HG Weather documentation.

Community libraries

Beyond the officially supported SDKs, the developer community often creates and maintains client libraries for various programming languages and frameworks. These community-driven projects can offer broader language support, specialized features, or integrations tailored to specific use cases not covered by official offerings. While not directly supported by HG Weather, they can be valuable resources for developers.

Community libraries for APIs, including those for weather data, are typically found on platforms like GitHub, GitLab, or language-specific package repositories (e.g., PyPI for Python, npm for Node.js). Developers interested in using community libraries should evaluate their maintenance status, documentation, and the reputation of their contributors. For example, the open-source community provides a wide array of tools that can interact with various APIs, as described by Mozilla's documentation on web APIs, which highlights the foundational technologies often used by such libraries.

When opting for a community library, it is advisable to:

  • Check for active maintenance: Ensure the library is regularly updated to reflect any API changes or bug fixes.
  • Review documentation: Good documentation is crucial for understanding how to use the library effectively.
  • Examine source code: If possible, review the code for security practices and adherence to API guidelines.
  • Consider licensing: Understand the licensing terms under which the library is distributed.

As of 2026, specific widely-adopted community libraries for HG Weather beyond the official SDKs may emerge or evolve. Developers are encouraged to search public code repositories and developer forums for the latest community contributions. The HG Weather developer documentation may also occasionally link to notable community projects, or developers can typically find them by searching for "HG Weather client" or "HG Weather SDK" on platforms like GitHub.