diff --git a/src/lib/BaseRestClient.ts b/src/lib/BaseRestClient.ts index e4b7367..58af6c2 100644 --- a/src/lib/BaseRestClient.ts +++ b/src/lib/BaseRestClient.ts @@ -149,6 +149,15 @@ export abstract class BaseRestClient { }, }; + if (restClientOptions.localisation) { + if (!this.globalRequestOptions.headers) { + this.globalRequestOptions.headers = {}; + } + + this.globalRequestOptions.headers['Accept-Language'] = + restClientOptions.localisation; + } + // If enabled, configure a https agent with keepAlive enabled if (this.options.keepAlive) { // For more advanced configuration, raise an issue on GitHub or use the "networkOptions" diff --git a/src/lib/requestUtils.ts b/src/lib/requestUtils.ts index 6feded7..53eba69 100644 --- a/src/lib/requestUtils.ts +++ b/src/lib/requestUtils.ts @@ -44,6 +44,26 @@ export interface RestClientOptions { privateKey: string; }; + /** + * https://docs.cdp.coinbase.com/coinbase-app/docs/localization + * + * The Coinbase App API supports localization for error messages and other strings. + * Localization is defined in each request with Accept-Language header. + * + * Accepted values are currently as below. Note: this may not work for all coinbase product groups. + */ + localisation?: + | 'de' + | 'en' + | 'es' + | 'es-mx' + | 'fr' + | 'id' + | 'it' + | 'nl' + | 'pt' + | 'pt-br'; + /** * Enable keep alive for REST API requests (via axios). * See: https://github.com/tiagosiebler/bybit-api/issues/368