提交 1ca648f7 编写于 作者: X xleili

Merge branch 'docs-cloud' of https://github.com/taosdata/TDengine into...

Merge branch 'docs-cloud' of https://github.com/taosdata/TDengine into docs/xiaolei/TD-18914-csharp-cloud-supplement
---
sidebar_label: REST and Schemaless
title: REST and Schemaless
description: Insert data using REST API or Schemaless
---
<!-- exclude -->
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
<!-- exclude-end -->
In this section we will explain how to write into TDengine cloud service using REST API or schemaless protocols over REST interface.
## REST API
### Config
Run this command in your terminal to save the TDengine cloud token and URL as variables:
<Tabs defaultValue="bash">
<TabItem value="bash" label="Bash">
```bash
export TDENGINE_CLOUD_TOKEN="<token>"
export TDENGINE_CLOUD_URL="<url>"
```
</TabItem>
<TabItem value="cmd" label="CMD">
```bash
set TDENGINE_CLOUD_TOKEN="<token>"
set TDENGINE_CLOUD_URL="<url>"
```
</TabItem>
<TabItem value="powershell" label="Powershell">
```powershell
$env:TDENGINE_CLOUD_TOKEN="<token>"
$env:TDENGINE_CLOUD_URL="<url>"
```
</TabItem>
</Tabs>
### Insert Data using REST API
Following command below show how to insert data into the table `d1001` of the database `test` via the command line utility `curl`.
```bash
curl -L \
-d "INSERT INTO d1001 VALUES (1538548685000, 10.3, 219, 0.31)" \
$TDENGINE_CLOUD_URL/rest/sql/test?token=$TDENGINE_CLOUD_TOKEN
```
## Schemaless
### InfluxDB Line Protocol
You can use any client that supports the http protocol to access the RESTful interface address `<cloud_url>/influxdb/v1/write` to write data in InfluxDB compatible format to TDengine. The EndPoint is as follows:
```text
/influxdb/v1/write?db=<db_name>&token=<cloud_token>
```
Support InfluxDB query parameters as follows.
- `db` Specifies the database name used by TDengine
- `precision` The time precision used by TDengine
Note: InfluxDB token authorization is not supported at present. Only Basic authorization and query parameter validation are supported.
### OpenTSDB Json and Telnet Protocol
You can use any client that supports the http protocol to access the RESTful interface address `<cloud_url>/opentsdb/v1/put` to write data in OpenTSDB compatible format to TDengine. The EndPoint is as follows:
```text
/opentsdb/v1/put/json/<db>?token=<cloud_token>
/opentsdb/v1/put/telnet/<db>?token=<cloud_token>
```
...@@ -13,7 +13,7 @@ import TabItem from '@theme/TabItem'; ...@@ -13,7 +13,7 @@ import TabItem from '@theme/TabItem';
First, you need to install the `taospy` module version >= `2.6.2`. Run the command below in your terminal. First, you need to install the `taospy` module version >= `2.6.2`. Run the command below in your terminal.
<Tabs defaultValue="pip"> <Tabs defaultValue="pip" groupID="package">
<TabItem value="pip" label="pip"> <TabItem value="pip" label="pip">
``` ```
...@@ -76,7 +76,7 @@ To obtain the value of cloud token and URL, please log in [TDengine Cloud](https ...@@ -76,7 +76,7 @@ To obtain the value of cloud token and URL, please log in [TDengine Cloud](https
## Connect ## Connect
Copy code bellow to your editor and run it. Copy code bellow to your editor and run it. If you are using jupyter, assuming you have followed the guide about Jupyter in previous secions, you can copy the code into Jupyter editor in your browser.
```python ```python
{{#include docs/examples/python/develop_tutorial.py:connect}} {{#include docs/examples/python/develop_tutorial.py:connect}}
...@@ -84,4 +84,49 @@ Copy code bellow to your editor and run it. ...@@ -84,4 +84,49 @@ Copy code bellow to your editor and run it.
For how to write data and query data, please refer to <https://docs.tdengine.com/cloud/data-in/insert-data/> and <https://docs.tdengine.com/cloud/data-out/query-data/>. For how to write data and query data, please refer to <https://docs.tdengine.com/cloud/data-in/insert-data/> and <https://docs.tdengine.com/cloud/data-out/query-data/>.
For more details about how to write or query data via REST API, please check [REST API](https://docs.tdengine.com/cloud/programming/connector/rest-api/). For more details about how to write or query data via REST API, please check [REST API](https://docs.tdengine.com/cloud/programming/connector/rest-api/).
\ No newline at end of file
## Jupyter
**Step 1: Install**
For the users who are familiar with Jupyter to program in Python, both TDengine Python connector and Jupyter need to be ready in your environment. If you have not done yet, please use the commands below to install them.
<Tabs defaultValue="pip" groupID="package">
<TabItem value="pip" label="pip">
```bash
pip install jupyterlab
pip3 install -U taospy
```
You'll need to have Python3 installed.
</TabItem>
<TabItem value="conda" label="conda">
```
conda install -c conda-forge jupyterlab
conda install -c conda-forge taospy
```
</TabItem>
</Tabs>
**Step 2: Configure**
In order for Jupyter to connect to TDengine cloud service, before launching Jupypter, the environment setting must be performed. We use Linux bash as example.
```bash
export TDENGINE_CLOUD_TOKEN="<token>"
export TDENGINE_CLOUD_URL="<url>"
jupyter lab
```
**Step 3: Connect**
Once jupyter lab is launched, Jupyter lab service is automatically connected and shown in your browser. You can create a new notebook and copy the sample code below and run it.
```python
{{#include docs/examples/python/develop_tutorial.py:connect}}
```
--- ---
sidebar_label: REST API sidebar_label: REST and Schemaless
title: REST API title: REST and Schemaless
description: Connect to TDengine Cloud Service through RESTful API description: Connect to TDengine Cloud Service through RESTful API or Schemaless
--- ---
<!-- exclude --> <!-- exclude -->
...@@ -40,9 +40,9 @@ $env:TDENGINE_CLOUD_URL="<url>" ...@@ -40,9 +40,9 @@ $env:TDENGINE_CLOUD_URL="<url>"
</TabItem> </TabItem>
</Tabs> </Tabs>
## Connect ## Usage
Please copy the code below to your editor and run it. The TDengine REST API is based on standard HTTP protocol and provides an easy way to access TDengine. As an example, the code below is to construct an HTTP request with the URL, the token and an SQL command and run it with the command line utility `curl`.
```bash ```bash
curl -L \ curl -L \
...@@ -50,3 +50,29 @@ curl -L \ ...@@ -50,3 +50,29 @@ curl -L \
$TDENGINE_CLOUD_URL/rest/sql?token=$TDENGINE_CLOUD_TOKEN $TDENGINE_CLOUD_URL/rest/sql?token=$TDENGINE_CLOUD_TOKEN
``` ```
## Schemaless
### InfluxDB Line Protocol
You can use any client that supports the http protocol to access the RESTful interface address `${TDENGINE_CLOUD_URL}/influxdb/v1/write` to write data in InfluxDB compatible format to TDengine. The EndPoint is as follows:
```text
/influxdb/v1/write?db=<DB_NAME>&token=${TDENGINE_CLOUD_TOKEN}
```
Support InfluxDB query parameters as follows.
- `db` Specifies the database name used by TDengine
- `precision` The time precision used by TDengine
Note: InfluxDB token authorization is not supported at present. Only Basic authorization and query parameter validation are supported.
### OpenTSDB Json and Telnet Protocol
You can use any client that supports the http protocol to access the RESTful interface address `${TDENGINE_CLOUD_URL}/opentsdb/v1/put` to write data in OpenTSDB compatible format to TDengine. The EndPoint is as follows:
```text
/opentsdb/v1/put/json/<db>?token=${TDENGINE_CLOUD_TOKEN}
/opentsdb/v1/put/telnet/<db>?token=${TDENGINE_CLOUD_TOKEN}
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册