{"id":15468307,"url":"https://github.com/winebarrel/redash-go","last_synced_at":"2025-04-22T11:27:09.684Z","repository":{"id":65806524,"uuid":"597586644","full_name":"winebarrel/redash-go","owner":"winebarrel","description":"Redash API client for Go that supports almost all APIs.","archived":false,"fork":false,"pushed_at":"2025-04-14T22:30:59.000Z","size":663,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-14T23:29:46.096Z","etag":null,"topics":["golang","redash"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/winebarrel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-05T01:31:35.000Z","updated_at":"2025-04-14T22:31:02.000Z","dependencies_parsed_at":"2023-10-15T08:15:58.478Z","dependency_job_id":"8da12f38-f694-41fd-a993-c064f88c9b7e","html_url":"https://github.com/winebarrel/redash-go","commit_stats":{"total_commits":261,"total_committers":2,"mean_commits":130.5,"dds":"0.14559386973180077","last_synced_commit":"4f39833340cbbf1dedb2142c70872bf0b72576fb"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winebarrel%2Fredash-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winebarrel%2Fredash-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winebarrel%2Fredash-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winebarrel%2Fredash-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/winebarrel","download_url":"https://codeload.github.com/winebarrel/redash-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250230659,"owners_count":21396335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","redash"],"created_at":"2024-10-02T01:40:39.867Z","updated_at":"2025-04-22T11:27:09.673Z","avatar_url":"https://github.com/winebarrel.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# redash-go\n\n[![CI](https://github.com/winebarrel/redash-go/actions/workflows/ci.yml/badge.svg)](https://github.com/winebarrel/redash-go/actions/workflows/ci.yml)\n[![Go Reference](https://pkg.go.dev/badge/github.com/winebarrel/redash-go/v2.svg)](https://pkg.go.dev/github.com/winebarrel/redash-go/v2)\n[![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/winebarrel/redash-go)](https://pkg.go.dev/github.com/winebarrel/redash-go/v2?tab=versions)\n[![Go Report Card](https://goreportcard.com/badge/github.com/winebarrel/redash-go/v2)](https://goreportcard.com/report/github.com/winebarrel/redash-go/v2)\n[![codecov](https://codecov.io/gh/winebarrel/redash-go/graph/badge.svg?token=9E21C7D54I)](https://codecov.io/gh/winebarrel/redash-go)\n\n## Overview\n\nRedash API client for Go that supports almost all APIs.\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/winebarrel/redash-go/v2\"\n)\n\nfunc main() {\n\tclient := redash.MustNewClient(\"https://redash.example.com\", \"\u003csecret\u003e\")\n\tctx := context.Background()\n\n\tds, err := client.CreateDataSource(ctx, \u0026redash.CreateDataSourceInput{\n\t\tName: \"postgres\",\n\t\tType: \"pg\",\n\t\t// see https://github.com/getredash/redash/blob/v25.1/redash/query_runner/pg.py#L149-L153\n\t\tOptions: map[string]any{\n\t\t\t\"dbname\": \"postgres\",\n\t\t\t\"host\":   \"postgres\",\n\t\t\t\"port\":   5432,\n\t\t\t\"user\":   \"postgres\",\n\t\t},\n\t})\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tquery, err := client.CreateQuery(ctx, \u0026redash.CreateQueryInput{\n\t\tDataSourceID: ds.ID,\n\t\tName:         \"my-query1\",\n\t\tQuery:        \"select 1\",\n\t})\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tvar buf bytes.Buffer\n\n\t// The API prefers to return a cached result.\n\t// If a cached result is not available then a new execution job begins and the job object is returned.\n\t// see https://redash.io/help/user-guide/integrations-and-api/api#Queries\n\tjob, err := client.ExecQueryJSON(ctx, query.ID, nil, \u0026buf)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\terr = client.WaitQueryJSON(ctx, query.ID, job, nil, \u0026buf)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(buf.String())\n}\n```\n\n### `max_age=0`\n\n```go\ninput := \u0026redash.ExecQueryJSONInput{\n  WithoutOmittingMaxAge: true,\n}\n\njob, err := client.ExecQueryJSON(ctx, query.ID, input, nil)\n\nif err != nil {\n  panic(err)\n}\n\nerr = client.WaitQueryJSON(ctx, query.ID, job, nil, \u0026buf)\n\nif err != nil {\n  panic(err)\n}\n\nfmt.Println(buf.String())\n```\n\n### Set debug mode\n\n```go\nclient := redash.MustNewClient(\"https://redash.example.com\", \"\u003csecret\u003e\")\nclient.SetDebug(true)\nclient.GetStatus(context.Background())\n```\n\n```\n% go run example.go\n---request begin---\nGET /status.json HTTP/1.1\nHost: redash.example.com\nAuthorization: Key \u003csecret\u003e\nContent-Type: application/json\nUser-Agent: redash-go\n\n\n---request end---\n---response begin---\nHTTP/1.1 200 OK\n...\n\n{\"dashboards_count\": 0, \"database_metrics\": {\"metrics\": [ ...\n```\n\n### With custom HTTP client\n\n```go\nhc := \u0026http.Client{\n  Timeout: 3 * time.Second,\n}\nclient := redash.MustNewClientWithHTTPClient(\"https://redash.example.com\", \"\u003csecret\u003e\", hc)\nclient.GetStatus(context.Background())\n```\n\n### Without context.Context\n\n```go\nclient0 := redash.MustNewClient(\"https://redash.example.com\", \"\u003csecret\u003e\")\nclient := client0.WithoutContext()\nclient.GetStatus()\n```\n\n### NewClient with error\n\n```go\nclient, err := redash.NewClient(\"https://redash.example.com\", \"\u003csecret\u003e\")\n```\n\n## Test\n\n```sh\nmake test\n```\n\n### Acceptance Test\n\n```sh\ndocker compose up -d\nmake redash-setup\nmake testacc\n```\n\n**NOTE:**\n* local Redash URL: http://localhost:5001\n* email: `admin@example.com`\n* password: `password`\n* mail server URL: http://localhost:10081\n\n## Related Links\n\n* https://redash.io/help/user-guide/integrations-and-api/api\n* https://github.com/winebarrel/terraform-provider-redash\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwinebarrel%2Fredash-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwinebarrel%2Fredash-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwinebarrel%2Fredash-go/lists"}