///
The SumUp Node.js SDK client is highly configurable, allowing you to tailor its behavior to your specific needs, such as setting authentication credentials, specifying the API host, or providing custo
248 views
~248 views from guests
Guest views are estimated from total page views. These include anonymous visitors and users who weren't logged in when they viewed the page.
The SumUp Node.js SDK client is highly configurable, allowing you to tailor its behavior to your specific needs, such as setting authentication credentials, specifying the API host, or providing custom fetch parameters.
APIConfig TypeThe primary way to configure the SDK client is by passing an APIConfig object to the SumUp constructor. The APIConfig type is defined as follows:
Let's break down each of these properties.
apiKeystringsup_sk_MvxmLOl0...Example: The most basic configuration involves providing your API key:
hoststringhttps://api.sumup.comExample: To use a custom host:
baseParamsType: Core.FetchParams
Purpose: This property allows you to provide an object containing fetch parameters that will be merged into every request made by the SDK client. Core.FetchParams is essentially Omit<RequestInit, "body" | "method">, meaning you can specify properties like headers, signal for aborting requests, cache strategy, etc.
Default Headers: The SDK automatically sets default headers. When baseParams is provided, its headers are merged with these defaults.
Accept: application/jsonContent-Type: application/jsonUser-Agent: sumup-ts/v<SDK_VERSION> (e.g., sumup-ts/v0.0.5)Authorization: Bearer <apiKey> (if apiKey is provided)When merging headers, custom headers provided in baseParams will override the SDK's default headers if they share the same key.
Example:
Adding a custom header to all requests, and setting a global timeout (assuming your fetch polyfill or environment supports it):
baseParams with Request-Specific ParametersWhen you make an individual API call, you can also pass FetchParams as an optional last argument. These request-specific parameters will be merged with the baseParams provided during client instantiation. Request-specific parameters take precedence over baseParams in case of conflicts.
For example, to override X-Custom-Header for a single request:
Here's an example combining all available configuration options:
By understanding and utilizing these configuration options, you can effectively control how the SumUp Node.js SDK interacts with the SumUp API, adapting it to various deployment scenarios and integration requirements.
For more details on getting started, refer to the [Getting Started] page.