Interact with your tables and data inside CARTO, as if you were running SQL statements.

This component is still under support but it will not be further developed. We don’t recommend starting new projects with it as it will eventually become deprecated. Instead, learn more about our new APIs here

What is SQL API?

CARTO’s SQL API allows you to interact with your tables and data inside CARTO, as if you were running SQL statements against a normal database.

You can use the SQL API to insert, update or delete data, or to select data from public tables in order to use it on your website or application. To understand the fundamentals of SQL API, read the guides. To view the source code, browse the open-source repository in GitHub and contribute. Otherwise, read the full reference API, or find different support options.

Guides

Quick reference guides for learning how to use SQL API features.

Reference

Browse the interactive API documentation to search for specific SQL API methods, arguments, and sample code that can be used to build your applications.

Check Full Reference API
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Single SQL Statement
curl -X GET \
https://username.carto.com/api/v2/sql?q=SELECT count(*) FROM cities

# SQL Statement
curl -X POST -H "Content-Type: application/json" -d '{ \
  "q": "SELECT count(*) FROM cities", \
  "filename": "number_of_cities.json" \
}' "https://username.carto.com/api/v2/sql"

# Batch Queries
curl -X POST -H "Content-Type: application/json" -d '{ \
  "query": "UPDATE nasdaq SET price = '$101.00' WHERE company = 'CARTO'", \
}' "https://username.carto.com/api/v2/sql/job"

Support

Get help or learn about known issues.