[[extending_core_components]]
== Extending
We decided to make this client low-level, and as such we probably have not implemented all the features you are looking for. For this reason, we made extending or even replacing the core components simple.

Check out the <<extensions>> page for a list of known extensions.

=== Connection
Extending a connection provides the powerful ability to change requests as they go out to the ElasticSearch REST API.

For example, you can extend the `HttpConnector` to force the default HTTP method to be `POST`:
[source,js]
---------------
var elasticsearch = require('elasticsearch');
var util = require('util');
var HttpConnector = require('elasticsearch/src/lib/connectors/http');

function MyHttpConnector(host, config) {
  HttpConnector.call(this, host, config);
}
util.inherits(MyHttpConnector, HttpConnector);
MyHttpConnector.prototype.makeReqParams = function(params) {
  params = params || {};
  params.method = params.method || 'POST';
  return HttpConnector.prototype.makeReqParams.call(this, params);
};

var client = new elasticsearch.Client({
  connectionClass: MyHttpConnector
});
---------------

=== Log
see <<logging>>.

=== Client/API
Extending or replacing the API that Elasticsearch.js provides is a simple as it should be in JS. To provide an entirely new API, just add it to the Client constructor's `api` property like so:

[source,js]
--------------
var myApi = {
  getDog: function () { ... }
};

elasticsearch.Client.apis.mine = myApi;

var client = new elasticsearch.Client({
  apiVersion: 'mine'
});

client.getDog( ... );
--------------

When the client is created, its prototype is set to the API version selected, and therefore you can access the client via the `this` variable within your API methods. Make requests within your methods using `this.transport.request(params, cb)`. For more information about the transport, see <<transport-reference>>.
