depndening of what you really whant to do in your component, you can use such kind of snippet :
<#assign messagesQuery = rest("2.0","/search?q=" + "SELECT * FROM messages WHERE foo='bar' ORDER BY post_time DESC LIMIT 5"?url) />
<#if messagesQuery.data.size gt 0>
<#list messagesQuery.data.items as message>
<#-- do some stuff -->
${message.foo} will print 'foo'
</#list>
</#if>
See the message Table structure for more precision about query filters and sort options
If you want more help you should explain precisely what you want to :
- what is your component for?
- where you want to use it? (which page).