Getting started overview

This guide provides a structured approach to initiating development with APIXU, which is now operated under the Weatherstack brand. The process covers account registration, API key retrieval, and executing an initial API request. Understanding these steps is foundational for integrating weather data into applications or services.

APIXU's functionality has been integrated into Weatherstack, maintaining the core offerings of current, historical, and forecast weather data. Developers transitioning from APIXU or new to Weatherstack will follow the same procedures for accessing the API. The API uses a RESTful architecture, typically returning data in JSON format, which is a common data interchange format for web APIs JSON specification. Authentication is managed via a unique API key provided upon account creation.

The following table outlines the key steps to begin using the API:

Step What to do Where
1. Sign Up Create a new account on the Weatherstack platform. Weatherstack signup page
2. Get API Key Locate and copy your unique API access key from your dashboard. Weatherstack dashboard
3. Make First Request Construct and execute a simple API call using your key and a tool like cURL or a browser. Your development environment or browser
4. Explore Docs Review the API documentation for available endpoints and parameters. Weatherstack API documentation

Create an account and get keys

To access the API, you must first create an account on the Weatherstack platform. This process will provision your unique API access key, which is essential for authenticating all your requests.

  1. Navigate to the Weatherstack Signup Page: Open your web browser and go to the Weatherstack signup page. As APIXU was acquired by Weatherstack, all services and sign-ups are now handled through the Weatherstack platform.

  2. Choose a Plan: Weatherstack offers various plans, including a free tier that allows up to 250 requests per month. Select the plan that best fits your initial development needs. The Weatherstack pricing page details the features and request limits for each tier.

  3. Complete Registration: Fill in the required registration details, typically including your email address and a password. After submitting, you may need to verify your email address.

  4. Access Your Dashboard: Once registered and logged in, you will be redirected to your Weatherstack dashboard. Your unique API access key will be prominently displayed on this page. It is critical to keep this key confidential to prevent unauthorized use.

  5. Copy Your API Key: Locate the API access key on your dashboard and copy it. This key will be included as a query parameter in every API request you make.

The API key acts as a unique identifier and authenticator for your application. Similar to how OAuth 2.0 uses tokens for delegated authorization OAuth 2.0 specification, API keys provide a simpler, direct authentication method for accessing specific API resources. Without a valid API key, requests to the API endpoints will be rejected.

Your first request

After obtaining your API access key, you can make your first request to retrieve current weather data. This example uses the current endpoint, which is one of the most common starting points for new users.

The base URL for the API is http://api.weatherstack.com/ for standard HTTP or https://api.weatherstack.com/ for encrypted HTTPS connections. For production environments, HTTPS is recommended to protect data in transit, as outlined in web security best practices Mozilla's secure contexts guide.

Using cURL (Command Line)

cURL is a widely used command-line tool for making HTTP requests. Replace YOUR_ACCESS_KEY with your actual API key and New York with your desired location.


curl "http://api.weatherstack.com/current?access_key=YOUR_ACCESS_KEY&query=New York"

This command sends a GET request to the current endpoint, specifying your API key and the query location.

Using a Web Browser

You can also test your API key directly in a web browser. Simply paste the following URL into your browser's address bar, replacing YOUR_ACCESS_KEY with your key:


http://api.weatherstack.com/current?access_key=YOUR_ACCESS_KEY&query=London

The browser will display the JSON response directly. This method is useful for quick verification of your API key and basic endpoint functionality.

Expected JSON Response

A successful request will return a JSON object similar to this (truncated for brevity):


{
  "request": {
    "type": "City",
    "query": "New York, United States of America",
    "language": "en",
    "unit": "m"
  },
  "current": {
    "observation_time": "04:49 PM",
    "temperature": 13,
    "weather_code": 113,
    "weather_icons": [
      "https://assets.weatherstack.com/images/wsymbols01_png_64/113.png"
    ],
    "weather_descriptions": [
      "Clear"
    ],
    "wind_speed": 0,
    "wind_degree": 349,
    "wind_dir": "N",
    "pressure": 1010,
    "precip": 0,
    "humidity": 62,
    "cloudcover": 0,
    "feelslike": 13,
    "uv_index": 4,
    "visibility": 16
  }
}

This response includes details about the request made and the current weather conditions for the specified location.

Common next steps

After successfully making your first API call, consider these next steps to further integrate and utilize the API:

  • Explore Documentation: Review the comprehensive Weatherstack API documentation to understand all available endpoints (e.g., historical, forecast), parameters, and response structures. This will help you identify the specific data points relevant to your application.

  • Integrate into Your Application: Incorporate the API calls into your chosen programming language or framework. Weatherstack provides examples for various languages including PHP, Python, Node.js, Ruby, and Go, which can be found in their documentation.

  • Handle Errors: Implement robust error handling in your code. The API returns specific error codes and messages for issues like invalid API keys, rate limits, or invalid parameters. Understanding these Weatherstack error codes is crucial for building resilient applications.

  • Manage Rate Limits: Be aware of the rate limits associated with your chosen plan (e.g., 250 requests/month for the Free Plan). Implement caching strategies or request throttling to stay within your allowance and avoid hitting limits, which can result in temporary service unavailability.

  • Consider Security: Always use HTTPS for all API requests, especially in production environments, to encrypt data in transit. Ensure your API key is stored securely and not exposed in client-side code or public repositories.

  • Monitor Usage: Regularly check your Weatherstack dashboard to monitor your API usage and ensure you are not approaching your plan's limits. This helps in planning for potential upgrades or optimizing your request patterns.

Troubleshooting the first call

Encountering issues during your first API call is common. Here are some troubleshooting steps and common problems:

  • Invalid API Key: This is the most frequent issue. Double-check that you have copied your API key correctly from your Weatherstack dashboard. Ensure there are no extra spaces or characters. The API will return an error indicating an invalid or missing access key.

  • Incorrect Endpoint or Parameters: Verify that the endpoint URL (e.g., /current) and query parameters (e.g., query=, access_key=) are spelled correctly and formatted as specified in the Weatherstack API documentation. Missing required parameters or using incorrect parameter names will result in an error.

  • HTTP vs. HTTPS: While the free plan allows HTTP, it's generally recommended to use HTTPS. If you're using HTTPS and encountering issues, ensure your environment supports SSL/TLS connections correctly. Conversely, if you're on a plan that only permits HTTP and you're trying HTTPS, it might fail.

  • Network Connectivity: Confirm that your machine has an active internet connection and can reach api.weatherstack.com. Network firewalls or proxies might block outgoing requests. You can test basic connectivity using ping api.weatherstack.com from your terminal.

  • Rate Limit Exceeded: If you've made too many requests within a short period, or if you're on the free tier and have exceeded 250 requests for the month, the API will return a rate limit error. Check your dashboard for current usage. Wait for the rate limit to reset, or consider upgrading your plan.

  • Response Format: Ensure your client or browser can correctly interpret JSON responses. Most modern browsers and programming language HTTP libraries handle JSON parsing automatically. If you see raw text or an error, it might be a parsing issue.

  • Location Query Issues: The query parameter accepts various formats (city name, IP address, latitude/longitude). If a location is not found, the API may return an error. Try a simpler or more common location name to rule out specific location parsing issues.