Develop a JavaScript Query
This section of the crash course covers Deephaven Enterprise's client APIs. This guide walks you through a simple end-to-end task:
- connecting to a Deephaven Enterprise server using JavaScript,
- opening a specific table,
- displaying its data,
- and applying a basic filter.
Note
To run these examples in your environment, you'll need to replace the following placeholder values with your actual information:
https://myserver/- Replace with your actual Deephaven server URL- Username and password in authentication examples
'MyQuery'- Replace with an actual Persistent Query name available on your server'my_data_table'- Replace with an actual table name from your query
The complete example at the end of this guide contains all the necessary HTML and JavaScript code. Copy this example, make the replacements noted above, and save it as an HTML file to get started quickly.
Prerequisites
To get started, you need to load the Deephaven JS library. This file is typically loaded from the Deephaven server itself. It resides at /irisapi/irisapi.nocache.js on the web server. In this example, we'll assume your Deephaven server is hosted at https://myserver/.
Include this script tag in your HTML file:
1. Connect and authenticate
First, create a dh.Client instance and log in. This example uses password authentication.
2. Open a Specific Table
Once you have an authenticated client, you can open tables from a Persistent Query using Core+ functionality.
This code uses the Core+ API to connect to the query and fetch the table. It dynamically imports the API from the URL provided in the query information, authenticates with a token, and then retrieves the table object.
3. Display Table Data
To display data from a table, you set a viewport and get its data.
4. Apply a Simple Filter
5. Put it all together
Complete example
Here's a full HTML page combining all the steps. Replace https://myserver/, user, password, MyQuery, my_data_table, and column names with your actual details.
Conclusion
This crash course has walked you through the essentials of using the Deephaven JavaScript API to connect to a server, retrieve a table, display its data, and apply a simple filter. With these fundamentals, you can start exploring more advanced features and building more complex client applications.