2.0.4 • Published 3 years ago

apimatic-weather-api-test v2.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

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:

ParameterTypeDescription
timeoutnumberTimeout 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

NameDescription
aPIGets ApiController

API Reference

List of APIs

API

Weather

weather

:information_source: Note This endpoint does not require authentication.

async weather(
  appid: string,
  route: string,
  q?: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<unknown>>
Parameters
ParameterTypeTagsDescription
appidstringQuery, Required-
routestringTemplate, Required-
qstring \| undefinedQuery, Optionalcity name
requestOptionsRequestOptions \| undefinedOptionalPass 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

NameTypeDescription
requestHttpRequestOriginal request that resulted in this response.
statusCodenumberResponse status codee.
headersRecord<string, string>Response headers.
resultTResponse data.
bodystring | Blob | NodeJS.ReadableStreamOriginal 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

NameTypeDescription
requestHttpRequestOriginal request that resulted in this response.
statusCodenumberResponse status codee.
headersRecord<string, string>Response headers.
resultTResponse data.
bodystring | Blob | NodeJS.ReadableStreamOriginal body from the response.