Author:


Introduction
As part of LSEG Workspace Migration, developers have new ways to access financial data directly from the browser. The LSEG Data Library for TypeScript provides a browser-compatible module (datalib.js) that enables client-side integration with Workspace as a lightweight, local applications.
This article walks you through the workflow of setting up and running a simple HTML page (test.html) that uses datalib.js to connect to Workspace via the Desktop session.
LSEG provides a browser build for the Data Library which is available in the NodeJS package @lsegroup/data. The JavaScript datalib.js file for browser can be found at @lsegroup\data\build\browser. This module is not separately deployed on the CDN. A web page can reference this script and import all the provided modules, as shown in the accompanying sample.
Limitations
Using the library within a web browser has following limitations:
- The Library can only be used with a Desktop Session, on a machine running LSEG Workspace. The CORS restrictions do not allow Platform Session connections.
- The browser does not have access to the local filesystem. Due to this, library is unable to read the API proxy port and tries to connect default port 9000 on the localhost. A workaround is to either manually provide the Proxy port or as the provided example shows, try a range of ports.
Prerequisite
- LSEG Workspace with Workspace account that has access to Data Library for TypeScript. (You can request LSEG Workspace Free Trial by clicking the link on the top right of this article)
- Node.js v23.6.0
- NodeJS package: @lsegroup/data@1.0.0, http-server@14.1.1
How it Works
Below is a simple diagram showing the flow from browser --> local server --> Workspace Desktop session to get the output data.

Workflow Overview
Step 1) Prepare your files
Copy the following files into a local directory on your machine:
- datalib.js (found in NodeJS package @lsegroup/data/build/browser)
- test.html (your HTML file that references datalib.js, the example file can be found here)

Let say your directory name is data-lib-browser, your folder structure should look like:
data-lib-browser/
├── datalib.js
└── test.html
Step 2) Start a server
Serve the files on your server. In case you want to do it in your local machine, you must serve the files using a local server to avoid CORS issues and enable Workspace desktop session detection.
The local server can be started with either using Node.js and http-server or Python. Here's I'm using the first option so I run the command below in my Command Prompt.
npm install -g http-server
cd data-lib-browser
http-server

Step 3) Open the app in your browser
Navigate to your server. For example, the address of my local server from the console above is
http://192.168.1. 163:8080/test.html, this will load HTML page and initialize the Data Library using your active Workspace Desktop Session

Step 4) Authenticate and Request Data
To authenticate and request data, make sure your Workspace is running and logged in on your machine.
Inside test.html file, the script will:
- Load datalib.js
- Use your App Key (that you input on the UI) to open a desktop session
- Request data from Workspace (e.g. instrument prices) by put the RIC of instrument that you want to get the data in the text box and click button next to it. The available functions to request data on this example are.
- Get Snapshot
- Start Streaming
- Get Fundamental
- Get History
Then you can follow the instruction shown in the UI: "Launch the LSEG Workspace, type in the APPKey and click connect"
For how to get your App Key, please follow the step mentioned in Desktop access point part of Quick start guide > Access credential
As the browser does not have access to the local filesystem. Due to this, library is unable to read the API proxy port and tries to connect default port 9000 on the localhost. A workaround is to either manually provide the Proxy port or as the provided example shows, try a range of ports.

Example of requesting snapshot data of CAD=

Example of requesting fundamental data of GOOGL.O

Example of requesting historical data of IBM.N

Conclusion
Running the LSEG Data Library for TypeScript is a simple way to access Workspace data directly from the client side. By copying datalib.js and test.html into a local directory and serving them with a local server, developers can quickly test and prototype browser-based applications with the Workspace Desktop Session.
If you have any questions regarding this article or our API usage, please feel free to check and post them in our Q&A Forum.
In a next article, we'll explore how to implement and compile the Data Library using TypeScript for more advanced and customizable solutions. The example code of Data Library for TypeScript can be found in LSEG-API-Samples/Example.DataLibrary.TypeScript