Interface CreateClientParams

Client initialization parameters

interface CreateClientParams {
    accessToken: string;
    adapter?: AxiosAdapter;
    alphaFeatures?: {
        includeContentSourceMaps?: boolean;
    };
    application?: string;
    basePath?: string;
    environment?: string;
    headers?: Record<string, string>;
    host?: string;
    httpAgent?: any;
    httpsAgent?: any;
    includeContentSourceMaps?: boolean;
    insecure?: boolean;
    integration?: string;
    logHandler?: ((level: string, data?: string | Record<string, any>) => void);
    proxy?: false | AxiosProxyConfig;
    requestLogger?: ((request: Error | AxiosRequestConfig<any>) => unknown);
    responseLogger?: ((response: Error | AxiosResponse<any, any>) => unknown);
    retryLimit?: number;
    retryOnError?: boolean;
    space: string;
    timeout?: number;
}

Properties

accessToken: string

Contentful CDA Access Token

adapter?: AxiosAdapter

Optional axios request adapter (see axios docs )

alphaFeatures?: {
    includeContentSourceMaps?: boolean;
}

Enable alpha features.

Type declaration

  • OptionalincludeContentSourceMaps?: boolean

    Use the includeContentSourceMaps option directly instead.

application?: string

Application name and version e.g myApp/version

basePath?: string

Path appended to the host to support gateways/proxies with custom urls

environment?: string

Contentful Environment ID

"master"
headers?: Record<string, string>

Optional additional headers

host?: string

API host. Also usable with preview.contentful.com.

"cdn.contentful.com"
httpAgent?: any

Optional Node.js HTTP agent for proxying (see Node.js docs and https-proxy-agent)

httpsAgent?: any

Optional Node.js HTTP agent for proxying (see Node.js docs and https-proxy-agent)

includeContentSourceMaps?: boolean

Enable Content Source Maps.

This feature is only available when using the Content Preview API.

insecure?: boolean

Requests will be made over http instead of the default https

true
integration?: string

Integration name and version e.g react/version

logHandler?: ((level: string, data?: string | Record<string, any>) => void)

A log handler function to process given log messages and errors. (The default can be found at: https://github.com/contentful/contentful-sdk-core/blob/master/src/create-http-client.ts)

Type declaration

    • (level, data?): void
    • Parameters

      • level: string

        Log level, e.g. error, warning, or info

      • Optionaldata: string | Record<string, any>

        Log data

      Returns void

proxy?: false | AxiosProxyConfig

Optional Axios proxy (see axios docs )

requestLogger?: ((request: Error | AxiosRequestConfig<any>) => unknown)

Interceptor called on every request. Takes Axios request config as an arg.

responseLogger?: ((response: Error | AxiosResponse<any, any>) => unknown)

Interceptor called on every response. Takes Axios response object as an arg.

retryLimit?: number

Optional number of retries before failure.

5
retryOnError?: boolean

If we should retry on errors and 429 rate limit exceptions

true
space: string

Space ID

timeout?: number

connection timeout in milliseconds (default:30000)