src/api/v4/client.js
function Client (settings) {
  settings.serverUrl = (settings.serverUrl || DEFAULT_SERVER_URL).replace(/{username}/, settings.username || '');
  _checkSettings(settings);
  this._layers = new Layers();
  this._dataviews = [];
  this._engine = new Engine({
    apiKey: settings.apiKey,
    username: settings.username,
    serverUrl: settings.serverUrl,
    client: 'js-' + VERSION
  });
  this._bindEngine(this._engine);
}
function Client (settings) {
  settings.serverUrl = (settings.serverUrl || DEFAULT_SERVER_URL).replace(/{username}/, settings.username || '');
  _checkSettings(settings);
  this._layers = new Layers();
  this._dataviews = [];
  this._engine = new Engine({
    apiKey: settings.apiKey,
    username: settings.username,
    serverUrl: settings.serverUrl,
    client: 'js-' + VERSION
  });
  this._bindEngine(this._engine);
}
function Client ( settings ) { settings . serverUrl = ( settings . serverUrl || DEFAULT_SERVER_URL ) . replace ( / {username} / , settings . username || '' ) ; _checkSettings ( settings ) ; this . _layers = new Layers ( ) ; this . _dataviews = [ ] ; this . _engine = new Engine ( { apiKey : settings . apiKey , username : settings . username , serverUrl : settings . serverUrl , client : 'js-' + VERSION } ) ; this . _bindEngine ( this . _engine ) ; }
This is the entry point for a CARTO.js application.

A CARTO client allows managing layers and dataviews. Some operations like addding a layer or a dataview are asynchronous.
The client takes care of the communication between CARTO.js and the server for you.

To create a new client you need a CARTO account, where you will be able to get
your API key and username.

If you want to learn more about authorization and authentication, please read the authorization fundamentals section of our Developer Center.

@param {object} settings
@param {string} settings.apiKey - API key used to authenticate against CARTO
@param {string} settings.username - Name of the user
@param {string} [settings.serverUrl='https://{username}.carto.com'] - URL of the windshaft server. Only needed in custom installations. Pattern: `http(s)://{username}.your.carto.instance` or `http(s)://your.carto.instance/user/{username}` (only for On-Premises environments).

@example
var client = new carto.Client({
apiKey: 'YOUR_API_KEY_HERE',
username: 'YOUR_USERNAME_HERE'
});

var client = new carto.Client({
apiKey: 'YOUR_API_KEY_HERE',
username: 'YOUR_USERNAME_HERE',
serverUrl: 'http://{username}.your.carto.instance'
});

@constructor
@memberof carto
@api

@fires error
@fires success
This is the entry point for a CARTO . js application .