- JavaScript Client: other versions:
- Introduction
- Usage
- Client configuration
- API Reference
- Common parameters
- bulk
- cat.aliases
- cat.allocation
- cat.count
- cat.fielddata
- cat.health
- cat.help
- cat.indices
- cat.master
- cat.nodeattrs
- cat.nodes
- cat.pendingTasks
- cat.plugins
- cat.recovery
- cat.repositories
- cat.segments
- cat.shards
- cat.snapshots
- cat.tasks
- cat.templates
- cat.threadPool
- clearScroll
- cluster.allocationExplain
- cluster.getSettings
- cluster.health
- cluster.pendingTasks
- cluster.putSettings
- cluster.remoteInfo
- cluster.reroute
- cluster.state
- cluster.stats
- count
- create
- delete
- deleteByQuery
- deleteByQueryRethrottle
- deleteScript
- exists
- existsSource
- explain
- fieldCaps
- get
- getScript
- getSource
- index
- indices.analyze
- indices.clearCache
- indices.close
- indices.create
- indices.delete
- indices.deleteAlias
- indices.deleteTemplate
- indices.exists
- indices.existsAlias
- indices.existsTemplate
- indices.existsType
- indices.flush
- indices.flushSynced
- indices.forcemerge
- indices.get
- indices.getAlias
- indices.getFieldMapping
- indices.getMapping
- indices.getSettings
- indices.getTemplate
- indices.getUpgrade
- indices.open
- indices.putAlias
- indices.putMapping
- indices.putSettings
- indices.putTemplate
- indices.recovery
- indices.refresh
- indices.rollover
- indices.segments
- indices.shardStores
- indices.shrink
- indices.split
- indices.stats
- indices.updateAliases
- indices.upgrade
- indices.validateQuery
- info
- ingest.deletePipeline
- ingest.getPipeline
- ingest.processorGrok
- ingest.putPipeline
- ingest.simulate
- mget
- msearch
- msearchTemplate
- mtermvectors
- nodes.hotThreads
- nodes.info
- nodes.reloadSecureSettings
- nodes.stats
- nodes.usage
- ping
- putScript
- rankEval
- reindex
- reindexRethrottle
- renderSearchTemplate
- scriptsPainlessExecute
- scroll
- search
- searchShards
- searchTemplate
- snapshot.create
- snapshot.createRepository
- snapshot.delete
- snapshot.deleteRepository
- snapshot.get
- snapshot.getRepository
- snapshot.restore
- snapshot.status
- snapshot.verifyRepository
- tasks.cancel
- tasks.get
- tasks.list
- termvectors
- update
- updateByQuery
- updateByQueryRethrottle
- ccr.deleteAutoFollowPattern
- ccr.follow
- ccr.followInfo
- ccr.followStats
- ccr.forgetFollower
- ccr.getAutoFollowPattern
- ccr.pauseFollow
- ccr.putAutoFollowPattern
- ccr.resumeFollow
- ccr.stats
- ccr.unfollow
- ilm.deleteLifecycle
- ilm.explainLifecycle
- ilm.getLifecycle
- ilm.getStatus
- ilm.moveToStep
- ilm.putLifecycle
- ilm.removePolicy
- ilm.retry
- ilm.start
- ilm.stop
- indices.freeze
- indices.unfreeze
- security.createApiKey
- security.getApiKey
- security.invalidateApiKey
- xpack.graph.explore
- xpack.info
- xpack.license.delete
- xpack.license.get
- xpack.license.getBasicStatus
- xpack.license.getTrialStatus
- xpack.license.post
- xpack.license.postStartBasic
- xpack.license.postStartTrial
- xpack.migration.deprecations
- xpack.migration.getAssistance
- xpack.migration.upgrade
- xpack.ml.closeJob
- xpack.ml.deleteCalendar
- xpack.ml.deleteCalendarEvent
- xpack.ml.deleteCalendarJob
- xpack.ml.deleteDatafeed
- xpack.ml.deleteExpiredData
- xpack.ml.deleteFilter
- xpack.ml.deleteForecast
- xpack.ml.deleteJob
- xpack.ml.deleteModelSnapshot
- xpack.ml.findFileStructure
- xpack.ml.flushJob
- xpack.ml.forecast
- xpack.ml.getBuckets
- xpack.ml.getCalendarEvents
- xpack.ml.getCalendars
- xpack.ml.getCategories
- xpack.ml.getDatafeedStats
- xpack.ml.getDatafeeds
- xpack.ml.getFilters
- xpack.ml.getInfluencers
- xpack.ml.getJobStats
- xpack.ml.getJobs
- xpack.ml.getModelSnapshots
- xpack.ml.getOverallBuckets
- xpack.ml.getRecords
- xpack.ml.info
- xpack.ml.openJob
- xpack.ml.postCalendarEvents
- xpack.ml.postData
- xpack.ml.previewDatafeed
- xpack.ml.putCalendar
- xpack.ml.putCalendarJob
- xpack.ml.putDatafeed
- xpack.ml.putFilter
- xpack.ml.putJob
- xpack.ml.revertModelSnapshot
- xpack.ml.setUpgradeMode
- xpack.ml.startDatafeed
- xpack.ml.stopDatafeed
- xpack.ml.updateDatafeed
- xpack.ml.updateFilter
- xpack.ml.updateJob
- xpack.ml.updateModelSnapshot
- xpack.ml.validate
- xpack.ml.validateDetector
- xpack.monitoring.bulk
- xpack.rollup.deleteJob
- xpack.rollup.getJobs
- xpack.rollup.getRollupCaps
- xpack.rollup.getRollupIndexCaps
- xpack.rollup.putJob
- xpack.rollup.rollupSearch
- xpack.rollup.startJob
- xpack.rollup.stopJob
- xpack.security.authenticate
- xpack.security.changePassword
- xpack.security.clearCachedRealms
- xpack.security.clearCachedRoles
- xpack.security.deletePrivileges
- xpack.security.deleteRole
- xpack.security.deleteRoleMapping
- xpack.security.deleteUser
- xpack.security.disableUser
- xpack.security.enableUser
- xpack.security.getPrivileges
- xpack.security.getRole
- xpack.security.getRoleMapping
- xpack.security.getToken
- xpack.security.getUser
- xpack.security.getUserPrivileges
- xpack.security.hasPrivileges
- xpack.security.invalidateToken
- xpack.security.putPrivileges
- xpack.security.putRole
- xpack.security.putRoleMapping
- xpack.security.putUser
- xpack.sql.clearCursor
- xpack.sql.query
- xpack.sql.translate
- xpack.ssl.certificates
- xpack.usage
- xpack.watcher.ackWatch
- xpack.watcher.activateWatch
- xpack.watcher.deactivateWatch
- xpack.watcher.deleteWatch
- xpack.watcher.executeWatch
- xpack.watcher.getWatch
- xpack.watcher.putWatch
- xpack.watcher.restart
- xpack.watcher.start
- xpack.watcher.stats
- xpack.watcher.stop
- Breaking changes coming from the old client
- Authentication
- Observability
- Creating a child client
- Extend the client
- TypeScript support
- Examples
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' } } })
ElasticON events are back!
Learn about the Elastic Search AI Platform from the experts at our live events.
Register nowWas this helpful?
Thank you for your feedback.