Scuba provides a behavioral analytics query language (BQL, or BAQL) that you can use with an API call to programmatically query Scuba.
For more information about the Scuba query language, see:
Scuba query concepts for BQL users for a discussion of how Scuba queries work, with examples of how to create these types of queries using BQL.
BQL syntax and usage for a description of BQL building blocks and examples of common Scuba queries from the UI translated into BQL.
BQL vs. SQL comparison for similarities and differences between BQL and SQL concepts.
For information about querying with the API, see Use the Scuba external query API.