• Version 4.3.2
  • Published
  • 67.1 kB
  • 5 dependencies
  • Apache-2.0 license


npm i gaxios
yarn add gaxios
pnpm add gaxios


A simple common HTTP client specifically for Google APIs and services.



variable instance

const instance: Gaxios;
  • The default instance used when the request method is directly invoked.


function request

request: <T>(
opts: GaxiosOptions
) => Promise<import('./common').GaxiosResponse<T>>;
  • Make an HTTP request using the given options.

    Parameter opts

    Options for the request


class Gaxios

class Gaxios {}


    constructor(defaults?: GaxiosOptions);
    • The Gaxios class is responsible for making HTTP requests.

      Parameter defaults

      The default set of options to be used for this instance.

    property agentCache

    protected agentCache: Map<string, any>;

      property defaults

      defaults: GaxiosOptions;
      • Default HTTP options that will be used for every HTTP request.

      method request

      request: <T = any>(opts?: GaxiosOptions) => GaxiosPromise<T>;
      • Perform an HTTP request with the given options.

        Parameter opts

        Set of HTTP options that will be used for this HTTP request.

      class GaxiosError

      class GaxiosError<T = any> extends Error {}


        message: string,
        options: GaxiosOptions,
        response: GaxiosResponse<T>

          property code

          code?: string;

            property config

            config: GaxiosOptions;

              property response

              response?: GaxiosResponse<T>;


                interface GaxiosOptions

                interface GaxiosOptions {}
                • Request options that are used to form the request.

                property adapter

                adapter?: <T = any>(
                options: GaxiosOptions,
                defaultAdapter: (options: GaxiosOptions) => GaxiosPromise<T>
                ) => GaxiosPromise<T>;
                • Optional method to override making the actual HTTP request. Useful for writing tests.

                property agent

                agent?: Agent | ((parsedUrl: URL) => Agent);

                  property baseUrl

                  baseUrl?: string;

                    property baseURL

                    baseURL?: string;

                      property body

                      body?: any;

                        property cert

                        cert?: string;

                          property data

                          data?: any;

                            property fetchImplementation

                            fetchImplementation?: FetchImplementation;
                            • Implementation of fetch to use when making the API call. By default, will use the browser context if available, and fall back to node-fetch in node.js otherwise.

                            property follow

                            follow?: number;

                              property headers

                              headers?: Headers;

                                property key

                                key?: string;

                                  property maxContentLength

                                  maxContentLength?: number;
                                  • The maximum size of the http response content in bytes allowed.

                                  property maxRedirects

                                  maxRedirects?: number;
                                  • The maximum number of redirects to follow. Defaults to 20.

                                  property method

                                  | 'GET'
                                  | 'HEAD'
                                  | 'POST'
                                  | 'DELETE'
                                  | 'PUT'
                                  | 'CONNECT'
                                  | 'OPTIONS'
                                  | 'TRACE'
                                  | 'PATCH';

                                    property onUploadProgress

                                    onUploadProgress?: (progressEvent: any) => void;

                                      property params

                                      params?: any;

                                        property paramsSerializer

                                        paramsSerializer?: (params: { [index: string]: string | number }) => string;

                                          property responseType

                                          responseType?: 'arraybuffer' | 'blob' | 'json' | 'text' | 'stream';

                                            property retry

                                            retry?: boolean;

                                              property retryConfig

                                              retryConfig?: RetryConfig;

                                                property signal

                                                signal?: AbortSignal;

                                                  property size

                                                  size?: number;

                                                    property timeout

                                                    timeout?: number;

                                                      property url

                                                      url?: string;

                                                        property validateStatus

                                                        validateStatus?: (status: number) => boolean;

                                                          interface GaxiosResponse

                                                          interface GaxiosResponse<T = any> {}

                                                            property config

                                                            config: GaxiosOptions;

                                                              property data

                                                              data: T;

                                                                property headers

                                                                headers: Headers;

                                                                  property request

                                                                  request: GaxiosXMLHttpRequest;

                                                                    property status

                                                                    status: number;

                                                                      property statusText

                                                                      statusText: string;

                                                                        interface Headers

                                                                        interface Headers {}

                                                                          index signature

                                                                          [index: string]: any;

                                                                            interface RetryConfig

                                                                            interface RetryConfig {}
                                                                            • Configuration for the Gaxios request method.

                                                                            property currentRetryAttempt

                                                                            currentRetryAttempt?: number;
                                                                            • The number of retries already attempted.

                                                                            property httpMethodsToRetry

                                                                            httpMethodsToRetry?: string[];
                                                                            • The HTTP Methods that will be automatically retried. Defaults to ['GET','PUT','HEAD','OPTIONS','DELETE']

                                                                            property noResponseRetries

                                                                            noResponseRetries?: number;
                                                                            • When there is no response, the number of retries to attempt. Defaults to 2.

                                                                            property onRetryAttempt

                                                                            onRetryAttempt?: (err: GaxiosError) => Promise<void> | void;
                                                                            • Function to invoke when a retry attempt is made.

                                                                            property retry

                                                                            retry?: number;
                                                                            • The number of times to retry the request. Defaults to 3.

                                                                            property retryDelay

                                                                            retryDelay?: number;
                                                                            • The amount of time to initially delay the retry, in ms. Defaults to 100ms.

                                                                            property shouldRetry

                                                                            shouldRetry?: (err: GaxiosError) => Promise<boolean> | boolean;
                                                                            • Function to invoke which determines if you should retry

                                                                            property statusCodesToRetry

                                                                            statusCodesToRetry?: number[][];
                                                                            • The HTTP response status codes that will automatically be retried. Defaults to: [[100, 199], [429, 429], [500, 599]]

                                                                            Type Aliases

                                                                            type GaxiosPromise

                                                                            type GaxiosPromise<T = any> = Promise<GaxiosResponse<T>>;

                                                                              Package Files (3)

                                                                              Dependencies (5)

                                                                              Dev Dependencies (46)

                                                                              Peer Dependencies (0)

                                                                              No peer dependencies.


                                                                              To add a badge like this badgeto your package's README, use the codes available below.

                                                                              You may also use to create a custom badge linking to

                                                                              • Markdown
                                                                              • HTML
                                                                                <a href=""><img src="" alt=""></a>