# API Search Example

**URL:** <https://community.graylog.org/t/api-search-example/14502>\
**Category:** Graylog Central (peer support)\
**Created:** [March 13, 2020, 3:59pm UTC](https://community.graylog.org/t/api-search-example/14502 "2020-03-13T15:59:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dansl](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@dansl](https://community.graylog.org/u/dansl)\
**Post date:** [March 13, 2020, 3:59pm UTC](https://community.graylog.org/t/api-search-example/14502/1 "2020-03-13T15:59:50Z")

</div>

I need to execute search from API but haven’t had any luck, can anyone help with a basic example using the following endpoint?

/views/search/sync

Just need to search for presence string in the message field and within timerange.

---

<div class="post-metadata">

**Author:** ![anon51124659](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@anon51124659](https://community.graylog.org/u/anon51124659)\
**Post date:** [March 13, 2020, 4:09pm UTC](https://community.graylog.org/t/api-search-example/14502/2 "2020-03-13T16:09:33Z")

</div>

Hi @dansl!

Maybe the API-Browser, which is reachable via the System -\> Node Nav-Entry, can help you figuring out the problem.  
There are the necessary request & response JSON-Payload fields (key & value-datatype) listed.

Greets

---

<div class="post-metadata">

**Author:** ![dansl](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@dansl](https://community.graylog.org/u/dansl)\
**Post date:** [March 13, 2020, 4:43pm UTC](https://community.graylog.org/t/api-search-example/14502/3 "2020-03-13T16:43:06Z")

</div>

I have reviewed that but being new to graylog I’m not sure what the syntax of the values need to be.

For example, here is the model provided, but what is the value format for ‘querys’ to look for data in a message?  
{  
id (string, optional),  
queries (array[object], optional),  
parameters (array[object], optional),  
owner (string, optional),  
created\_at (string, optional),  
requires (object, optional)  
}

---

<div class="post-metadata">

**Author:** ![shoothub](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/shoothub/32/6412_2.png) [@shoothub](https://community.graylog.org/u/shoothub)\
**Post date:** [March 16, 2020, 8:40am UTC](https://community.graylog.org/t/api-search-example/14502/4 "2020-03-16T08:40:31Z")

</div>

Try to use this curl command:  
`curl -u admin:password -H 'X-Requested-By: cli' "http://GRAYLOG_IP_OR_HOSTNAME/api/search/universal/relative?query=*&range=3600&limit=100&sort=timestamp:desc&pretty=true" -H "Accept: application/json" -H "Content-Type: application/json"`

Where:  
`query=*` - replace \* with your desired string  
`range=3600` - replace 3600 with time range (in seconds)  
`limit=100` - replace 100 with number of returned results  
`sort=timestamp:desc` - replace timestamp:desc with field you want to sort

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/graylog/original/3X/c/7/c7c09c6b5099570133d6502b83f50ba4430de5b6.png) [@system](https://community.graylog.org/u/system)\
**Post date:** [March 30, 2020, 8:40am UTC](https://community.graylog.org/t/api-search-example/14502/5 "2020-03-30T08:40:34Z")

</div>

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