I’ve been following the tutorials available here which show you have to set up a database in carto 2 and query it using sql requests. It seems simple enough to build a url that deal with the desired query.

Unfortunately carto2 has now changed to carto workplace (carto3), https://carto.com/ and whilst there still seems to be a carto api the documentation is complicated, with references to connections, access tokens ect. In spite of two attempts I’ve not been able to get my old sql queries running again.

Obviously I’m a beginner with post GIS but is someone with more experience able to tell me whether the simple functionality of carto2 is gone? you used to be able to simply upload a geojson database and easily query it with sql.

For example the below code used to pull a list of plans from a database in carto2

    let carto_user = "michaeldorman";
    let url = "https://" + carto_user+.carto.com/api/v2/sql?format=GeoJSON&q=";
    let sqlQuery = "SELECT name_lat, the_geom FROM plants LIMIT 25";
    fetch(url + sqlQuery)
        .then(function(response) {
            return response.json();
        .then(function(data) {
            L.geoJSON(data, {
                onEachFeature: function(feature, layer) {

And should replaced in carto 3 by something like the following?:

    var requestOptions = {
      method: 'GET',
      redirect: 'follow'
    fetch("https://gcp-us-east1.api.carto.com/v3/sql/carto_dw/query?q=select * from carto-dw-ac-qesubrab.shared.plants ", requestOptions)
      .then(response => response.text())
      .then(result => console.log(result))
      .catch(error => console.log('error', error));

The issue seems to be that the new code doesn’t define the user name and generates an error relating to a token:


    “{"error":"Token not defined!","status":401,"message":"Token not defined!","originalError":{}“

Is there really no way to just upload the data and start doing sql queries on it anymore?

1 Answer 1


CARTO Dashboard (a.k.a CARTO 2) is still available! When logging in you choose where to go:

CARTO Log in

The new CARTO platform offers a 7 days trial period. Although the new platform is the future of CARTO and is already putting some advantages to the previous one, it has been public for just 3 months and not all the functionality has been migrated yet (January 2022).

The tutorial you are mentioning uses the classic CARTO account and methods, so I recommend you to use the CARTO Dashboard option to follow the tutorials without too much trouble.

The official documentation for CARTO Dashboard can be found at: https://carto.com/help/tutorials/your-dashboard-overview/

Have you tried CARTOframes? It's much easier to build a seamless workflow between CARTO and your Python code with this library, without the overhead of using HTTP requests, a RESTful API and all of that. Have a look a it here: https://carto.com/developers/cartoframes/reference/

  • I think your answer is useful however a new account registered since oct 2021 does not let you log into carto2 (carto dashboard). This is problem a for me. I have not looked at Cartoframe and it is good of you to recommend that but I’m confused why you are talking about python code? I was making a web map in html / java script. My understanding is that python is a totally separate coding language.
    – williamh
    Commented Feb 23, 2022 at 11:38
  • Hi @williamh, I'm sorry that my answer wasn't helpful for you. Also, sorry if I confused you, I didn't know your context/background, so I proposed an alternative by using CARTOframes, but that requires Python as you have already guessed. I will try to edit my answer focussing on CARTO 3. Commented Feb 24, 2022 at 9:32
  • I think it is helpful, I did upvote it and I’m sure your suggestion of CARTOframes is sensible however with my lack of experience in this area, I’ve only just learned HTML & JS and having built a solution that works I’ve now run into an issue due to the carto changes. Its frustrating that the solution seems to be learn a new coding language and start again from scratch. I appreciate that to someone who already knows python your suggestion would be easy to implement. I think I will just use my existing carto2 account for now. Always grateful for the response.
    – williamh
    Commented Feb 25, 2022 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.