svg0510/swaggerclient-php

swagger client for weather api

v1.0 2025-01-29 10:21 UTC

This package is auto-updated.

Last update: 2025-02-05 11:31:41 UTC


README

Ceasefire Now

PHP client for WeatherAPI.com

Introduction

WeatherAPI.com provides access to weather and geo data via a JSON/XML restful API. It allows developers to create desktop, web and mobile applications using this data very easy.

We provide following data through our API:

  • Real-time weather
  • 14 day weather forecast
  • Historical Weather
  • Marine Weather and Tide Data
  • Future Weather (Upto 365 days ahead)
  • Daily and hourly intervals
  • 15 min interval (Enterprise only)
  • Astronomy
  • Time zone
  • Location data
  • Sports
  • Search or Autocomplete API
  • Weather Alerts
  • Air Quality Data
  • Bulk Request

Getting Started

You need to signup and then you can find your API key under your account, and start using API right away!

Try our weather API by using interactive API Explorer.

We also have SDK for popular framework/languages available on Github for quick integrations.

If you find any features missing or have any suggestions, please contact us.

Authentication

API access to the data is protected by an API key. If at anytime, you find the API key has become vulnerable, please regenerate the key using Regenerate button next to the API key.

Authentication to the WeatherAPI.com API is provided by passing your API key as request parameter through an API .

key parameter

key=YOUR API KEY

Requirements

PHP 5.5 and later

Installation & Usage

Composer

To install the bindings via Composer, add the following to composer.json:

{
  "repositories": [
    {
      "type": "git",
      "url": "https://github.com//.git"
    }
  ],
  "require": {
    "/": "*@dev"
  }
}

Then run composer install

Manual Installation

Download the files and include autoload.php:

    require_once('/path/to/SwaggerClient-php/vendor/autoload.php');

Tests

To run the unit tests:

composer install
./vendor/bin/phpunit

Getting Started

Please follow the installation procedure and then run the following:

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: ApiKeyAuth
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('key', 'Bearer');

$apiInstance = new Swagger\Client\Api\APIsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$q = "q_example"; // string | Pass US Zipcode, UK Postcode, Canada Postalcode, IP address, Latitude/Longitude (decimal degree) or city name. Visit [request parameter section](https://www.weatherapi.com/docs/#intro-request) to learn more.
$dt = new \DateTime("2013-10-20"); // \DateTime | Date on or after 1st Jan, 2015 in yyyy-MM-dd format

try {
    $result = $apiInstance->astronomy($q, $dt);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling APIsApi->astronomy: ', $e->getMessage(), PHP_EOL;
}

?>

Documentation for API Endpoints

All URIs are relative to https://api.weatherapi.com/v1

Documentation For Models

Documentation For Authorization

ApiKeyAuth

  • Type: API key
  • API key parameter name: key
  • Location: URL query string

Author