SDKs overview

Redash provides both official and community-driven Software Development Kits (SDKs) and libraries, primarily designed to facilitate programmatic interaction with its platform. While Redash itself is an open-source data visualization and querying tool accessible via a web interface, its underlying architecture exposes a RESTful API. This API serves as the foundation for all SDKs, allowing developers to automate tasks such as creating and executing queries, managing data sources, organizing dashboards, and retrieving query results programmatically. The availability of SDKs extends Redash's utility beyond its graphical user interface, enabling integration into custom applications, CI/CD pipelines for data analytics, and automated reporting systems. Developers can leverage these tools to embed Redash functionalities within larger software ecosystems or to build bespoke data workflows that involve Redash as a core component for data querying and visualization.

The primary focus for official SDK development has historically been Python, reflecting the language's prevalence in data science and backend development. However, the open-source nature of Redash has fostered a community that contributes libraries and wrappers in other programming languages, broadening its appeal and applicability. These tools abstract the complexities of direct API requests, providing language-specific constructs that simplify common operations. For detailed information on the Redash API, consult the Redash REST API documentation.

Official SDKs by language

Redash maintains official support for a Python SDK, which serves as the primary interface for developers looking to interact with the Redash API programmatically. This SDK is designed to encapsulate the HTTP requests required to communicate with a Redash instance, providing a more Pythonic way to manage queries, dashboards, and other Redash entities. The official Python SDK is typically distributed via the Python Package Index (PyPI), making it accessible through standard Python package managers like pip.

The Python SDK offers functionalities to:

  • Execute queries: Run existing queries and fetch their results.
  • Manage data sources: List, create, or update connections to various databases.
  • Handle dashboards: Create new dashboards, add widgets, and update existing ones.
  • Retrieve metadata: Access information about users, queries, and data sources.

While Python is the officially supported language for an SDK, the Redash API itself is language-agnostic, meaning developers can build their own clients in any language capable of making HTTP requests. This flexibility is a core aspect of Redash's design, allowing for broad integration possibilities.

Here's a summary of the official SDK and its characteristics:

Language Package Name Install Command Maturity
Python redash-toolbelt pip install redash-toolbelt Official, actively maintained

Installation

Installing the Redash Python SDK, redash-toolbelt, is a standard process for Python packages. It uses pip, the package installer for Python, which typically comes bundled with Python distributions. Before installation, it's recommended to use a virtual environment to manage dependencies and avoid conflicts with other projects. A virtual environment creates an isolated Python installation where you can install packages without affecting your system-wide Python environment. To set up a virtual environment and install the SDK, follow these steps:

  1. Create a virtual environment: Open your terminal or command prompt and navigate to your project directory. Run python -m venv venv (or python3 -m venv venv on some systems) to create a new virtual environment named venv.
  2. Activate the virtual environment:
    • On macOS and Linux: source venv/bin/activate
    • On Windows: venv\Scripts\activate
    Once activated, your terminal prompt will usually show (venv) indicating you are operating within the virtual environment.
  3. Install the Redash SDK: With the virtual environment active, install redash-toolbelt using pip:
    pip install redash-toolbelt
    This command downloads the package and its dependencies from PyPI and installs them into your virtual environment.

After installation, you can import the redash_toolbelt module in your Python scripts and begin interacting with your Redash instance. Remember to deactivate the virtual environment when you are done by typing deactivate in your terminal.

Quickstart example

This quickstart example demonstrates how to use the redash-toolbelt Python SDK to connect to a Redash instance, list existing queries, and execute a specific query. Before running this code, ensure you have installed the redash-toolbelt package as described in the installation section and have your Redash API key and base URL ready. The API key can be found in your Redash user profile settings, and the base URL is the address of your Redash instance (e.g., https://your-redash-instance.com).

from redash_toolbelt import Redash
import os

# Configuration variables
REDASH_BASE_URL = os.environ.get("REDASH_BASE_URL", "https://demo.redash.io") # Replace with your Redash URL
REDASH_API_KEY = os.environ.get("REDASH_API_KEY", "YOUR_API_KEY") # Replace with your API Key

# Initialize the Redash client
try:
    client = Redash(REDASH_BASE_URL, REDASH_API_KEY)
    print(f"Successfully connected to Redash at: {REDASH_BASE_URL}")
except Exception as e:
    print(f"Error connecting to Redash: {e}")
    exit(1)

# 1. List all queries
print("\n--- Listing all queries ---")
try:
    queries = client.queries()
    if queries:
        for query in queries[:5]: # Print first 5 queries for brevity
            print(f"  ID: {query['id']}, Name: {query['name']}, Data Source: {query['data_source']['name']}")
    else:
        print("  No queries found.")
except Exception as e:
    print(f"Error listing queries: {e}")

# 2. Execute a specific query by ID (replace with an actual query ID from your Redash instance)
# You can find query IDs in the Redash UI by opening a query and checking the URL.
TARGET_QUERY_ID = 12345 # Replace with an actual query ID

print(f"\n--- Executing query ID: {TARGET_QUERY_ID} ---")
try:
    # Get query definition first to ensure it exists
    query_definition = client.query(TARGET_QUERY_ID)
    print(f"  Found query: '{query_definition['name']}'")

    # Execute the query and fetch results
    # The `refresh` parameter ensures the query runs fresh, not from cache.
    results = client.query_results(TARGET_QUERY_ID, refresh=True)

    if results and results['query_result']['data']['rows']:
        print(f"  Query executed successfully. First 3 rows of results:")
        for row in results['query_result']['data']['rows'][:3]:
            print(f"    {row}")
    else:
        print("  No results or empty results for the query.")

except RedashAPIError as e:
    print(f"  Redash API Error executing query {TARGET_QUERY_ID}: {e.message}")
except Exception as e:
    print(f"  General error executing query {TARGET_QUERY_ID}: {e}")

This example demonstrates basic interaction: establishing a connection, retrieving a list of available queries, and then executing a specific one by its ID. For more advanced features, such as creating new queries, managing data sources, or interacting with dashboards, refer to the redash-toolbelt GitHub repository and its documentation.

Community libraries

Beyond the official Python SDK, the open-source nature of Redash has encouraged its community to develop and maintain various libraries and tools that extend its functionality and integration capabilities. These community contributions often cater to specific use cases, provide wrappers in different programming languages, or offer utilities that enhance developer experience when working with Redash. While not officially supported by the Redash core team, these libraries can be valuable resources for developers seeking alternative language bindings or specialized tools.

Examples of common types of community contributions include:

  • Language wrappers: Libraries that provide an interface to the Redash API in languages other than Python, such as JavaScript/Node.js, Ruby, Go, or PHP. These wrappers typically follow the design patterns of their respective languages, making it easier for developers familiar with those ecosystems to interact with Redash.
  • CLI tools: Command-line interface utilities built on top of the Redash API, allowing for quick scripting and automation of Redash tasks directly from the terminal.
  • Deployment and management tools: Scripts or configurations (e.g., Docker Compose files, Kubernetes manifests) that simplify the deployment, scaling, or management of Redash instances, often integrating with infrastructure-as-code practices.
  • Data export/import utilities: Tools that facilitate moving data into or out of Redash, perhaps for backup purposes, migration between Redash instances, or integration with external data processing pipelines.

When considering community-contributed libraries, it is important to evaluate their maintenance status, community activity, and compatibility with your Redash version. Resources like GitHub, PyPI, and other package managers are common places to discover these libraries. Searching for "Redash client" or "Redash API" combined with your preferred programming language often yields relevant results. For instance, developers working with JavaScript might look for Node.js clients that abstract HTTP requests to the Redash API. Although specific community libraries are subject to change and varying levels of maintenance, a general search on platforms like GitHub can reveal several options, such as projects that provide a JavaScript client for Redash's API.

It's always recommended to review the source code, documentation, and issue tracker of any community library before incorporating it into a production environment. This due diligence ensures the library meets your project's requirements for reliability, security, and ongoing support.