> For the complete documentation index, see [llms.txt](https://docs.getblock.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.getblock.io/api-reference/cosmos/tendermint-rpc-api/block_search-cosmos.md).

# block\_search - Cosmos

Example code for the block\_search JSON-RPC method. Complete guide on how to use block\_search JSON-RPC in GetBlock Web3 documentation.

Searches blocks by an event-attribute query (over finalize-block events), with pagination and ordering.

## Method

```
block_search
```

## Parameters

| Parameter | Type   | Description      |
| --------- | ------ | ---------------- |
| query     | string | Event query      |
| page      | string | Page number      |
| per\_page | string | Results per page |
| order\_by | string | "asc" or "desc"  |

## Example

{% code overflow="wrap" %}

```bash
export COSMOS_TM=https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/

# JSON-RPC over HTTP (POST)
curl -X POST "${COSMOS_TM}" -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": "getblock.io", "method": "block_search", "params": {"query": "block.height>31000000", "page": "1", "per_page": "30", "order_by": "desc"}}'

# URI over HTTP (GET)
curl "${COSMOS_TM}block_search?query=block.height>31000000&page=1&per_page=30&order_by=desc"
```

{% endcode %}

## Response

```json
{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": {
        "blocks": [
            {
                "block_id": {
                    "hash": "A1B2..."
                },
                "block": {
                    "header": {
                        "height": "31378844"
                    }
                }
            }
        ],
        "total_count": "1"
    }
}
```

## Response Fields

| Field        | Type   | Description             |
| ------------ | ------ | ----------------------- |
| blocks       | array  | Matching blocks         |
| total\_count | string | Total number of matches |

## Use Cases

* **Event blocks**: Find blocks emitting a given event

## Error Handling

| Error                     | Message         | Description                                       |
| ------------------------- | --------------- | ------------------------------------------------- |
| -32600 / Invalid request  | Invalid request | The JSON-RPC envelope was malformed               |
| -32602 / Invalid params   | Invalid params  | A parameter was missing or of the wrong type      |
| 403 / RBAC: access denied | Access denied   | The GetBlock access token is missing or incorrect |
