bx-rest 0.23.0 β†’ 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.en.md ADDED
@@ -0,0 +1,578 @@
1
+ πŸ‡·πŸ‡Ί [Русский](README.md) | πŸ‡¬πŸ‡§ **English**
2
+
3
+ # bx-rest - Bitrix24 REST API client for TypeScript, Angular, Vue and React
4
+
5
+ [![npm version](https://img.shields.io/npm/v/bx-rest.svg)](https://www.npmjs.com/package/bx-rest)
6
+ [![npm downloads](https://img.shields.io/npm/dm/bx-rest.svg)](https://www.npmjs.com/package/bx-rest)
7
+ [![license](https://img.shields.io/npm/l/bx-rest.svg)](https://github.com/Aricatofuka/bx-rest/blob/main/LICENSE)
8
+
9
+ `bx-rest` is a TypeScript SDK for the Bitrix24 REST API. It helps call BX24 REST methods, work with auth tokens, sessid, OAuth2, pagination, mappers and typed API requests.
10
+
11
+ Also known as: Bitrix24 REST client, BX24 REST SDK, Bitrix24 API client, Bitrix REST TypeScript library.
12
+
13
+ ## Contents
14
+
15
+ - [Install](#install)
16
+ - [Requirements](#requirements)
17
+ - [Quick Start](#quick-start)
18
+ - [Result modes](#result-modes)
19
+ - [Authentication and OAuth2](#authentication-and-oauth2)
20
+ - [Error handling](#error-handling)
21
+ - [Usage in Angular](#usage-in-angular)
22
+ - [SessionKeyServices](#sessionkeyservices)
23
+ - [Usage in Vue](#usage-in-vue)
24
+ - [Usage in React](#usage-in-react)
25
+ - [Custom REST methods](#custom-rest-methods)
26
+ - [Mapper](#mapper)
27
+ - [A custom method with `simple()`](#a-custom-method-with-simple)
28
+ - [A paginated custom method with `pagNav()`](#a-paginated-custom-method-with-pagnav)
29
+ - [Specific methods](#specific-methods)
30
+ - [`tasks.task.list`](#taskstasklist)
31
+ - [Date parsing](#date-parsing)
32
+ - [Future features](#future-features)
33
+ - [License](#license)
34
+
35
+ ## Install
36
+
37
+ ```shell
38
+ npm install bx-rest
39
+ ```
40
+
41
+ ## Requirements
42
+
43
+ - **Module format:** `bx-rest` ships ES modules only β€” there is no CommonJS/`require` build. Use it from an ESM-aware bundler (Angular CLI, Vite, webpack 5+, Next.js, ...) or a native `import()`. Plain `require('bx-rest')` (older Jest configs without ESM support, `ts-node` in CJS mode, etc.) will not resolve the package.
44
+ - **TypeScript:** developed against TypeScript 5.5+. `strict` mode is recommended β€” the bundled typification relies on it to give accurate field types.
45
+ - **RxJS:** `rxjs` (^7.8) is a regular dependency bundled with the package, not a `peerDependency`, so no specific host version is enforced. Every REST call returns an RxJS `Observable`.
46
+ - **Frameworks:** the Angular, Vue and React examples below are written against Angular 18/19, Vue 3 and React 18+ APIs (the versions this library is built and tested with). None of these frameworks are declared as `peerDependencies` β€” `bx-rest` has no hard dependency on any of them β€” but the DI/composition patterns shown assume those major versions.
47
+ - **Environment:** `bx-rest` is browser-oriented. The `cookies`/`localStorage`/`sessid` auth sources and `SessionKeyServices` read `window`, `document` and `localStorage` directly. In a server-side-rendered app (Angular Universal, Next.js, etc.) only exercise those code paths in the browser (e.g. behind `isPlatformBrowser`/`typeof window !== 'undefined'` guards), or use an auth source that doesn't touch browser globals, such as `source: () => accessToken` or `source: 'off'`.
48
+
49
+ ## Quick Start
50
+
51
+ Configure the portal URL and an access-token source once, then create a client and subscribe to the returned RxJS `Observable`. Use a complete URL including `https://`.
52
+
53
+ ```typescript
54
+ import { firstValueFrom } from 'rxjs'
55
+ import { BXRestNavvy, BXRestSettings } from 'bx-rest'
56
+
57
+ const accessToken = 'YOUR_ACCESS_TOKEN'
58
+
59
+ BXRestSettings.update({
60
+ auth: {
61
+ source: () => accessToken,
62
+ key: 'auth'
63
+ },
64
+ urls: {
65
+ source: 'string',
66
+ key: 'https://example.bitrix24.com',
67
+ additional_part: 'rest'
68
+ }
69
+ })
70
+
71
+ const bxRest = new BXRestNavvy()
72
+
73
+ const deals = await firstValueFrom(
74
+ bxRest.crm.deal.list({
75
+ select: ['ID', 'TITLE'],
76
+ filter: {},
77
+ start: 0
78
+ }).res()
79
+ )
80
+
81
+ console.log(deals)
82
+ ```
83
+
84
+ Do not hardcode or commit a production access token. Pass it from your application's authorization flow, server response or secure runtime configuration.
85
+
86
+ ### Result modes
87
+
88
+ REST calls are lazy: the request starts when the returned `Observable` is subscribed to or passed to `firstValueFrom`.
89
+
90
+ | Method | Result |
91
+ | --- | --- |
92
+ | `.res(options?)` | Unwraps the Bitrix response and applies the configured mapper. For paginated methods it returns the current page. |
93
+ | `.resAll()` | Loads and combines every page. Available on paginated Navvy helpers. |
94
+ | `.resVanilla()` | Returns the raw Bitrix response, including fields such as `result`, `total` and `next`. |
95
+ | `.mapForVanilla()` | Keeps the raw response envelope but applies the mapper to its `result`. |
96
+
97
+ `.res()` accepts an optional options object:
98
+
99
+ | Option | Default | Effect |
100
+ | --- | --- | --- |
101
+ | `throwOnApiError` | `false` | When `true`, a Bitrix-level API error makes the returned `Observable` error out with a `BXRestApiError` instead of resolving with `undefined`. See [Error handling](#error-handling). |
102
+
103
+ ## Authentication and OAuth2
104
+
105
+ `auth.source` controls where credentials are read from. `auth.key` controls the request parameter name, except for the special `OAuth2` cookie-credentials mode.
106
+
107
+ | Scenario | `auth.source` | `auth.key` | Behaviour |
108
+ | --- | --- | --- | --- |
109
+ | Access token from application state | `() => accessToken` | `auth` | Calls the function before each request and sends its value in the `auth` parameter. Recommended for OAuth2 access tokens managed by the application. |
110
+ | Access token in local storage | `localStorage` | `auth` | Reads `localStorage["auth"]` and sends it as `auth`. |
111
+ | Access token in a cookie | `cookies` | `auth` | Reads the `auth` cookie and sends it as `auth`. |
112
+ | Embedded Bitrix page / local session | `cookies` | `sessid` | Tries `window.BX.bitrix_sessid()`, the `sessid` query parameter, `localStorage.sessid`, then the `auth` cookie. Sends the resolved value as `sessid`. |
113
+ | Incoming webhook or URL that already contains authorization | `off` | Any value | Skips credential lookup and does not add an authorization parameter. |
114
+ | Cookie-based credential request | Any source returning a non-empty value | `OAuth2` | Does not append the resolved value to request params and enables Axios `withCredentials`. Use only when the portal and CORS policy support credential cookies. |
115
+
116
+ For a regular Bitrix OAuth2 `access_token`, use `auth.key: 'auth'` and provide the current token through a function or `localStorage`. The special `auth.key: 'OAuth2'` mode is for credential cookies; it does not send an OAuth access token by itself.
117
+
118
+ For an incoming webhook URL, keep the full webhook path in `urls.key`, set `additional_part` to an empty string and disable additional authorization:
119
+
120
+ ```typescript
121
+ BXRestSettings.update({
122
+ auth: {
123
+ source: 'off',
124
+ key: 'auth'
125
+ },
126
+ urls: {
127
+ source: 'string',
128
+ key: 'https://example.bitrix24.com/rest/1/WEBHOOK_CODE',
129
+ additional_part: ''
130
+ }
131
+ })
132
+ ```
133
+
134
+ ## Error handling
135
+
136
+ `bx-rest` surfaces two different kinds of failure, and `.res()` only reacts to one of them.
137
+
138
+ | Failure | When it happens | How it surfaces on `.res()` |
139
+ | --- | --- | --- |
140
+ | Transport / configuration errors β€” network failure, missing auth, missing base URL | Before or during the HTTP call | The returned `Observable` errors. Handle it with RxJS `catchError` or the `error` callback of `subscribe()`. |
141
+ | Bitrix API errors β€” `{ error, error_description }`, e.g. `INSUFFICIENT_SCOPE`, `expired_token` | HTTP 200 response whose body is not a success payload | By default, `.res()` resolves normally with `undefined` β€” **it does not throw**. Pass `{ throwOnApiError: true }` to make it throw a `BXRestApiError` instead. |
142
+
143
+ Because a Bitrix-level error resolves as `undefined` rather than as an `Observable` error by default, don't rely on plain `.res()` alone to tell "no records" apart from "the call failed". You have two options.
144
+
145
+ **Option 1 β€” opt in to throwing with `.res({ throwOnApiError: true })`.** The `Observable` errors with a `BXRestApiError`, exposing `error` and `error_description`, so it can be handled alongside transport errors in a single `catchError`/`error` callback:
146
+
147
+ ```typescript
148
+ import { BXRestNavvy, BXRestApiError } from 'bx-rest'
149
+
150
+ const bxRest = new BXRestNavvy()
151
+
152
+ bxRest.crm.deal.list({
153
+ select: ['ID', 'TITLE'],
154
+ filter: {},
155
+ start: 0
156
+ }).res({ throwOnApiError: true }).subscribe({
157
+ next: deals => console.log(deals),
158
+ error: err => {
159
+ if (err instanceof BXRestApiError) {
160
+ console.error('Bitrix API error:', err.error, err.error_description)
161
+ } else {
162
+ console.error('Request failed:', err.message)
163
+ }
164
+ }
165
+ })
166
+ ```
167
+
168
+ **Option 2 β€” keep the default and check the raw response.** Call `.resVanilla()` instead and check the response with the exported `isBXRestAnswerSuccess()` type guard:
169
+
170
+ ```typescript
171
+ import { firstValueFrom } from 'rxjs'
172
+ import { BXRestNavvy, isBXRestAnswerSuccess } from 'bx-rest'
173
+
174
+ const bxRest = new BXRestNavvy()
175
+
176
+ const answer = await firstValueFrom(
177
+ bxRest.crm.deal.list({
178
+ select: ['ID', 'TITLE'],
179
+ filter: {},
180
+ start: 0
181
+ }).resVanilla()
182
+ )
183
+
184
+ if (!answer || !isBXRestAnswerSuccess(answer)) {
185
+ console.error('Bitrix API error:', answer?.error, answer?.error_description)
186
+ } else {
187
+ console.log(answer.result)
188
+ }
189
+ ```
190
+
191
+ Regardless of `throwOnApiError`, transport-level failures always propagate as `Observable` errors and can be caught the usual RxJS way:
192
+
193
+ ```typescript
194
+ bxRest.crm.deal.list({
195
+ select: ['ID', 'TITLE'],
196
+ filter: {},
197
+ start: 0
198
+ }).res().subscribe({
199
+ next: deals => console.log(deals),
200
+ error: err => console.error('Request failed:', err.message)
201
+ })
202
+ ```
203
+
204
+ ## Usage in Angular
205
+
206
+ Register the public clients and `Navvy` when you want to inject them into Angular services or components:
207
+
208
+ ```typescript
209
+ import { ApplicationConfig, Provider } from '@angular/core'
210
+ import {
211
+ BXRestMap,
212
+ BXRestNavvy,
213
+ BXRestRequest,
214
+ Navvy
215
+ } from 'bx-rest'
216
+
217
+ export const BXRestNavvyProvider: Provider = {
218
+ provide: BXRestNavvy,
219
+ useFactory: () => new BXRestNavvy()
220
+ }
221
+
222
+ export const BXRestMapProvider: Provider = {
223
+ provide: BXRestMap,
224
+ useFactory: () => new BXRestMap()
225
+ }
226
+
227
+ export const BXRestRequestProvider: Provider = {
228
+ provide: BXRestRequest,
229
+ useFactory: () => new BXRestRequest()
230
+ }
231
+
232
+ export const NavvyProvider: Provider = {
233
+ provide: Navvy,
234
+ useFactory: () => new Navvy()
235
+ }
236
+
237
+ export const appConfig: ApplicationConfig = {
238
+ providers: [
239
+ BXRestNavvyProvider,
240
+ BXRestMapProvider,
241
+ BXRestRequestProvider,
242
+ NavvyProvider
243
+ ]
244
+ }
245
+ ```
246
+
247
+ Example component:
248
+
249
+ ```typescript
250
+ import { Component, inject } from '@angular/core'
251
+ import { BXRestNavvy } from 'bx-rest'
252
+
253
+ @Component({
254
+ selector: 'app-list',
255
+ template: ''
256
+ })
257
+ export class ListComponent {
258
+ private readonly bxRest = inject(BXRestNavvy)
259
+
260
+ readonly listElements$ = this.bxRest.lists.element.get({
261
+ IBLOCK_TYPE_ID: 'lists',
262
+ IBLOCK_ID: 150,
263
+ FILTER: {
264
+ '>ID': 0
265
+ }
266
+ }).res()
267
+ }
268
+ ```
269
+
270
+ ## SessionKeyServices
271
+
272
+ `SessionKeyServices` is available from the public API and can be used when you need to inspect the current authorization data before making REST requests.
273
+
274
+ ```typescript
275
+ import { BXRestSettings, SessionKeyServices, SessionKeyError } from 'bx-rest'
276
+
277
+ BXRestSettings.update({
278
+ auth: {
279
+ source: 'cookies',
280
+ key: 'auth'
281
+ },
282
+ urls: {
283
+ source: 'string',
284
+ key: 'https://example.bitrix24.com',
285
+ additional_part: 'rest'
286
+ }
287
+ })
288
+
289
+ const session = new SessionKeyServices()
290
+
291
+ const auth = session.getAuthParams()
292
+ const authKey = session.getKeyAuth()
293
+
294
+ if (!auth && session.getCheckAuthParamsIsOn()) {
295
+ const error = session.getAuthError('manual auth check')
296
+ if (error instanceof SessionKeyError) {
297
+ console.error(error.message)
298
+ }
299
+ throw error
300
+ }
301
+
302
+ session.getBaseUrl().subscribe((baseUrl) => {
303
+ if (!baseUrl) {
304
+ throw session.getBaseUrlError('manual base url check')
305
+ }
306
+
307
+ console.log({ authKey, auth, baseUrl })
308
+ })
309
+ ```
310
+
311
+ ## Usage in Vue
312
+
313
+ ```typescript
314
+ import type { Plugin } from 'vue'
315
+ import { BXRestSettings, BXRestMap, BXRestNavvy, BXRestRequest } from 'bx-rest'
316
+
317
+ const bxRestPlugin: Plugin = {
318
+ install(app) {
319
+ BXRestSettings.update({
320
+ auth: {
321
+ source: 'cookies',
322
+ key: 'auth'
323
+ },
324
+ urls: {
325
+ source: 'string',
326
+ key: 'https://example.bitrix24.com',
327
+ additional_part: 'rest'
328
+ }
329
+ })
330
+
331
+ app.config.globalProperties.$bxRestNavvy = new BXRestNavvy()
332
+ app.config.globalProperties.$bxRestMap = new BXRestMap()
333
+ app.config.globalProperties.$bxRestRequest = new BXRestRequest()
334
+ }
335
+ }
336
+
337
+ export default bxRestPlugin
338
+ ```
339
+
340
+ ```vue
341
+ import './assets/main.css'
342
+
343
+ import { createApp } from 'vue'
344
+ import App from './App.vue'
345
+ import bxRestPlugin from './bxRestPlugin'
346
+
347
+ const app = createApp(App)
348
+
349
+ app.use(bxRestPlugin)
350
+
351
+ app.mount('#app')
352
+ ```
353
+
354
+ ## Usage in React
355
+
356
+ Create the client outside the component and unsubscribe when the component is unmounted:
357
+
358
+ ```tsx
359
+ import { useEffect, useState } from 'react'
360
+ import { BXRestNavvy } from 'bx-rest'
361
+
362
+ const bxRest = new BXRestNavvy()
363
+
364
+ export function Deals() {
365
+ const [deals, setDeals] = useState<unknown[]>([])
366
+
367
+ useEffect(() => {
368
+ const subscription = bxRest.crm.deal.list({
369
+ select: ['ID', 'TITLE'],
370
+ filter: {},
371
+ start: 0
372
+ }).res().subscribe({
373
+ next: value => setDeals(value ?? []),
374
+ error: error => console.error(error)
375
+ })
376
+
377
+ return () => subscription.unsubscribe()
378
+ }, [])
379
+
380
+ return <pre>{JSON.stringify(deals, null, 2)}</pre>
381
+ }
382
+ ```
383
+
384
+ ## Custom REST methods
385
+
386
+ `Navvy` is exported from `bx-rest`. In Angular, register the `NavvyProvider` shown above and inject `Navvy` into your custom API service. A method URL is represented as an array and is joined with dots before the request is sent.
387
+
388
+ See the [Bitrix24 documentation](https://dev.1c-bitrix.ru/learning/course/index.php?COURSE_ID=99&LESSON_ID=7985) for registering custom REST methods.
389
+
390
+ ### Mapper
391
+
392
+ A mapper is a regular function. It does not need to extend `BXRestMap`.
393
+
394
+ ```typescript
395
+ import {
396
+ iBXRestCustomBlogGet,
397
+ iBXRestCustomBlogGetHttp
398
+ } from '../type/blog'
399
+
400
+ export class BXCustomBlogMap {
401
+ static get(
402
+ value: iBXRestCustomBlogGetHttp[] | undefined
403
+ ): iBXRestCustomBlogGet[] {
404
+ return (value ?? []).map(item => ({
405
+ id: Number(item.ID),
406
+ title: item.TITLE
407
+ }))
408
+ }
409
+ }
410
+ ```
411
+
412
+ ### A custom method with `simple()`
413
+
414
+ Use `simple()` when the method returns one response without automatic pagination:
415
+
416
+ ```typescript
417
+ import { inject, Injectable } from '@angular/core'
418
+ import { Navvy, partNameMethods as PNM } from 'bx-rest'
419
+ import { BXCustomBlogMap } from '../map/blog'
420
+ import {
421
+ iBXRestCustomBlogGet,
422
+ iBXRestCustomBlogGetHttp,
423
+ iBXRestCustomParamBlogGet
424
+ } from '../type/blog'
425
+
426
+ @Injectable({
427
+ providedIn: 'root'
428
+ })
429
+ export class BXRestNavvyCustomApiBlog {
430
+ private readonly url = {
431
+ get: ['blog', PNM.$get]
432
+ }
433
+
434
+ private readonly navvy = inject(Navvy)
435
+
436
+ get(param: iBXRestCustomParamBlogGet) {
437
+ return this.navvy.simple<
438
+ iBXRestCustomBlogGetHttp[],
439
+ iBXRestCustomBlogGet[],
440
+ iBXRestCustomParamBlogGet
441
+ >(
442
+ this.url.get,
443
+ param,
444
+ BXCustomBlogMap.get
445
+ )
446
+ }
447
+ }
448
+ ```
449
+
450
+ The returned helper supports `.res()`, `.resVanilla()` and `.mapForVanilla()`.
451
+
452
+ ### A paginated custom method with `pagNav()`
453
+
454
+ Use `pagNav()` when the Bitrix response contains an array and standard `start`, `next` and `total` pagination fields. The parameter type must support `start?: number`.
455
+
456
+ ```typescript
457
+ import { inject, Injectable } from '@angular/core'
458
+ import { Navvy, partNameMethods as PNM } from 'bx-rest'
459
+ import type { iBXRestPagination } from 'bx-rest/typification/base'
460
+ import { BXCustomBlogMap } from '../map/blog'
461
+ import {
462
+ iBXRestCustomBlogGet,
463
+ iBXRestCustomBlogGetHttp
464
+ } from '../type/blog'
465
+
466
+ export interface iBXRestCustomParamBlogList extends iBXRestPagination {
467
+ filter?: Record<string, unknown>
468
+ }
469
+
470
+ @Injectable({
471
+ providedIn: 'root'
472
+ })
473
+ export class BXRestNavvyCustomApiBlogList {
474
+ private readonly url = {
475
+ list: ['blog', PNM.$list]
476
+ }
477
+
478
+ private readonly navvy = inject(Navvy)
479
+
480
+ list(param: iBXRestCustomParamBlogList) {
481
+ return this.navvy.pagNav<
482
+ iBXRestCustomBlogGetHttp,
483
+ iBXRestCustomBlogGet,
484
+ iBXRestCustomParamBlogList
485
+ >(
486
+ this.url.list,
487
+ param,
488
+ BXCustomBlogMap.get
489
+ )
490
+ }
491
+ }
492
+ ```
493
+
494
+ The returned helper additionally supports `.resAll()` for loading and combining all pages.
495
+
496
+ ## Specific methods
497
+
498
+ ### `tasks.task.list`
499
+
500
+ The first generic argument selects built-in task fields. The second adds project-specific user fields:
501
+
502
+ ```typescript
503
+ import { BXRestNavvy } from 'bx-rest'
504
+ import type { iBXRestTaskFieldsName } from 'bx-rest/typification/tasks'
505
+
506
+ type SelectedTaskField = Extract<
507
+ iBXRestTaskFieldsName,
508
+ 'ID' | 'TITLE' | 'GROUP_ID' | 'TIME_ESTIMATE' | 'CREATED_DATE' | 'CLOSED_DATE' | 'DURATION_FACT' | 'TIME_SPENT_IN_LOGS'
509
+ >
510
+
511
+ type CustomTaskFields = {
512
+ ufListDiscipline: string
513
+ ufListSubdiscipline: string
514
+ ufList1: string
515
+ }
516
+
517
+ const selectedTaskFields: SelectedTaskField[] = [
518
+ 'ID',
519
+ 'TITLE',
520
+ 'GROUP_ID',
521
+ 'CREATED_DATE'
522
+ ]
523
+
524
+ const selectedCustomFields = [
525
+ 'UF_LIST_DISCIPLINE',
526
+ 'UF_LIST_SUBDISCIPLINE',
527
+ 'UF_LIST_1'
528
+ ] as const
529
+
530
+ const bxRest = new BXRestNavvy()
531
+
532
+ const tasks$ = bxRest.tasks.task.list<
533
+ SelectedTaskField[],
534
+ CustomTaskFields
535
+ >({
536
+ order: {
537
+ ID: 'DESC'
538
+ },
539
+ filter: {
540
+ CREATED_BY: [1]
541
+ },
542
+ select: [...selectedTaskFields, ...selectedCustomFields],
543
+ start: 0
544
+ }).res()
545
+ ```
546
+
547
+ ## Date parsing
548
+
549
+ Some Bitrix24 REST fields (notably `calendar.section.get`, `calendar.event.get` and `crm.calllist.*`) return dates as plain strings formatted according to the portal's own date/time settings (Settings β†’ date and time format) β€” not a fixed ISO format. Because that format is a per-portal setting, `bx-rest` can't know it in advance, so `BXBaseServices.toDate()` (used internally by these mappers) resolves an ambiguous string in three steps, in order:
550
+
551
+ 1. **The format you asked for.** If you (or a mapper) pass an explicit `format` (e.g. `'dd.MM.yyyy HH:mm:ss'`), it's tried first, token by token (`yyyy`, `MM`, `dd`, `HH`, `mm`, `ss`, and their single-letter variants) with the literal separators from the format string.
552
+ 2. **A short list of known Bitrix24 formats** (`'dd.MM.yyyy HH:mm:ss'`, `'yyyy-MM-dd HH:mm:ss'`, `'dd.MM.yyyy'`, `'yyyy-MM-dd'`) β€” tried if step 1 didn't match, since different portals commonly send one of these.
553
+ 3. **A positional heuristic**, as a last resort β€” it locates the year by its unambiguous 4-digit length (whichever end of the date it's on), treats the middle segment as the month (true for both ISO and European-style dates) and reads any separator (`.`, `-`, `/`, space...). It does **not** guess in the one case that's genuinely ambiguous β€” a purely numeric `MM/dd` vs `dd/MM` order where both segments are ≀ 12 β€” and it validates ranges (month 1-12, day 1-31, hour/minute/second) rather than letting `Date` silently roll over an out-of-range value into the next month/year.
554
+
555
+ If you already know your portal's exact format, pass it explicitly instead of relying on auto-detection β€” it's always tried first and skips steps 2-3 entirely. The calendar and call-list mappers accept it as a single optional trailing `dateTimeFormat` argument, and it flows through the corresponding `BXRestNavvy` methods too. Where a mapper also has date-only fields (`calendar.event`'s `EXDATE`/`RRULE.UNTIL`), their format is derived from `dateTimeFormat` by dropping `HH:mm:ss` β€” day/month/year order is always the same for both on a given portal, so there's nothing extra to pass:
556
+
557
+ ```typescript
558
+ import { BXRestNavvy } from 'bx-rest'
559
+
560
+ const bxRest = new BXRestNavvy()
561
+
562
+ // Portal-specific date/time format, e.g. from Settings β†’ date and time format.
563
+ const dateTimeFormat = 'yyyy-MM-dd HH:mm:ss'
564
+
565
+ bxRest.calendar.event.get({ FROM: '01.01.2026', TO: '31.01.2026' }, dateTimeFormat).res()
566
+ bxRest.calendar.section.get({}, dateTimeFormat).res()
567
+ bxRest.crm.callList.get({ ID: 1 }, dateTimeFormat).res()
568
+ ```
569
+
570
+ ## Future features
571
+ - Auto get token
572
+ - Mappers for normalization types
573
+
574
+ Have a feature request or found a bug? Check [existing issues](https://github.com/Aricatofuka/bx-rest/issues) or open a new one.
575
+
576
+ ## License
577
+
578
+ [MIT](https://github.com/Aricatofuka/bx-rest/blob/main/LICENSE) Β© Aricatofuka