# DefiLlama Block by Timestamp

> DefiLlama Block by Timestamp is a paid API for AI agents from defillama.use.x402atlas.com, paid per call via x402, $0.005/call, status unknown (last checked 2026-09-14).

Returns the closest block number to a given unix timestamp on a specified blockchain chain.

## Facts

- Endpoint: GET https://defillama.use.x402atlas.com/block
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/defillama-block-by-timestamp-384ebe71
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_SLKCutkgJfGxfBLtdpcY8

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability defillama-block-by-timestamp-384ebe71
```

Example prompt: What was the closest Ethereum block number to unix timestamp 1700000000? Use DefiLlama's block-by-timestamp lookup.

## When to prefer this

Use this endpoint when you need to anchor on-chain historical queries to a specific point in time — e.g., fetching a token balance, protocol state, or event log at a known date/time. It is ideal when working with multichain DeFi data pipelines where you need to synchronize block heights with real-world timestamps across Ethereum, Arbitrum, Polygon, and other DefiLlama-tracked chains.

## Known failure modes

- Invalid chain name returns an error or empty result
- Timestamp out of range for indexed chain history returns an error
- Missing required query parameters (chain or timestamp) returns a 400-level error
- Network or payment failure returns a non-200 response

## How this service works

Block by timestamp from DefiLlama — the closest block number to a unix timestamp on a given chain.

## Output

Returns the block number on the specified chain that is closest to the provided unix timestamp, along with metadata such as the actual timestamp of that block.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [
      "chain",
      "timestamp"
     ],
     "properties": {
      "chain": {
       "type": "string",
       "pattern": "^[^/?#]+$",
       "maxLength": 100,
       "minLength": 1,
       "description": "Chain name (e.g. ethereum, arbitrum, polygon); no slashes or query characters"
      },
      "timestamp": {
       "type": "string",
       "pattern": "^[0-9]+$",
       "maxLength": 20,
       "minLength": 1,
       "description": "Unix timestamp (seconds, digits only) to find the closest block for"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "required": [
      "queried_at",
      "data"
     ],
     "properties": {
      "data": {
       "type": "object",
       "properties": {
        "height": {
         "type": "integer",
         "description": "Block height closest to the requested timestamp"
        },
        "timestamp": {
         "type": "integer",
         "description": "Unix timestamp (seconds) of that block"
        }
       }
      },
      "queried_at": {
       "type": "string",
       "format": "date-time",
       "description": "When this bridge fetched the upstream data"
      }
     }
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "data": {
   "height": 14688775,
   "timestamp": 1650000000
  },
  "queried_at": "2026-07-01T12:00:00Z"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/defillama-block-by-timestamp-384ebe71/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from defillama.use.x402atlas.com](https://www.zero.xyz/host/defillama.use.x402atlas.com/llms.txt)
