apimatic-weather-api-test
TypeScript icon, indicating that this package has built-in type declarations

2.0.4 • Public • Published

Getting Started with Weather API

Getting Started

Introduction

Open weather api with today data

Install the Package

Run the following command from your project directory to install the package from npm:

npm install apimatic-weather-api-test@2.0.4

Initialize the API Client

The following parameters are configurable for the API Client:

Parameter Type Description
timeout number Timeout for API calls.
Default: 0

The API client can be initialized as follows:

const client = new Client({
  timeout: 0,
})

Client Class Documentation

Weather API Client

The gateway for the SDK. This class acts as a factory for the Controllers and also holds the configuration of the SDK.

Controllers

Name Description
aPI Gets ApiController

API Reference

List of APIs

API

Weather

weather

ℹ️ Note This endpoint does not require authentication.

async weather(
  appid: string,
  route: string,
  q?: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<unknown>>
Parameters
Parameter Type Tags Description
appid string Query, Required -
route string Template, Required -
q string | undefined Query, Optional city name
requestOptions RequestOptions | undefined Optional Pass additional request options.
Response Type

unknown

Example Usage
const appid = 'appid6';
const route = '/weather';
try {
  const { result, ...httpResponse } = await apiController.weather(appid, route);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Common Code Documentation

ApiResponse

An interface for the result of an API call.

Properties

Name Type Description
request HttpRequest Original request that resulted in this response.
statusCode number Response status codee.
headers Record<string, string> Response headers.
result T Response data.
body string | Blob | NodeJS.ReadableStream Original body from the response.

ApiError

Thrown when the HTTP status code is not okay.

The ApiError extends the ApiResponse interface, so all ApiResponse properties are available.

Properties

Name Type Description
request HttpRequest Original request that resulted in this response.
statusCode number Response status codee.
headers Record<string, string> Response headers.
result T Response data.
body string | Blob | NodeJS.ReadableStream Original body from the response.

Readme

Keywords

none

Package Sidebar

Install

npm i apimatic-weather-api-test

Weekly Downloads

1

Version

2.0.4

License

MIT

Unpacked Size

12.4 kB

Total Files

14

Last publish

Collaborators

  • mrehanalam