# Kibaba Plugin - how to insert data into elasticsearch

**URL:** <https://discuss.elastic.co/t/kibaba-plugin-how-to-insert-data-into-elasticsearch/280374>\
**Category:** Kibana\
**Tags:** kibana-plugin-development\
**Created:** [August 4, 2021, 12:34am UTC](https://discuss.elastic.co/t/kibaba-plugin-how-to-insert-data-into-elasticsearch/280374 "2021-08-04T00:34:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hoai\_Le](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hoai_le/32/91610_2.png) [@Hoai\_Le](https://discuss.elastic.co/u/Hoai_Le)\
**Post date:** [August 4, 2021, 12:34am UTC](https://discuss.elastic.co/t/kibaba-plugin-how-to-insert-data-into-elasticsearch/280374/1 "2021-08-04T00:34:07Z")

</div>

let say I have a plugin with route:

```auto
router.post(
    {
      path: '/api/dashboard_real_time/create',
      validate: {
        body: schema.object({
          fullName: schema.string(),
          age: schema.number(),
          status: schema.number()
        })
      },
    },
    async (context, request, response) => {
      // then i wanna insert some data into elasticsearch here
      return response.ok({
        body: {
          time: new Date().toISOString(),
        },
      });
    }
  );

```

I am confused to use the kibana elastic search service or data plugin or elasticsearchjs (which i have to config authentication manually).  
Please give me some sample code. Thank alot!

---

<div class="post-metadata">

**Author:** ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)\
**Post date:** [August 4, 2021, 11:40pm UTC](https://discuss.elastic.co/t/kibaba-plugin-how-to-insert-data-into-elasticsearch/280374/2 "2021-08-04T23:40:33Z")

</div>

Hello,

Here is our official elasticsearch node JS client - [GitHub - elastic/elasticsearch-js: Official Elasticsearch client library for Node.js](https://github.com/elastic/elasticsearch-js)

I suspect that is what you need to use. Let me know if the docs are not enough.

Thanks,  
Bhavya

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 1, 2021, 11:41pm UTC](https://discuss.elastic.co/t/kibaba-plugin-how-to-insert-data-into-elasticsearch/280374/3 "2021-09-01T23:41:20Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
