Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
50 lines (43 sloc) 1.2 KB

ElasticSearch Clients

In order to use a default ElasticSearch client, you can provide the following parameters:

  • server: https://api.eth.events/es/
  • index: ethereum-ethereum-mainnet-block
  • type: block
  • username: your email address
  • password: your API key

The following example shows how to fetch the latest 5 DAI transfers from ElasticSearch in Node.js

const Client = require('elasticsearch').Client

const esClient = new Client({
  hosts: 'https://api.eth.events/es/',
  httpAuth: 'your-email-address:your-api-key',
})

esClient.search({
  index: 'ethereum-ethereum-mainnet-event',
  type: 'event',
  body: {
    query: {
      bool: {
        filter: [
          {
            term: {
              'address.raw': '0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359'
            }
          },
          {
            term: {
              'event.raw': 'Transfer'
            }
          }
        ]
      }
    },
    sort: {
      timestamp: 'desc'
    },
    size: 5
  }
})
.then(result => console.log(require('util').inspect(result, { depth: null })))
.catch(err => console.error(err))
You can’t perform that action at this time.