Skip to content

Instantly share code, notes, and snippets.

@Xatpy
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xatpy/7ffdbf6ad1f17bf57d20 to your computer and use it in GitHub Desktop.
Save Xatpy/7ffdbf6ad1f17bf57d20 to your computer and use it in GitHub Desktop.
[Tutorial] How to use Import API without guessing

How to use CartoDB Import API without guessing

Documentation URL

  1. Using MacOSX.

  2. Open your browser and log in your CartoDB account.

  3. Get your API key:

2a) Click on your "user-->Your API keys" option. (Up-right section)

2b) Copy your api key (you can click on the icon).

  1. Open your terminal (bash).

  2. We are going to use cURL and this command:

curl -F file=@/path/file.csv "https://{{account}}.cartodb.com/api/v1/imports/?api_key={{api_key}}&type_guessing=false"

4a) Get the path file you want to upload and replace it in the last command. Example: file=@/Users/jaimechapinal/workspace/datasets/test_import_2.csv

4b) Replace your name account in {{account}} section. Example: https://xatpy.cartodb.com/

4c) Replace your API key (you got it in the second step). Example (please, note it is a fake id): api_key=ab444afbbbb11165b237c3a4c37fadbb7fddc111

4d) Final example:

curl -F file=@/Users/jaimechapinal/workspace/datasets/test_import_2.csv "https://xatpy.cartodb.com/api/v1/imports/?api_key=ab444afbbbb11165b237c3a4c37fadbb7fddc111&type_guessing=false"

  1. Press Enter.

  2. If it was OK, you'll see the following message in your console (with another id):

{"item_queue_id":"74872d0b-13e5-4b5b-812b-ae1770260d78","success":true}%

  1. Now you can check in your dashboard that you have your data without guessing (so all fields are strings).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment