RedashのAPIをつかってcsvを取得するためのツール
configに設定値を入れて実行するだけ。
config.example.jsonをconfig.jsonにして使うこと。
queryキーで対象となるクエリとパラメタの設定を行う。 以下にいくつか設定例を記す。
クエリパラメタが存在しないクエリのcsvを取得する
{
"apiKey": "Set your API Key",
"baseUrl": "http://hogehoge.example.com",
"exportPath": "/Users/h_hiroki/Desktop",
"query": [
{
"queryId": "1106"
}
]
}クエリパラメタが1つだけ存在するクエリのcsvを取得する
{
"apiKey": "Set your API Key",
"baseUrl": "http://hogehoge.example.com",
"exportPath": "/Users/h_hiroki/Desktop",
"query": [
{
"queryId": "1080",
"baseParams": [
"p_yyyy-mm"
],
"setParams": [
["2018-12"],
["2018-11"],
["2018-10"]
]
}
]
}クエリパラメタが2つ存在するクエリのcsvを取得する
{
"apiKey": "Set your API Key",
"baseUrl": "http://hogehoge.example.com",
"exportPath": "/Users/h_hiroki/Desktop",
"query": [
{
"queryId": "1107",
"baseParams": [
"p_start",
"p_end"
],
"setParams": [
["2018-12-01", "2018-12-01"],
["2018-12-02", "2018-12-02"],
["2018-12-03", "2018-12-03"]
]
}
]
}複数のクエリに対してcsvを取得する。 以下の場合、3つのクエリのCSVを取得できる。
{
"apiKey": "Set your API Key",
"baseUrl": "http://hogehoge.example.com",
"exportPath": "/Users/h_hiroki/Desktop",
"query": [
{
"queryId": "1106"
},
{
"queryId": "1107",
"baseParams": [
"p_start",
"p_end"
],
"setParams": [
["2018-12-01", "2018-12-01"],
["2018-12-02", "2018-12-02"],
["2018-12-03", "2018-12-03"]
]
},
{
"queryId": "1080",
"baseParams": [
"p_yyyy-mm"
],
"setParams": [
["2018-12"],
["2018-11"],
["2018-10"]
]
}
]
}設定ファイルをjsonで書く記事 http://m-shige1979.hatenablog.com/entry/2017/10/30/080000
{ "apiKey": "Set your API Key", //RedashのUserAPIKeyをセットすること "baseUrl": "http://hogehoge.example.com", //利用する RedashのURLを設定すること "exportPath": "/Users/h_hiroki/Desktop", //取得したCSVの出力先を指定できる "query": [ { "queryId": "1106" //queryキーは後述する } ] }