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;
    insecure?: boolean;
    integration?: string;
    logHandler?: ((level, data?) => void);
    proxy?: false | AxiosProxyConfig;
    requestLogger?: ((request) => unknown);
    responseLogger?: ((response) => 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

  • Optional includeContentSourceMaps?: boolean

    Enable Content Source Maps.

    Remarks

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

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

Default Value

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

Optional additional headers

host?: string

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

Default Value

"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)

insecure?: boolean

Requests will be made over http instead of the default https

Default Value

true
integration?: string

Integration name and version e.g react/version

logHandler?: ((level, data?) => 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

      • Optional data: string | Record<string, any>

        Log data

      Returns void

proxy?: false | AxiosProxyConfig

Optional Axios proxy (see axios docs )

requestLogger?: ((request) => unknown)

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

Type declaration

    • (request): unknown
    • Parameters

      • request: Error | AxiosRequestConfig<any>

      Returns unknown

responseLogger?: ((response) => unknown)

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

Type declaration

    • (response): unknown
    • Parameters

      • response: Error | AxiosResponse<any, any>

      Returns unknown

retryLimit?: number

Optional number of retries before failure.

Default Value

5
retryOnError?: boolean

If we should retry on errors and 429 rate limit exceptions

Default Value

true
space: string

Space ID

timeout?: number

connection timeout in milliseconds (default:30000)