NOTE: You are looking at documentation for an older release. For the latest information, see the current release documentation.
ApiKey authentication
editApiKey authentication
editYou can use the ApiKey authentication by passing the apiKey
parameter via the auth
option.
The apiKey
parameter can be either a base64 encoded string or an object with the values that you can obtain from the create api key endpoint.
If you provide both basic authentication credentials and the Api Key configuration, the Api Key will take precedence.
const { Client } = require('@elastic/elasticsearch') const client = new Client({ node: 'https://localhost:9200', auth: { apiKey: 'base64EncodedKey' } })
const { Client } = require('@elastic/elasticsearch') const client = new Client({ node: 'https://localhost:9200', auth: { apiKey: { id: 'foo', api_key: 'bar' } } })