For this example (and the rest of the ones illustrated in this document) we will be using a command-line tool known as
cURL. For more info about this tool see this blog post or type
man curl in bash.
Uploading a Local File
Suppose you have a CARTO account whose username is documentation, and you want to upload a local file named prism_tour.csv (located in the Documents folder). This requires that you execute the following command on a Terminal window:
Note that the api_key element has an alphanumeric value that is exclusive to the documentation CARTO account.
The response to this request appears in the following format, where a successful value indicates that the import process is enqueued:
item_queue_id value is a unique identifier that references the import process. Once this process has started, its information can be obtained doing a request to the imports endpoint as explained in the “Check the status of an import process section.
Uploading from a Remote URL
Suppose you have a server at the hostname examplehost.com, with a csv named sample.csv already uploaded. Creating a table from the URL requires that you execute the following command on a Terminal window:
The response to this request returns the following format, returning a success value if the import process is correctly enqueued:
Connecting to a Database
Suppose you have an external MySQL database named mydb that you want to connect to. For the purpose of this example, you will access a server with the address of mydbserver.com. Your username is myuser, and your password is mypass. Connect a CARTO dataset to a remote table, named mytable, by executing the following command on a Terminal window:
For details, see Database Connectors.