updated all api examples with rebranded account url- confirmed by luis

This commit is contained in:
csobier 2016-07-04 17:42:18 -04:00
parent 1e8412edb1
commit 8e677e0407
6 changed files with 31 additions and 31 deletions

View File

@ -13,5 +13,5 @@ To use your API Key, pass it as a parameter in an URL call to the CARTO API. For
#### Example
```bash
https://{username}.cartodb.com/api/v2/sql?q={SQL statement}&api_key={api_key}
https://{username}.carto.com/api/v2/sql?q={SQL statement}&api_key={api_key}
```

View File

@ -9,7 +9,7 @@ The first is to use the format=GeoJSON method described above. Others can be han
#### Call
```bash
https://{username}.cartodb.com/api/v2/sql?q=SELECT cartodb_id,ST_AsGeoJSON(the_geom) as the_geom FROM {table_name} LIMIT 1
https://{username}.carto.com/api/v2/sql?q=SELECT cartodb_id,ST_AsGeoJSON(the_geom) as the_geom FROM {table_name} LIMIT 1
```
#### Result
@ -32,7 +32,7 @@ https://{username}.cartodb.com/api/v2/sql?q=SELECT cartodb_id,ST_AsGeoJSON(the_g
#### Call
```bash
https://{username}.cartodb.com/api/v2/sql?q=SELECT cartodb_id,ST_AsText(the_geom) FROM {table_name} LIMIT 1
https://{username}.carto.com/api/v2/sql?q=SELECT cartodb_id,ST_AsText(the_geom) FROM {table_name} LIMIT 1
```
#### Result
@ -57,7 +57,7 @@ All data returned from *the_geom* column is in WGS 84 (EPSG:4326). You can chang
### ST_Transform
```bash
https://{username}.cartodb.com/api/v2/sql?q=SELECT ST_Transform(the_geom,4147) FROM {table_name} LIMIT 1
https://{username}.carto.com/api/v2/sql?q=SELECT ST_Transform(the_geom,4147) FROM {table_name} LIMIT 1
```
CARTO also stores a second geometry column, *the_geom_webmercator*. We use this internally to build your map tiles as fast as we can. In the user-interface it is hidden, but it is visible and available for use. In this column, we store a reprojected version of all your geometries using Web Mercator (EPSG:3857).

View File

@ -12,7 +12,7 @@ All SQL API requests to your CARTO account should follow this general pattern:
#### SQL query example
```bash
https://{username}.cartodb.com/api/v2/sql?q={SQL statement}
https://{username}.carto.com/api/v2/sql?q={SQL statement}
```
If you encounter errors, double-check that you are using the correct account name, and that your SQL statement is valid. A simple example of this pattern is conducting a count of all the records in your table:
@ -20,7 +20,7 @@ If you encounter errors, double-check that you are using the correct account nam
#### Count example
```bash
https://{username}.cartodb.com/api/v2/sql?q=SELECT count(*) FROM {table_name}
https://{username}.carto.com/api/v2/sql?q=SELECT count(*) FROM {table_name}
```
#### Result
@ -49,7 +49,7 @@ The CARTO SQL API is setup to handle both GET and POST requests. You can test th
#### Call
```javascript
$.getJSON('https://{username}.cartodb.com/api/v2/sql/?q='+sql_statement, function(data) {
$.getJSON('https://{username}.carto.com/api/v2/sql/?q='+sql_statement, function(data) {
$.each(data.rows, function(key, val) {
// do something!
});
@ -68,7 +68,7 @@ The standard response from the CARTO SQL API is JSON. If you are building a web-
#### Call
```bash
https://{username}.cartodb.com/api/v2/sql?q=SELECT * FROM {table_name} LIMIT 1
https://{username}.carto.com/api/v2/sql?q=SELECT * FROM {table_name} LIMIT 1
```
#### Result
@ -97,7 +97,7 @@ Alternatively, you can use the [GeoJSON specification](http://www.geojson.org/ge
#### Call
```bash
https://{username}.cartodb.com/api/v2/sql?format=GeoJSON&q=SELECT * FROM {table_name} LIMIT 1
https://{username}.carto.com/api/v2/sql?format=GeoJSON&q=SELECT * FROM {table_name} LIMIT 1
```
#### Result
@ -136,7 +136,7 @@ To customize the output filename, add the `filename` parameter to your URL:
#### Call
```bash
https://{username}.cartodb.com/api/v2/sql?filename={custom_filename}&q=SELECT * FROM {table_name} LIMIT 1
https://{username}.carto.com/api/v2/sql?filename={custom_filename}&q=SELECT * FROM {table_name} LIMIT 1
```
@ -147,7 +147,7 @@ Currently, there is no public method to access your table schemas. The simplest
#### Call
```bash
https://{username}.cartodb.com/api/v2/sql?q=SELECT * FROM {table_name} LIMIT 1
https://{username}.carto.com/api/v2/sql?q=SELECT * FROM {table_name} LIMIT 1
```
@ -176,7 +176,7 @@ Performing inserts or updates on your data is simple using your [API Key](#authe
#### Call
```bash
https://{username}.cartodb.com/api/v2/sql?q=INSERT INTO test_table (column_name, column_name_2, the_geom) VALUES ('this is a string', 11, ST_SetSRID(ST_Point(-110, 43),4326))&api_key={api_key}
https://{username}.carto.com/api/v2/sql?q=INSERT INTO test_table (column_name, column_name_2, the_geom) VALUES ('this is a string', 11, ST_SetSRID(ST_Point(-110, 43),4326))&api_key={api_key}
```
Updates are just as simple. Here is an example of updating a row based on the value of the cartodb_id column.
@ -186,5 +186,5 @@ Updates are just as simple. Here is an example of updating a row based on the va
#### Call
```bash
https://{username}.cartodb.com/api/v2/sql?q=UPDATE test_table SET column_name = 'my new string value' WHERE cartodb_id = 1 &api_key={api_key}
https://{username}.carto.com/api/v2/sql?q=UPDATE test_table SET column_name = 'my new string value' WHERE cartodb_id = 1 &api_key={api_key}
```

View File

@ -5,4 +5,4 @@ There are some tricks to consider when using the SQL API that might make your ap
* Only request the fields you need. Selecting all columns will return a full version of your geometry in *the_geom*, as well as a reprojected version in *the_geom_webmercator*.
* Use PostGIS functions to simplify and filter out unneeded geometries when possible. One very handy function is, [ST_Simplify](http://www.postgis.org/docs/ST_Simplify.html).
* Remember to build indexes that will speed up some of your more common queries. For details, see [Creating Indexes](http://docs.carto.com/carto-editor/managing-your-data/#creating-indexes)
* Use *cartodb_id* to retrieve specific rows of your data, this is the unique key column added to every CARTO table. For a sample use case, view the [_Faster data updates with Carto_](https://blog.carto.com/faster-data-updates-with-cartodb/) blogpost.
* Use *cartodb_id* to retrieve specific rows of your data, this is the unique key column added to every CARTO table. For a sample use case, view the [_Faster data updates with Carto_](https://blog.carto.com/faster-data-updates-with-carto/) blogpost.

View File

@ -75,7 +75,7 @@ If you are using the Batch API create operation for cURL POST request, use the f
```bash
curl -X POST -H "Content-Type: application/json" -d '{
"query": "CREATE TABLE world_airports AS SELECT a.cartodb_id, a.the_geom, a.the_geom_webmercator, a.name airport, b.name country FROM world_borders b JOIN airports a ON ST_Contains(b.the_geom, a.the_geom)"
}' "http://{username}.cartodb.com/api/v2/sql/job"
}' "http://{username}.carto.com/api/v2/sql/job"
```
If you are using the Batch API create operation for a Node.js client POST request, use the following code:
@ -85,7 +85,7 @@ var request = require("request");
var options = {
method: "POST",
url: "http://{username}.cartodb.com/api/v2/sql/job",
url: "http://{username}.carto.com/api/v2/sql/job",
headers: { "content-type": "application/json" },
body: {
query: "CREATE TABLE world_airports AS SELECT a.cartodb_id, a.the_geom, a.the_geom_webmercator, a.name airport, b.name country FROM world_borders b JOIN airports a ON ST_Contains(b.the_geom, a.the_geom)"
@ -128,7 +128,7 @@ BODY: {
If you are using the Batch API read operation for cURL GET request, use the following code:
```bash
curl -X GET "http://{username}.cartodb.com/api/v2/sql/job/{job_id}"
curl -X GET "http://{username}.carto.com/api/v2/sql/job/{job_id}"
```
If you are using the Batch API read operation for a Node.js client GET request, use the following code:
@ -138,7 +138,7 @@ var request = require("request");
var options = {
method: "GET",
url: "http://{username}.cartodb.com/api/v2/sql/job/{job_id}"
url: "http://{username}.carto.com/api/v2/sql/job/{job_id}"
};
request(options, function (error, response, body) {
@ -183,7 +183,7 @@ BODY: [{
If you are using the Batch API list operation for cURL GET request, use the following code:
```bash
curl -X GET "http://{username}.cartodb.com/api/v2/sql/job"
curl -X GET "http://{username}.carto.com/api/v2/sql/job"
```
If you are using the Batch API list operation for a Node.js client GET request, use the following code:
@ -193,7 +193,7 @@ var request = require("request");
var options = {
method: "GET",
url: "http://{username}.cartodb.com/api/v2/sql/job"
url: "http://{username}.carto.com/api/v2/sql/job"
};
request(options, function (error, response, body) {
@ -243,7 +243,7 @@ If you are using the Batch API update operation for cURL PUT request, use the fo
```bash
curl -X PUT -H "Content-Type: application/json" -d '{
"query": "UPDATE airports SET type = 'military'"
}' "http://{username}.cartodb.com/api/v2/sql/job/{job_id}"
}' "http://{username}.carto.com/api/v2/sql/job/{job_id}"
```
If you are using the Batch API update operation for a Node.js client PUT request, use the following code:
@ -253,7 +253,7 @@ var request = require("request");
var options = {
method: "PUT",
url: "http://{username}.cartodb.com/api/v2/sql/job/{job_id}",
url: "http://{username}.carto.com/api/v2/sql/job/{job_id}",
headers: {
"content-type": "application/json"
},
@ -309,7 +309,7 @@ errors: [
If you are using the Batch API cancel operation for cURL DELETE request, use the following code:
```bash
curl -X DELETE "http://{username}.cartodb.com/api/v2/sql/job/{job_id}"
curl -X DELETE "http://{username}.carto.com/api/v2/sql/job/{job_id}"
```
If you are using the Batch API cancel operation for a Node.js client DELETE request, use the following code:
@ -319,7 +319,7 @@ var request = require("request");
var options = {
method: "DELETE",
url: "http://{username}.cartodb.com/api/v2/sql/job/{job_id}",
url: "http://{username}.carto.com/api/v2/sql/job/{job_id}",
};
request(options, function (error, response, body) {
@ -386,7 +386,7 @@ curl -X POST -H "Content-Type: application/json" -d '{
"DROP TABLE airports",
"ALTER TABLE world_airports RENAME TO airport"
]
}' "http://{username}.cartodb.com/api/v2/sql/job"
}' "http://{username}.carto.com/api/v2/sql/job"
```
If you are using the Batch API Multi Query operation for a Node.js client POST request, use the following code:
@ -396,7 +396,7 @@ var request = require("request");
var options = {
method: "POST",
url: "http://{username}.cartodb.com/api/v2/sql/job",
url: "http://{username}.carto.com/api/v2/sql/job",
headers: { "content-type": "application/json" },
body: {
"query": [
@ -427,7 +427,7 @@ curl -X PUT -H "Content-Type: application/json" -d '{
"ALTER TABLE world_airports RENAME TO airport",
"UPDATE airports SET airport = upper(airport)"
]
}' "http://{username}.cartodb.com/api/v2/sql/job/{job_id}"
}' "http://{username}.carto.com/api/v2/sql/job/{job_id}"
```
If you are using the Batch API Multi Query operation for a Node.js client PUT request, use the following code:
@ -437,7 +437,7 @@ var request = require("request");
var options = {
method: "PUT",
url: "http://{username}.cartodb.com/api/v2/sql/job/{job_id}",
url: "http://{username}.carto.com/api/v2/sql/job/{job_id}",
headers: { "content-type": "application/json" },
body: {
query: [
@ -488,7 +488,7 @@ Using cURL tool:
```bash
curl -X POST -H "Content-Type: application/json" -d '{
"query": "{query}"
}' "http://{username}.cartodb.com/api/v2/sql/job?api_key={api_key}"
}' "http://{username}.carto.com/api/v2/sql/job?api_key={api_key}"
```
Using Node.js request client:
@ -498,7 +498,7 @@ var request = require("request");
var options = {
method: "POST",
url: "http://{username}.cartodb.com/api/v2/sql/job",
url: "http://{username}.carto.com/api/v2/sql/job",
qs: {
"api_key": "{api_key}"
},

View File

@ -1,3 +1,3 @@
# API Version Number
All CARTO applications use **Version 2** of our APIs. All other APIs are deprecated and will not be maintained or supported. You can check that you are using **Version 2** of our APIs by looking at your request URLS. They should all begin containing **/v2/** in the URLs as follows, `https://{username}.cartodb.com/api/v2/`
All CARTO applications use **Version 2** of our APIs. All other APIs are deprecated and will not be maintained or supported. You can check that you are using **Version 2** of our APIs by looking at your request URLS. They should all begin containing **/v2/** in the URLs as follows, `https://{username}.carto.com/api/v2/`