# How to search messages using REST API

**URL:** https://community.graylog.org/t/how-to-search-messages-using-rest-api/17943
**Category:** Graylog Central (peer support)
**Created:** [November 23, 2020, 12:07pm UTC](https://community.graylog.org/t/how-to-search-messages-using-rest-api/17943 "2020-11-23T12:07:52Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![jan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/jan/32/11_2.png) [@jan](https://community.graylog.org/u/jan)
#### Post date: [December 14, 2020, 8:31am UTC](https://community.graylog.org/t/how-to-search-messages-using-rest-api/17943/6 "2020-12-14T08:31:45Z")

</div>

one open would be to use the relative time,

Include the streams ID you want to search in, include the query string in the `query_string` object and the time you want to search as relative.

The below search will return as CSV/export.

```auto
## Search via Export API
curl -X "POST" "https://graylog.ch/api/views/search/messages" \
     -H 'X-Requested-By: Mamamia' \
     -H 'Content-Type: application/json' \
     -H 'Accept: text/csv' \
     -u 'admin:password' \
     -d $'{
  "streams": [
    "5e569003c793163fea1b3373"
  ],
  "query_string": {
    "type": "elasticsearch",
    "query_string": "section:boulder"
  },
  "timerange": {
    "type": "relative",
    "range": 30000
  }
}'

```

---

_[View the full topic](https://community.graylog.org/t/how-to-search-messages-using-rest-api/17943)._
