Interface IRettiwtConfig

The configuration for initializing a new Rettiwt instance.

interface IRettiwtConfig {
    apiKey?: string;
    delay?: number | () => number | Promise<number>;
    errorHandler?: IErrorHandler;
    headers?: { [key: string]: string };
    logging?: boolean;
    maxRetries?: number;
    proxy?: null | string | AxiosProxyConfig;
    responseMiddleware?: (response: AxiosResponse) => void | Promise<void>;
    timeout?: number;
}

Properties

apiKey?: string

The apiKey (cookie) to use for authenticating Rettiwt against Twitter API.

delay?: number | () => number | Promise<number>

The delay (in ms) to use between concurrent request.

Can either be a number or a function that returns a number synchronously or asynchronously.

errorHandler?: IErrorHandler

Optional custom error handler to define error conditions and process API/HTTP errors in responses.

headers?: { [key: string]: string }

Optional custom HTTP headers to add to all requests to Twitter API.

Custom headers can be useful for proxies, avoiding rate limits, etc.

logging?: boolean

Whether to write logs to console or not.

maxRetries?: number

The maximum number of retries to use.

Recommended to use a value of 5 combined with a delay of 1000 to prevent error 404.

proxy?: null | string | AxiosProxyConfig

The proxy to use.


- If set to anything besides `undefined`, disables Axios' built-in environment variable-set proxy.
// Use custom proxy config via config object
{
proxy: {
host: '127.0.0.1',
port: 8080
}
}

// Use custom proxy config via URL
{
proxy: 'https://127.0.0.1:8080'
}

// Use Axios environment variable for proxy
{
proxy: undefined
}
responseMiddleware?: (response: AxiosResponse) => void | Promise<void>

Optional response middleware to be executed on obtaining a successful response.

Type declaration

    • (response: AxiosResponse): void | Promise<void>
    • Parameters

      • response: AxiosResponse

        The raw AxiosReponse object.

      Returns void | Promise<void>

timeout?: number

The max wait time (in milli-seconds) for a response; if not set, Twitter server timeout is used.