> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Cloud SQL Query (Classic)

## Example

Query the hashes of the last 3,000 blocks in Ethereum and the number of transactions in each block:

```bash theme={null}
curl -X "POST" "https://api.chainbase.online/v1/dw/query" \
     -H 'X-API-KEY: YOUR-API-KEY ' \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "query": "select number, transactions_count from ethereum.blocks order by number desc limit 3000;"
}'
```

If there are more than 1000 rows, you need to paginate through the`task_id` and `page` to get all the results:

```bash theme={null}
curl -X "POST" "https://api.chainbase.online/v1/dw/query" \
     -H 'X-API-KEY: YOUR-API-KEY ' \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
       "task_id": "xxxxxxxxxxxxxxxxxxxxx",
       "page": 2
}'
```

<Note>
  🚧 Note

  1. When `quey_id` is passed in, the content of query will be ignored
  2. The executed request generates a `task_id`, which is valid for 1 hour
  3. A maximum of 100,000 pieces of data are allowed to be obtained from the request, and 1,000 results are paginated per page
</Note>


## OpenAPI

````yaml post /dw/query
openapi: 3.0.2
info:
  title: Data Cloud Task API
  version: '1.0'
servers:
  - url: https://api.chainbase.com/api/v1
security: []
paths:
  /dw/query:
    post:
      parameters:
        - $ref: '#/components/parameters/X-API-KEY'
        - $ref: '#/components/parameters/Content-Type'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                query:
                  type: string
                  example: >-
                    select number, transactions_count from ethereum.blocks order
                    by number desc limit 3000;
      responses:
        '200':
          description: OK
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: sql is empty
                  code:
                    type: integer
                    format: int32
                    example: 1001
                  data:
                    type: array
                    example: []
components:
  parameters:
    X-API-KEY:
      name: X-API-KEY
      in: header
      required: true
      schema:
        type: string
    Content-Type:
      name: Content-Type
      in: header
      required: true
      schema:
        type: string
        example: application/json

````