Connecting via the API

The bit.io developer API

bit.io has a RESTful API that makes it easy to programmatically interact with your databases. Using the API, you can create new databases, look up metadata about your database, import data, run queries, and more. See here for a full list of API endpoints and their associated documentation.

Using curl to interact with the developer API

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

First, grab your API key from the bit.io bit.io Connect Tab

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 put your API key in the Authorization header as shown below in order to query using the AP

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"}'

All API endpoints return JSON data, so you may find it useful to pipe the output of your API calls to jq to format them.

In the below example, we check the metadata of a database, upload a file to it to create a new table, and then query some data from the table.

asciicast