You need to enable JavaScript to run this app.
ByteHouse Cloud Data Warehouse Version

ByteHouse Cloud Data Warehouse Version

Copy page
Download PDF
Connect ByteHouse
Use HTTP connection
Copy page
Download PDF
Use HTTP connection

The HTTP interface supports the use of ByteHouse on any platform in any programming language through the REST API. This article introduces how to connect to ByteHouse using the HTTP method.

Prerequisites

Please ensure you have installed curl, see the official website for details.

Connect to ByteHouse

You can connect to ByteHouse using the following command.

curl "https://<domain>:8123?user=bytehouse&password=${APItoken}"

Parameter

Configuration Key Points

Configure the host information for ByteHouse. You can obtain the public or private domain name information in ByteHouse Console's tenant management>basic information>network information, format as follows:

  • Private Network: tenant-{TENANT_ID}-{REGION}[-{ENVIRONMENT}].bytehouse.ivolces.com
  • Public Network: tenant-{TENANT_ID}-{REGION}[-{ENVIRONMENT}]-public.bytehouse.volces.com

Of which {ENVIRONMENT} is optional, if using the default environment, it does not need to be filled; if specifying another environment, add this parameter .

user

Username for logging into the ByteHouse database, configured as bytehouse.

password

Password for logging into the ByteHouse database, configured as ByteHouse's <API_Key>, which can be obtained in the **Tenant ManagementConnection Information ** section of the ByteHouse console. For more details, see Get API Key.

Use example

You can connect to ByteHouse via HTTP and manage data. This section uses table t as an example, demonstrating how to create, write, query, and delete tables. Please replace the domain, api_token, and query statements according to your environment information and business needs in actual use.

Create Table

echo 'CREATE TABLE t (a UInt8) ENGINE = 'CnchMergeTree' ORDER BY a' | curl 'https://<domain>:8123?user=bytehouse&password=<api_token>&' --data-binary @-

Write Data

Support data insertion via INSERT search.

echo 'INSERT INTO t VALUES (1),(2),(3)' | curl 'https://<domain>:8123?user=bytehouse&password=<api_token>&' --data-binary @-

You can also separate the data from the query and send it.

echo '(4),(5),(6)' | curl 'https://<domain>:8123?user=bytehouse&password=<api_token>&query=INSERT%20INTO%20t%20VALUES' --data-binary @-

You can specify any data format. 'Values' format is the same as used when writing INSERT INTO t VALUES.

echo '(7),(8),(9)' | curl 'https://<domain>:8123?user=bytehouse&password=<api_token>&query=INSERT%20INTO%20t%20FORMAT%20Values' --data-binary @-

To insert data from a tab-separated dump, please specify the corresponding format.

echo -ne '10\n11\n12\n' | curl 'https://<domain>:8123?user=bytehouse&password=<api_token>&query=INSERT%20INTO%20t%20FORMAT%20TabSeparated' --data-binary @-

You can use the following commands to write to a CSV file.

curl "https://<domain>:8123?user=bytehouse&password=<api_token>&query=INSERT%20INTO%20t%20FORMAT%20CSV" --data-binary @data.csv

Query Data

curl 'https://<domain>:8123/?user=bytehouse&password=<api_token>&query=SELECT%20a%20FROM%20t'

Delete Table

$ echo 'DROP TABLE t' | curl 'http://localhost:8123/' --data-binary @-

Optimize output style using the format parameter

You can use format Pretty to optimize the style of your query results.

curl "https://gateway-rc.volc-boe.offline.bytehouse.cn:8123?query=select%20100%20format%20Pretty&user=bytehouse&password=${APItoken}"

You can also use format JSON; query results will be output in JSON format.

curl "https://gateway-rc.volc-boe.offline.bytehouse.cn:8123?query=select%20100%20format%20JSON&user=bytehouse&password=${APItoken}"

Last updated: 2026.03.31 16:21:56