コンテンツにスキップ

InfluxAPI

データ書き込み用のWebAPI

データベースの作成

1
curl -i -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE webapidb"
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
urlencode "q=CREATE DATABASE webapidb"
HTTP/1.1 200 OK
Connection: close
Content-Type: application/json
Request-Id: 1f1643bc-ae13-11e7-801b-000000000000
X-Influxdb-Version: 1.3.5
Date: Tue, 10 Oct 2017 23:31:20 GMT
Transfer-Encoding: chunked

{"results":[{"statement_id":0}]}
1
curl -i -XPOST 'http://localhost:8086/write?db=webapidb' --data-binary 'aizu,temperature=11 humidity=30.1'
1
2
3
4
5
HTTP/1.1 204 No Content
Content-Type: application/json
Request-Id: 562d4f3e-ae13-11e7-801e-000000000000
X-Influxdb-Version: 1.3.5
Date: Tue, 10 Oct 2017 23:32:53 GMT

データの読み込み

1
curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=webapidb" --data-urlencode "q=SELECT *  FROM \"aizu\""
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
    "results": [
        {
            "statement_id": 0,
            "series": [
                {
                    "name": "aizu",
                    "columns": [
                        "time",
                        "humidity",
                        "temperature"
                    ],
                    "values": [
                        [
                            "2017-10-10T23:32:53.151305504Z",
                            30.1,
                            "11"
                        ]
                    ]
                }
            ]
        }
    ]
}