# Additional methods

This article describes the additional methods in the [Datafeed API](https://charting-library-docs.xstaging.tv/latest/connecting_data/datafeed-api.md).
With methods, you can enable additional features such as marks and a countdown to the bar close.

## searchSymbolsPaginated

The library calls the [`searchSymbolsPaginated`] method to request symbols in pages (batches) as the user scrolls.
When implemented, this method is used instead of [`searchSymbols`].

The method receives an `options` object containing the search criteria (such as symbol type and exchange) and pagination details.
Pass the resulting array of symbols as a parameter to the `onResult` callback.

```javascript
searchSymbolsPaginated: async (
    options,
    onResult,
) => {
    console.log('[searchSymbolsPaginated]: Method call', options);
    // options object contains: userInput, exchange, symbolType, limit, etc.
    const symbols = await getMatchingSymbolsFromBackend(options);
    onResult(symbols);
}
```

As a result, the library gets an array of [`SearchSymbolResultItem`] objects that have the following format:

```javascript
[
    {
        "symbol": "<short symbol name>",
        "description": "<symbol description>",
        "exchange": "<symbol exchange name>",
        "ticker": "<symbol ticker name>",
        "type": "stock" // "futures"/"crypto"/"forex"/"index"
    },
    {
        //...
    }
]
```

## getMarks

The library calls [`getMarks`](../../api/interfaces/Charting_Library.IDatafeedChartApi.md#getmarks) to request [marks](https://charting-library-docs.xstaging.tv/latest/ui_elements/Marks.md#marks-on-the-chart) for the visible bar range. The library assumes that you call [`GetMarksCallback`](../../api/modules/Datafeed.md#getmarkscallback) once per `getMarks` call. Pass an array of [`Mark`](../../api/interfaces/Charting_Library.Mark.md) objects as a callback parameter.

Only ten marks can be attached to a bar. The time of each mark must match the time of a bar. For example, if the bar times are `2023-01-01`, `2023-01-08`, and `2023-01-15`, then a mark cannot have the time `2023-01-05`.

:::caution

This method is called only if your datafeed [supports marks](https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.DatafeedConfiguration#supports_marks).

:::

By default, the mark's pop-up tooltip displays the plain text string from the [`text`](../../api/interfaces/Charting_Library.Mark.md#text) property. In [Trading Platform](https://charting-library-docs.xstaging.tv/latest/trading_terminal.md), you can render fully custom tooltip content with your own web component by providing the [`customTooltip`](../../api/interfaces/Charting_Library.Mark.md#customtooltip) property. Refer to the [Customize mark tooltips](https://charting-library-docs.xstaging.tv/latest/tutorials/how-to-guides/customize-mark-tooltips.md) guide for more information.

The code sample below demonstrates the example of `getMarks` implementation:

```js
getMarks = (symbolInfo, startDate, endDate, onDataCallback, resolution) => {
    console.log('getMarks');

    onDataCallback(
        [
            {
                id: 1,
                time: endDate,
                color: 'red',
                text: ['This is the mark pop-up text.'],
                label: 'M',
                labelFontColor: 'blue',
                minSize: 25
            },
            {
                id: 2,
                time: endDate + 5260000, // 2 months
                color: 'red',
                text: ['Second marker'],
                label: 'S',
                labelFontColor: 'green',
                minSize: 25
            }
        ]);
};
```

## getTimescaleMarks

The library calls [`getTimescaleMarks`](../../api/interfaces/Charting_Library.IDatafeedChartApi.md#gettimescalemarks) to request [timescale marks](https://charting-library-docs.xstaging.tv/latest/ui_elements/Marks.md#marks-on-the-time-scale) for the visible bar range. The library assumes that you call [`GetMarksCallback`](../../api/modules/Datafeed.md#getmarkscallback) once per `getTimescaleMarks` call. Pass an array of [`TimescaleMark`](../../api/interfaces/Charting_Library.TimescaleMark.md) objects as a callback parameter.

:::caution

These method is called only if your datafeed [supports marks](https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.DatafeedConfiguration#supports_marks).

:::

By default, the mark's pop-up tooltip displays the plain text strings from the [`tooltip`](../../api/interfaces/Charting_Library.TimescaleMark.md#tooltip) property. In [Trading Platform](https://charting-library-docs.xstaging.tv/latest/trading_terminal.md), you can render fully custom tooltip content with your own web component by providing the [`customTooltip`](../../api/interfaces/Charting_Library.TimescaleMark.md#customtooltip) property. Refer to the [Customize mark tooltips](https://charting-library-docs.xstaging.tv/latest/tutorials/how-to-guides/customize-mark-tooltips.md) guide for more information.

The code sample below demonstrates the example of `getTimescaleMarks` implementation:

```js
getTimescaleMarks = (
    symbolInfo,
    startDate,
    endDate,
    onDataCallback,
    resolution
) => {
    // optional
    console.log('getTimescaleMarks');

    let marks = [];

    if (symbolInfo.name === 'AAPL') {
        marks = [
            {
                id: 1,
                time: startDate,
                color: 'red',
                label: 'Aa',
                minSize: 30,
                tooltip: [
                    'Lorem',
                    'Ipsum',
                    'Dolor',
                    'Sit',
                ]
            },
            {
                id: 2,
                time: startDate + 5260000, // 2 months
                color: 'blue',
                label: 'B',
                minSize: 30,
                tooltip: [
                    'Amet',
                    'Consectetur',
                    'Adipiscing',
                    'Elit',
                ]
            }
        ];
    } else {
        marks = [
            {
                id: 'String id',
                time: endDate,
                color: 'red',
                label: 'T',
                tooltip: ['Nulla']
            }
        ];
    }

    onDataCallback(marks);
};
```

## getServerTime

By default, the library gets the time from the user's machine. If the machine time is incorrect, the time used in the library is also incorrect.
To synchronize the library time with a server's time, enable the [`supports_time`](../../api/interfaces/Charting_Library.DatafeedConfiguration.md#supports_time) property and implement the [`getServerTime`](../../api/interfaces/Charting_Library.IDatafeedChartApi.md#getservertime) method.
In the implementation, send a request to a time server and return the accurate value to the library using the [`ServerTimeCallback`](../../api/modules/Datafeed.md#servertimecallback).
The time value should be a Unix timestamp, for example, `1445324591`.
Note that the callback should be called only once.

The library allows you to display the countdown to the bar closing on the price scale.
If you use this feature, consider implementing `getServerTime` to make sure that the countdown is correct.

:::info

To display a countdown, set the [`mainSeriesProperties.showCountdown`](../../api/interfaces/Charting_Library.ChartPropertiesOverrides.md#mainseriespropertiesshowcountdown) property to `true`.

:::

## getVolumeProfileResolutionForPeriod

The library calls [`getVolumeProfileResolutionForPeriod`](../../api/interfaces/Charting_Library.IDatafeedChartApi.md#getvolumeprofileresolutionforperiod) to request the resolution that is used to calculate the _Volume Profile Visible Range_ indicator. Implement this method if you want to calculate the indicator more accurately. The implementation depends on how much data you can transfer to the library and the depth of data in your datafeed.

If this method is not specified, the library uses `currentResolution`.

[`searchSymbols`]: https://charting-library-docs.xstaging.tv/latest/connecting_data/datafeed-api/required-methods.md#searchsymbols
[`searchSymbolsPaginated`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.IDatafeedChartApi#searchsymbolspaginated
[`SearchSymbolResultItem`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.SearchSymbolResultItem

---

## Sitemap

- [All documentation pages](https://charting-library-docs.xstaging.tv/llms.txt)
- [Full page map with headings](https://charting-library-docs.xstaging.tv/docs_map.md)
