SDKs overview
Oikolab provides client-side libraries, commonly referred to as Software Development Kits (SDKs), to facilitate interaction with its weather data APIs. These SDKs are designed to simplify the process of fetching historical and forecast weather data, abstracting complexities such as HTTP request construction, authentication, and response parsing. Developers can integrate Oikolab's data into applications built with common programming languages by leveraging these tools, focusing on data utilization rather than integration mechanics.
The Oikolab API offers access to a range of weather variables and geospatial data, suitable for applications spanning academic research, climate modeling, energy forecasting, and agricultural planning. The official SDKs support key programming environments, ensuring broad compatibility for developers. For detailed API specifications, developers can consult the Oikolab API reference documentation.
Official SDKs by language
Oikolab maintains official SDKs for popular programming languages. These libraries are developed and supported by Oikolab to ensure compatibility with the latest API versions and features. The following table provides an overview of the officially supported SDKs:
| Language | Package Name | Installation Command | Maturity |
|---|---|---|---|
| Python | oikolab |
pip install oikolab |
Stable |
| R | oikolab |
install.packages("oikolab") |
Stable |
| JavaScript | @oikolab/api |
npm install @oikolab/api or yarn add @oikolab/api |
Stable |
Each SDK is designed to align with the idiomatic patterns of its respective language, providing a consistent developer experience. For comprehensive usage guides and detailed API methods, refer to the Oikolab official documentation.
Installation
To begin using the Oikolab SDKs, developers must install the relevant package for their chosen programming language. The installation process typically involves using the language's package manager.
Python SDK
The Python SDK can be installed using pip, the standard package installer for Python. Ensure you have Python 3.7 or newer installed. The Python Package Index (PyPI) serves as the repository for Python libraries, as described in the official Python packaging guide.
pip install oikolab
R SDK
The R SDK is available on CRAN (Comprehensive R Archive Network), the primary repository for R packages. Installation is performed using the install.packages() function within the R environment.
install.packages("oikolab")
JavaScript SDK
The JavaScript SDK can be installed via npm (Node Package Manager) or Yarn. These package managers are commonly used in JavaScript development environments for managing project dependencies, as detailed in the npm install documentation.
npm install @oikolab/api
Alternatively, using Yarn:
yarn add @oikolab/api
Quickstart example
The following quickstart examples demonstrate how to retrieve historical weather data using the Oikolab SDKs. Before executing any code, ensure you have an active Oikolab API key, which can be obtained by signing up on the Oikolab website. Replace YOUR_API_KEY with your actual key.
Python Quickstart
This Python example fetches historical temperature data for a specific location and time range.
from oikolab import OikoLab
# Initialize OikoLab client with your API key
api_key = "YOUR_API_KEY" # Replace with your actual Oikolab API key
client = OikoLab(api_key)
# Define query parameters
latitude = 34.0522 # Los Angeles latitude
longitude = -118.2437 # Los Angeles longitude
start_date = "2023-01-01"
end_date = "2023-01-02"
parameters = ["temperature_2m"]
try:
# Fetch historical data
data = client.get_historical_data(
latitude=latitude,
longitude=longitude,
start_date=start_date,
end_date=end_date,
parameters=parameters,
hourly=True # Request hourly data
)
print("Historical Temperature Data (Los Angeles):")
print(data.head())
except Exception as e:
print(f"An error occurred: {e}")
R Quickstart
This R example demonstrates retrieving historical weather data for a specified location and period, focusing on temperature at 2 meters.
# Install and load the oikolab package if not already done
# install.packages("oikolab")
library(oikolab)
# Initialize OikoLab client with your API key
api_key <- "YOUR_API_KEY" # Replace with your actual Oikolab API key
client <- OikoLab$new(api_key)
# Define query parameters
latitude <- 34.0522 # Los Angeles latitude
longitude <- -118.2437 # Los Angeles longitude
start_date <- "2023-01-01"
end_date <- "2023-01-02"
parameters <- c("temperature_2m")
# Fetch historical data
tryCatch({
data <- client$get_historical_data(
latitude=latitude,
longitude=longitude,
start_date=start_date,
end_date=end_date,
parameters=parameters,
hourly=TRUE # Request hourly data
)
print("Historical Temperature Data (Los Angeles):")
print(head(data))
}, error = function(e) {
message(paste("An error occurred:", e$message))
})
JavaScript Quickstart
This JavaScript example illustrates how to fetch historical temperature data for a specific location and time window using the @oikolab/api package.
import { OikoLab } from '@oikolab/api';
// Initialize OikoLab client with your API key
const apiKey = "YOUR_API_KEY"; // Replace with your actual Oikolab API key
const client = new OikoLab(apiKey);
async function fetchWeatherData() {
// Define query parameters
const latitude = 34.0522; // Los Angeles latitude
const longitude = -118.2437; // Los Angeles longitude
const startDate = "2023-01-01";
const endDate = "2023-01-02";
const parameters = ["temperature_2m"];
try {
// Fetch historical data
const data = await client.getHistoricalData({
latitude,
longitude,
startDate,
endDate,
parameters,
hourly: true, // Request hourly data
});
console.log("Historical Temperature Data (Los Angeles):");
console.log(data.slice(0, 5)); // Print first 5 entries
} catch (error) {
console.error(`An error occurred: ${error.message}`);
}
}
fetchWeatherData();
Community libraries
While Oikolab provides official SDKs, the developer community may also contribute third-party libraries or connectors that extend Oikolab's functionality or integrate it with other platforms. These community-driven projects can offer alternative language bindings, specialized data processing tools, or integrations with specific ecosystems.
As of late 2024, Oikolab's primary focus is on maintaining and expanding its official SDKs for Python, R, and JavaScript. Developers interested in contributing to or discovering community-led efforts are encouraged to explore platforms like GitHub, PyPI, CRAN, and npm for unofficial clients or utilities. Always exercise caution and review the source code and documentation of any third-party library before incorporating it into production environments, as these may not carry the same level of support or security guarantees as official SDKs. The official Oikolab documentation remains the definitive source for supported integration methods.