To use the CARTO.js library, you must register your project in your CARTO account and get an API key which you can add to your app or website.
Start creating your API key, registering a project in the CARTO Platform.
Notes:
For more information, see the fundamentals about authorization.
After loading the CARTO.js library, substitute YOUR_API_KEY in the code below with the API key you got from the previous step.
1
2
3
4
var client = new carto.Client({
apiKey: '{YOUR_API_KEY}',
username: '{username}'
});
You can get your username following these steps:
The API key allows you to control your applications in the CARTO Platform.
If you are a Trial Plan customer, with an API key you have access to all the Engine features.
If you are an Engine Plan customer, you must use an API key to access all the custom features and benefits of your Engine Plan.
Follow these steps to get an API key:
For more information on using the CARTO Platform, see our fundamentals.
If your API key is malformed or you supply an invalid username, the CARTO.js library returns an HTTP 403 (Forbidden) error.
CARTO Enterprise customers have access to enterprise-level support through CARTO’s support representatives available at enterprise-support@carto.com.