Connecting via the API

Using curl to connect with an API key

A quick and easy way to get started exploring bit.io is with cURL.

First, grab your API key by clicking "Connect" and then copying your API key (from the "Password" field; see below).

25662566

Then you can use the query API to query your databases or any public databases.

As an example, let's use the query API to download the first ten rows of a table. The query endpoint is https://api.bit.io/v2beta/query. You will need to pass your API key (see above) to query using the API. Note that, unlike in the previous version of bit.io, it is now necessary to include the database_name in the request.

API_KEY=<your-api-key>
curl --request POST \
     --url https://api.bit.io/v2beta/query \
     --header "Authorization: Bearer ${API_KEY}" \
     --header "Accept: application/json" \
     --header "Content-Type: application/json" \
     --data '{"query_string":"SELECT * FROM mytable LIMIT 10;", "database_name":"GettingStarted/MyDatabase"}'

You can pipe the output of the above command to jq to optionally add JSON output formatting, as shown below:

650650

❗️

Only one postgres command per query is supported

Did you received cannot insert multiple commands into a prepared statement? Only one command (i.e., one ;) is allowed per query submitted via the API.


Did this page help you?