# Kibana visualization request body

**URL:** https://discuss.elastic.co/t/kibana-visualization-request-body/129914
**Category:** Kibana
**Created:** [April 28, 2018, 9:53am UTC](https://discuss.elastic.co/t/kibana-visualization-request-body/129914 "2018-04-28T09:53:49Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sayali\_kadam](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@sayali\_kadam](https://discuss.elastic.co/u/sayali_kadam)
#### Post date: [April 28, 2018, 9:53am UTC](https://discuss.elastic.co/t/kibana-visualization-request-body/129914/1 "2018-04-28T09:53:50Z")

</div>

I want to fetch a request body associated with kibana visualization programatically, so is there API present for it?

---

<div class="post-metadata">

### Author: ![rashmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashmi/32/16391_2.png) [@rashmi](https://discuss.elastic.co/u/rashmi)
#### Post date: [April 30, 2018, 2:16pm UTC](https://discuss.elastic.co/t/kibana-visualization-request-body/129914/2 "2018-04-30T14:16:36Z")

</div>

Have you thought about Saved objects API. You can get the data from the REST API by using saved objects API.  
Saved objects have a use: Kibana uses them for searches and visualizations. Be warned, Saved Objects can change over time 🙂 When you query the .kibana index for a search object, you'll get back a document that looks like:

If you look at the kibanaSavedObjectMeta.searchSourceJSON from a search object in the .kibana index:

```auto
$ http --auth kibana_user:11111111 localhost:9200/.kibana/search/d76780b0-c15e-11e6-b8ec-f58a80978e3d?filter_path=_source.kibanaSavedObjectMeta.searchSourceJSON
HTTP/1.1 200 OK
content-encoding: gzip
content-type: application/json; charset=UTF-8
transfer-encoding: chunked

{
    "_source": {
        "kibanaSavedObjectMeta": {
            "searchSourceJSON": "{\"index\":\"tweets-*\",\"query\":{\"query_string\":{\"analyze_wildcard\":true,\"query\":\"_type:avocado\"}},\"filter\":[],\"highlight\":{\"pre_tags\":[\"@kibana-highlighted-field@\"],\"post_tags\":[\"@/kibana-highlighted-field@\"],\"fields\":{\"*\":{}},\"require_field_match\":false,\"fragment_size\":2147483647}}"
        }
    }
}

```

If you want to see what the actual query from a saved search looks like, you can also use the Spy panel in Kibana.  
Getting the data directly out of the .kibana index isn't really using a "REST API". You're using the Elasticsearch search API to get data that's managed by Kibana, and you're trying to go around Kibana to get it.

Additionally for more info: to get saved objects from Ki via API, these tests could help you:

> <https://github.com/elastic/kibana/blob/master/test/api_integration/apis/saved_objects/get.js#L15>

Cheers  
Rashmi

---

<div class="post-metadata">

### Author: ![sayali\_kadam](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@sayali\_kadam](https://discuss.elastic.co/u/sayali_kadam)
#### Post date: [May 1, 2018, 12:49pm UTC](https://discuss.elastic.co/t/kibana-visualization-request-body/129914/3 "2018-05-01T12:49:16Z")

</div>

Thanks for your inputs Rashmi.  
The query which we get in searchSOurceJson by using saved objects API is different from the query in request body of the spy panel. If we use the request body in spy panel , we can fetch the the data from elasticsearch by using below URL format:  
[http://localhost:9200/index/type/\_search?source=](http://localhost:9200/index/type/_search?source=){ request body attached with visualization of kibana in spy panel} & source\_content\_type=application/json.

So I want to know, Is there any way to fetch the request body in spy panel via program or any REST API.

---

<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: [May 29, 2018, 12:49pm UTC](https://discuss.elastic.co/t/kibana-visualization-request-body/129914/4 "2018-05-29T12:49:16Z")

</div>

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