|
| 1 | +# Elecktron WebSocket API with TypeScript Example |
| 2 | +## Overview |
| 3 | + |
| 4 | +[Elektron WebSocket API](https://developers.thomsonreuters.com/elektron/websocket-api-early-access) enables easy integration into a multitude of client technology environments such as scripting and web. This API runs directly on your TREP infrastructure or the Thomson Reuters platform and presents data in an open (JSON) readable format. The API supports all Thomson Reuters Elektron data models and can be integrated into multiple client technology standards e.g. Python, R, .Net etc. |
| 5 | + |
| 6 | +[TypeScript](https://www.typescriptlang.org) programming language is a typed superset of JavaScript that compiles to readable, standards-based JavaScript. The language is designed for application-scale JavaScript by adding optional types, classes, modules, ECMAScript 2015 features and future proposals to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript is as a first-class programming language in Microsoft Visual Studio, [Angular](https://angularjs.org/) web application platform. It also supported by various application frameworks like [React](https://github.com/Microsoft/TypeScript-React-Starter#typescript-react-starter), [NodeJS and Express framework](https://github.com/Microsoft/TypeScript-Node-Starter#typescript-node-starter), [ASP.Net Core](https://www.typescriptlang.org/docs/handbook/asp-net-core.html), [Vue.js](https://github.com/Microsoft/TypeScript-Vue-Starter#typescript-vue-starter) and more. |
| 7 | + |
| 8 | +This example shows how to implement the Elektron WebSocket API JavaScript web application with TypeScript. The web application source codes are implemented in TypeScript language to connect, consume and display data from the ADS server via the Elektron WebSocket API in the web browsers. All source codes will be compiled to readable JavaScript with [Webpack](https://webpack.js.org/) JavaScript module bundler. |
| 9 | + |
| 10 | +## Supported Web Browsers |
| 11 | +The example supports Chrome, Firefox and IE11 (based on the WebSocket and Web Workers browser supported platform). |
| 12 | + |
| 13 | +## Prerequisite |
| 14 | +This example requires the following dependencies softwares. |
| 15 | +1. [Node.js](https://nodejs.org/en/) - version 6.10 or higher. |
| 16 | +2. [npm](https://www.npmjs.com/) package manager (included in Node.js) |
| 17 | +2. [TypeScript](https://www.typescriptlang.org) |
| 18 | + |
| 19 | +This example also uses the following 3rd party libraries for UI presentation. |
| 20 | +1. [jQuery 3.2.1](https://jquery.com/) |
| 21 | +2. [Bootstrap 3.3.7](https://getbootstrap.com/docs/3.3/) |
| 22 | + |
| 23 | +Both of jQuery and Bootstrap are distributed under the [MIT license](https://opensource.org/licenses/MIT). Please see more detail in the LICENSE.md file. |
| 24 | + |
| 25 | +## Package |
| 26 | +The project includes complete TypeScript source code, CSS files and all required static dependencies. The dynamic dependencies for compiling and building JavaScript source file are defined in *package.json* file which can be installed via ```npm install``` command. |
| 27 | + |
| 28 | +The project includes the following files and folder |
| 29 | +- *src/* folder: The folder that contains all TypeScript source files |
| 30 | +- *web/* folder: The folder that contains all application web page files |
| 31 | + - *web/dist* folder: The folder that the compiled JavaScript file named *web_app.js* will be generated |
| 32 | + - *web/index.html*: The application HTML page |
| 33 | + - *web/css/cover.css*: The application CSS file |
| 34 | + - *web/libs/jquery-3.2.1.min.js*: jQuery library file |
| 35 | + - *web/bootstrap/css*, *web/bootstarp/fonts* and *web/bootstrap/js* folders: The folders for Bootstrap CSS and libraries files |
| 36 | +- package.json: Project's NPM dependencies file |
| 37 | +- tsconfig.json: Project's TypeSccript compiler options file |
| 38 | +- webpack.config.js: Project's Webpack compiler options file |
| 39 | + |
| 40 | + |
| 41 | +## How to run this example application |
| 42 | +1. Unzip or download the example project folder into a directory of your choice |
| 43 | +2. Run ```$> npm install``` in the command prompt to install all the dependencies required to run the sample in a subdirectory called *node_modules/*. |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | +3. If the machine is behind a proxy server, you need to configure Node.js uses proxy instead of a direct HTTP connection via the following command in command prompt: ```set https_proxy=http://<proxy.server>:<port>``` |
| 48 | +4. Run ```$> webpack``` in the command prompt to build and compile all TypeScript files in *src* into JavaScript source file (*/web/dist/* folder) |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +5. Copy and deploy the *web* folder into in any web server (recommend [http-server](https://www.npmjs.com/package/http-server) for quick dev/testing) |
| 53 | +6. Open web browser, then navigate to index.html of the web server (example for http-server: ```hhttp://localhost:8080/index.html```) |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | +## References |
| 58 | +For further details, please check out the following resources: |
| 59 | +* [Thomson Reuters Elektron WebSocket API page](https://developers.thomsonreuters.com/elektron/websocket-api-early-access) on the [Thomson Reuters Developer Community](https://developers.thomsonreuters.com/) web site. |
| 60 | +* [TypeScript programming language: Documentation](https://www.typescriptlang.org/docs/home.html). |
| 61 | +* [Mozilla Developer Network: Web Workers API page](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) |
| 62 | + |
| 63 | +For any question related to this article or Elektron WebSocket API page, please use the Developer Community [Q&A Forum](https://community.developers.thomsonreuters.com/). |
0 commit comments