Hi Redash Community!
We (RecoLabs, a stealth startup) are building a golang SDK for Redash, and we’re planning to open-source it. We’d love to coordinate with the community before just publishing it, so here goes
What is it?
From the documentation of the go package:
// redashclient is a go wrapper to Redash's REST API.
// redashclient provides a go API to set up and manage a remote redash client programmatically.
And from the README:
This is a simple SDK for the programmatic management of Redash. We created this client based on the python code of version 10.1.0 of Redash.
What’s included?
- Easy to use Go client that covers some parts of the API.
- Swagger definition of the Redash API - we would love to coordinate with the community here and contribute this to the main project in the future.
- Documentation and examples.
- Earthly-based build pipeline (lint and test).
- Many linters with golangci-lint and good test coverage.
Which parts of the API are covered?
- Data Sources
- Queries
- Visualizations
- Users
Some of these resources might only be partially covered.
Why do this?
We needed a way to programmatically control our self-hosted Redash instance from our backend services - we developed a custom dashboard screen in our product and Redash solved many issues for us, so we decided to use it as both the backend and the visualization engine (with embedded visualizations).
Examples
Subsection of the Swagger file
Client usage
List all queries
import (
redashclient "github.com/[REDACTED]/redashClient"
"github.com/[REDACTED]/gen/client"
)
redashClient := redashclient.NewClient(
"{API_KEY}",
&client.TransportConfig{
Host: "{HOST_ADDRESS}",
})
// Calls in the client are of the form:
// client.<Queries/Visualizations/Users/DataSources>.<Method>(...)
// For example:
// List the current queries in Redash
allQueries, err := redashClient.Queries.List()
Get a visualization’s embed URL
queryID := 1
visualizationID := 1
queryAPIKey := "{API_KEY}"
visualizationUrl, err := redashClient.Visualizations.GetURL(visualizationID, queryID, queryAPIKey)
`
What’s next?
Once we collect a bit more feedback about the package internally and from y’all here in the community, we plan to release it under BSD 2-Clause “Simplified” License. Hopefully, we’ll be able to make this happen very soon.