Connecting data
Overview
The library is a powerful, client-side solution for creating rich, interactive user interfaces for market data.
The library does not provide any market data. You must connect the library to your own data source or a third-party provider.
The connection between the library and your data source is managed by a crucial component called the datafeed. The datafeed is a JavaScript object that acts as a bridge, responding to the library's requests for information. When a user interacts with the chart, for example, by loading a symbol, changing the time interval, or scrolling back in time, the library calls the appropriate methods on your datafeed to fetch the necessary data.
Your responsibility is to implement the datafeed to fetch data from your backend and return it to the library in the expected format. The core datafeed responsibilities include:
- Provide configuration to the library, including supported exchanges, resolutions, and symbol types.
 - Resolve symbol information, such as its trading hours, timezone, and price formatting rules.
 - Supply historical bar data (OHLC).
 - Stream real-time data to show the latest market activity.
 - Provide real-time quote data such as bid/ask prices and volume (for Trading Platform only).
 
Data integration approaches
You have two approaches for implementing the datafeed. The best choice depends on your project's requirements and development timeline.
Datafeed API
The Datafeed API is a set of JavaScript methods that you implement to create a custom datafeed. This approach offers maximum flexibility, allowing you to use any protocol (like WebSockets for real-time data) and implement custom logic for data handling. This is the recommended approach.
To begin your implementation, we recommend following our step-by-step tutorial How to connect data via datafeed API. It will guide you through creating a functional datafeed from scratch, including real-time data streaming with WebSockets.
UDF adapter
The library includes a pre-built UDF (Universal Datafeed) adapter, which is a ready-to-use implementation of the Datafeed API. It works by making simple HTTP requests to your backend. Your responsibility is to create a server-side service that responds in the required format.
UDF adapter does not support real-time data streaming out of the box but you can implement it.
Choose this approach if you want to get started quickly or as a reference implementation. You can use the UDF adapter source code as an example of the Datafeed API implementation, copying and modifying it for your own needs.
To begin your implementation, we recommend following the UDF adapter article for step-by-step details on API requests, queries, and parameters.