Honeydew provides a GraphQL API, that allows to directly call the Honeydew service.
This guide covers a direct connection to the Honeydew API using GraphQL.It is also possible to use Honeydew APIs with a Snowflake Connection, by calling the Snowflake Native Application API.
Public GraphQL API is not enabled by default. To enable for your organization, please contact support@honeydew.ai.

Use Cases

Embedded Analytics

The GraphQL API can be used to build embedded analytics applications that leverage the semantic layer. This allows you to build custom applications that use the semantic layer to generate queries and retrieve data.

Building custom AI analyst applications

The GraphQL API can be used to build custom AI analyst applications that leverage the semantic layer to answer user questions in natural language.

Metadata Sharing

The GraphQL API can be used to share metadata with other applications or services. For example, you can use the GraphQL API to share metadata with a data catalog or a data governance tool, or to import metadata from another system into Honeydew.

BI Integration

The GraphQL API can be used to publish metadata to BI tools, such as Tableau, Power BI, Thoughtspot, and more.

Development and Testing

The GraphQL API can be used to develop and test semantic layer definitions. Developers can use their favorite development tools to edit the semantic layer definitions, push them directly to git, and use the GraphQL APIs to validate the definitions. These validations can also be integrated into CI/CD pipelines to ensure that the semantic layer definitions are valid before deploying them to production.

Usage

Security

You can use the GraphQL API with an API Key and Secret. You cannot use the GraphQL API with a Honeydew username and password.
Different API queries and mutations require different permissions. Therefore, in order to follow the principal of least privileges as a best practice, you may need to create different API keys for different use cases.Each query or mutation below specifies the required permissions.
It is recommended to restrict API access to specific IP addresses or ranges, by using the IP Access Control feature. To set up IP Access Control, please contact support@honeydew.ai.

API Endpoint

The default API endpoint is https://api.honeydew.cloud/api/public/v1/graphql. If your organization uses a custom hostname for the API connection, you can locate it in the Honeydew UI, under the API section in Settings.

Headers

The following custom Honeydew headers can be used in the API requests:
  • X-Honeydew-Client: A string that identifies the client making the request. Use it to identify the client in Honeydew logs and query history, for audit, debugging and support purposes.
  • X-Honeydew-Workspace: The name of the workspace to use for the request. This is required for most queries and mutations that operate on a specific workspace.
  • X-Honeydew-Branch: The name of the branch to use for the request. This is required for most queries and mutations that operate on a specific branch.

API integration example

Below we have provided API integration examples for Python, JavaScript and cURL. The API can be used with any programming language that supports HTTP requests.
To learn more about GraphQL, you can refer to the GraphQL documentation
This example uses the requests library to make HTTP requests to the Honeydew API. To install it, run:
pip install requests
import requests
from requests.auth import HTTPBasicAuth

# Replace with your Honeydew API Key and Secret
API_KEY = "your_api_key_here"
API_SECRET = "your_api_secret_here"


# Honeydew API endpoint
# If your organization uses a custom hostname, use it here instead of the default
HONEYDEW_API_HOSTNAME = "api.honeydew.cloud"
API_URI = f"https://{HONEYDEW_API_HOSTNAME}/api/public/v1/graphql"


# Example of a GraphQL query to get workspaces
# Since the graphql call is at a global level, we don't need to specify workspace or branch here

WORKSPACES_QUERY = """
    query {
        workspaces {
            name
        }
    }
"""

response = requests.post(
    API_URI,
    json={"query": WORKSPACES_QUERY},
    auth=HTTPBasicAuth(API_KEY, API_SECRET),
    timeout=30,
    headers={
        "Content-Type": "application/json",
        "X-Honeydew-Client": "python-script",
    },
)
response.raise_for_status()  # Raise an error for bad responses

print("Response from Honeydew API:", response.json())


# Example of a GraphQL query to get entities of a specific workspace

WORKSPACE_NAME = "tpch"
BRANCH_NAME = "prod"

ENTITIES_QUERY = """
    query {
        entities {
            name
        }
    }
"""

response = requests.post(
    API_URI,
    json={"query": ENTITIES_QUERY},
    auth=HTTPBasicAuth(API_KEY, API_SECRET),
    timeout=30,
    headers={
        "Content-Type": "application/json",
        "X-Honeydew-Client": "python-script",
        "X-Honeydew-Workspace": WORKSPACE_NAME,
        "X-Honeydew-Branch": BRANCH_NAME,
    },
)
response.raise_for_status()  # Raise an error for bad responses

print("Response from Honeydew API:", response.json())


# Example of a GraphQL query to get a specific entity with variables
ENTITY_QUERY = """
    query getEntity($name: String!) {
        entity(name: $name) {
            name
            keys
        }
    }
"""

response = requests.post(
    API_URI,
    json={
        "query": ENTITY_QUERY,
        "variables": {"name": "customers"},
    },
    auth=HTTPBasicAuth(API_KEY, API_SECRET),
    timeout=30,
    headers={
        "Content-Type": "application/json",
        "X-Honeydew-Client": "python-script",
        "X-Honeydew-Workspace": WORKSPACE_NAME,
        "X-Honeydew-Branch": BRANCH_NAME,
    },
)
response.raise_for_status()  # Raise an error for bad responses

print("Response from Honeydew API:", response.json())

# Example of a GraphQL mutation to reload workspace
RELOAD_ALL_WORKSPACES = """
    mutation ReloadAllWorkspaces {
        reset_all_workspaces
    }
"""

response = requests.post(
    API_URI,
    json={
        "query": RELOAD_ALL_WORKSPACES,
    },
    auth=HTTPBasicAuth(API_KEY, API_SECRET),
    timeout=30,
    headers={
        "Content-Type": "application/json",
    },
)
response.raise_for_status()  # Raise an error for bad responses

print("Response from Honeydew API:", response.json())
The above will produce the following kind of output:
Response from Honeydew API: {'data': {'workspaces': [{'name': 'tasty_bytes'}, {'name': 'tpch'}]}}
Response from Honeydew API: {'data': {'entities': [{'name': 'customers'}, {'name': 'order_lines'}, {'name': 'orders'}, {'name': 'parts'}, {'name': 'sessions'}]}}
Response from Honeydew API: {'data': {'entity': {'keys': ['custkey'], 'name': 'customers'}}}
Response from Honeydew API: {'data': {'reset_all_workspaces': None}}
The above examples are basic and do not include error handling. In production code, you should handle errors and exceptions appropriately. We recommended using a graphql client library for more complex queries and mutations.

GraphQL API Reference

Workspaces and Branches

Querying Schema

Modifying Schema

Queries

AI

BI Integration

Missing an API query or mutation? If you need a specific query or mutation that is not covered in this guide, please reach out to support@honeydew.ai