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

# Block at Timestamp

> Resolves a Unix timestamp (in seconds) to a block number. Returns the first block whose timestamp is greater than or equal to `timestamp`. Resolution prefers archival data and falls back to the real-time source when available; the `x-sqd-data-source` response header reports which source served the result (`network` or `real_time`).




## OpenAPI

````yaml /en/api/catalog/evm/openapi.yaml get /timestamps/{timestamp}/block
openapi: 3.1.0
info:
  title: SQD Portal API - EVM Dataset Endpoints
  description: >-
    API endpoints for interacting with EVM datasets under the SQD Portal,
    specifically for the Ethereum Mainnet dataset.
  version: 1.0.0
servers:
  - url: https://portal.sqd.dev/datasets/ethereum-mainnet
    description: SQD Portal's endpoint for Ethereum Mainnet
security: []
paths:
  /timestamps/{timestamp}/block:
    get:
      summary: Block at Timestamp
      description: >
        Resolves a Unix timestamp (in seconds) to a block number. Returns the
        first block whose timestamp is greater than or equal to `timestamp`.
        Resolution prefers archival data and falls back to the real-time source
        when available; the `x-sqd-data-source` response header reports which
        source served the result (`network` or `real_time`).
      parameters:
        - name: timestamp
          in: path
          required: true
          schema:
            type: integer
            format: int64
            default: 1693066895
            example: 1693066895
          description: Unix timestamp in seconds.
      responses:
        '200':
          description: Block number resolved.
          headers:
            x-sqd-data-source:
              schema:
                type: string
                enum:
                  - network
                  - real_time
              description: Source that served the result.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BlockNumberResponse'
              examples:
                ethereum-mainnet:
                  summary: First block at or after the timestamp
                  value:
                    block_number: 18000000
        '404':
          description: No block found at or after the given timestamp.
        '500':
          description: Internal server error. Do not retry.
        '503':
          description: Upstream data source temporarily unavailable. Retry later.
      x-codeSamples:
        - lang: shell
          label: Resolve timestamp to block
          source: >
            curl
            'https://portal.sqd.dev/datasets/ethereum-mainnet/timestamps/1693066895/block'
        - lang: python
          label: Resolve timestamp to block
          source: |
            import requests

            response = requests.get(
                "https://portal.sqd.dev/datasets/ethereum-mainnet/timestamps/1693066895/block"
            )
            block_number = response.json()["block_number"]
        - lang: javascript
          label: Resolve timestamp to block
          source: >
            const response = await
            fetch("https://portal.sqd.dev/datasets/ethereum-mainnet/timestamps/1693066895/block");

            const { block_number } = await response.json();
components:
  schemas:
    BlockNumberResponse:
      type: object
      properties:
        block_number:
          type: integer
          format: int64
          description: >-
            Number of the first block whose timestamp is greater than or equal
            to the requested timestamp.
          example: 18000000
      required:
        - block_number

````