NOTE: You are looking at documentation for an older release. For the latest information, see the current release documentation.
Basic authentication
editBasic authentication
editYou can provide your credentials by passing the username
and password
parameters via the auth
option.
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: { username: 'elastic', password: 'changeme' } })
Otherwise, you can provide your credentials in the node(s) URL.
const { Client } = require('@elastic/elasticsearch') const client = new Client({ node: 'https://username:password@localhost:9200' })