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).

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:


Did this page help you?