# How to use the Graylog API to query data？

**URL:** https://community.graylog.org/t/how-to-use-the-graylog-api-to-query-data/34756
**Category:** Graylog Central (peer support)
**Created:** [January 24, 2025, 2:12am UTC](https://community.graylog.org/t/how-to-use-the-graylog-api-to-query-data/34756 "2025-01-24T02:12:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![loveyang2012](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/loveyang2012/32/17595_2.png) [@loveyang2012](https://community.graylog.org/u/loveyang2012)
#### Post date: [January 24, 2025, 2:12am UTC](https://community.graylog.org/t/how-to-use-the-graylog-api-to-query-data/34756/1 "2025-01-24T02:12:51Z")

</div>

How can I use the Graylog API to query data for the last hour, with the field status:200 and stream:000000000000000000000001 ?  
I only need the count, not the display of all the data. I’ve tried using /api/search/aggregate many times, but it has failed each time. Could you please help me with an example? Thank you very much.

ps:  
graylog 5.12  
stream id ：000000000000000000000001

---

<div class="post-metadata">

### Author: ![janheise](https://avatars.discourse-cdn.com/v4/letter/j/c89c15/32.png) [@janheise](https://community.graylog.org/u/janheise)
#### Post date: [January 27, 2025, 1:13pm UTC](https://community.graylog.org/t/how-to-use-the-graylog-api-to-query-data/34756/2 "2025-01-27T13:13:55Z")

</div>

imho, the docs for the Search Scripting API and the examples should get you on track: [Search Scripting API](https://go2docs.graylog.org/current/making_sense_of_your_log_data/simple_search_scripting_api.htm#aanchor53)

---

<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: [February 10, 2025, 1:14pm UTC](https://community.graylog.org/t/how-to-use-the-graylog-api-to-query-data/34756/3 "2025-02-10T13:14:17Z")

</div>

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