I am developing a web application that dynamically creates tables of data on CartoDB. Once I've uploaded some data, I'd like to show a cluster of points from that data. The uploaded data has a the_geom field of datatype geometry with well-identified data (eg, ST_SetSRID(ST_Point(37.878086,-122.51026),4326))

So, given that I get a table name back from a successful create/write (eg, t62b61b0091e633029be9332b5f20bf74_6d6d454828c05e8ceea03c99cc5f5), I'd like to grab the viz.json identifier (eg, 2b13c956-e7c1-11e2-806b-5404a6a683d5, or even the full https://myCartoAccount.cartodb.com/api/v2/viz/2b13c956-e7c1-11e2-806b-5404a6a683d5/viz.json) somehow, programmatically.

I can't seem to find the way to do this, nor references to it on the documentation.



viz.json files are related with Maps (visualizations) but not with tables (datasets).

The Import API will allow you to import a table and automatically create a Map from it (setting the create_vis parameter of the import request as true), and you will receive as a response the name of your new uploaded table as well as the visualization id which you can build to construct your viz.json URL as follows:


Here's a request example to upload a new table from a URL:

curl -v -H "Content-Type: application/json" -d '{"url":"URL", "create_vis": true}' 

The response of this request will give you "item_queue_id", which you can use in the next request.

This is the request to obtain the data of the result:

curl -v "https://USERNAME.cartodb.com/api/v1/imports/ITEM_QUEUE_ID?api_key=API_KEY"

And this will be an example of the response, where in the structure you can find the visualization ID that you need for your viz.json:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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