{
  "openapi": "3.0.1",
  "info": {
    "title": "Blockchain Data API - Dune SQL Query Results, Onchain Analytics",
    "description": "Export Dune query results to a dataset: latest results of any public or owned Dune query, run saved queries with parameters or raw DuneSQL and poll to completion, with filters, sorting and sampling. DEX trades, NFTs, tokens, wallets on Ethereum, Solana, Base and more. Bring your own API key.",
    "version": "0.1",
    "x-build-id": "YOPE4ahFoiL4sbRh3"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/nabeelbaghoor~blockchain-sql-onchain-data-api/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-nabeelbaghoor-blockchain-sql-onchain-data-api",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/nabeelbaghoor~blockchain-sql-onchain-data-api/runs": {
      "post": {
        "operationId": "runs-sync-nabeelbaghoor-blockchain-sql-onchain-data-api",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/nabeelbaghoor~blockchain-sql-onchain-data-api/run-sync": {
      "post": {
        "operationId": "run-sync-nabeelbaghoor-blockchain-sql-onchain-data-api",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "properties": {
          "mode": {
            "title": "What to read",
            "enum": [
              "latestResult",
              "executeQuery",
              "executeSql",
              "executionResult",
              "customEndpoint"
            ],
            "type": "string",
            "description": "Latest query result reads the stored result of each saved Dune query without running it (cheapest: billed only by data exported). Execute query runs each saved query again, with your parameter values, waits for it and reads the result (uses execution credits). Execute SQL runs one raw DuneSQL statement the same way. Execution result reads the stored result of an earlier execution ID. Custom endpoint reads a Dune custom API endpoint by handle and slug.",
            "default": "latestResult"
          },
          "queryIds": {
            "title": "Query IDs",
            "type": "array",
            "description": "Latest query result and execute query modes. Saved Dune query IDs, the number after /queries/ in a dune.com query URL (a full URL such as https://dune.com/queries/3568055 also works), one per line. The query must be public or owned by you or your team. Up to 50 for latest results, 10 for executions.",
            "items": {
              "type": "string"
            }
          },
          "queryParameters": {
            "title": "Query parameters",
            "type": "object",
            "description": "Latest query result and execute query modes. Values for the query's own parameters as a JSON object, such as {\"blockchain\": \"ethereum\", \"days\": 30}; a list is a multi-select parameter. Execute query runs with them (parameters left out keep their defaults). Latest query result returns the newest stored result that ran with these values."
          },
          "sql": {
            "title": "DuneSQL",
            "type": "string",
            "description": "Execute SQL mode. One DuneSQL statement to run, such as SELECT block_time, project, amount_usd FROM dex.trades WHERE block_time > now() - interval '1' day LIMIT 100. Add a LIMIT to keep compute and export credits down."
          },
          "performance": {
            "title": "Performance tier",
            "enum": [
              "small",
              "medium",
              "large"
            ],
            "type": "string",
            "description": "Execute modes only. The engine tier to run on; leave empty for Dune's default. Credits follow the compute actually used."
          },
          "timeoutSeconds": {
            "title": "Execution timeout (seconds)",
            "minimum": 10,
            "maximum": 1800,
            "type": "integer",
            "description": "Execute modes only. How long to wait for an execution to finish before giving up. Dune's own limit is 30 minutes.",
            "default": 300
          },
          "pollIntervalSeconds": {
            "title": "Poll interval (seconds)",
            "minimum": 1,
            "maximum": 60,
            "type": "integer",
            "description": "Execute modes only. How often to check the execution status. Status checks are free.",
            "default": 5
          },
          "cancelOnTimeout": {
            "title": "Cancel on timeout",
            "type": "boolean",
            "description": "Execute modes only. Cancel an execution that is still running at the timeout so it stops using compute credits. Turn off to let it finish and read it later with the execution result mode.",
            "default": true
          },
          "executionIds": {
            "title": "Execution IDs",
            "type": "array",
            "description": "Execution result mode. The 26 character execution_id of earlier executions, one per line. Results are kept for 90 days.",
            "items": {
              "type": "string"
            }
          },
          "customEndpoints": {
            "title": "Custom endpoints",
            "type": "array",
            "description": "Custom endpoint mode. Dune custom endpoints as handle/endpoint-slug, one per line.",
            "items": {
              "type": "string"
            }
          },
          "filters": {
            "title": "Filters",
            "type": "string",
            "description": "Server-side row filter over the result columns, like a SQL WHERE clause without the WHERE, such as amount_usd > 1000 AND project = 'uniswap'. Cannot be combined with a sample count."
          },
          "sortBy": {
            "title": "Sort by",
            "type": "string",
            "description": "Server-side sort over the result columns, like a SQL ORDER BY clause, such as amount_usd desc, block_time."
          },
          "columns": {
            "title": "Columns",
            "type": "array",
            "description": "Return only these result columns, one per line. Fewer columns means less data exported and fewer credits.",
            "items": {
              "type": "string"
            }
          },
          "sampleCount": {
            "title": "Sample count",
            "minimum": 1,
            "maximum": 100000,
            "type": "integer",
            "description": "Return a uniform random sample of this many rows instead of the first rows. Cannot be combined with filters."
          },
          "allowPartialResults": {
            "title": "Allow partial results",
            "type": "boolean",
            "description": "Read a result that was truncated because it was too large (over Dune's 32GB result limit) instead of refusing it.",
            "default": false
          },
          "maxResults": {
            "title": "Maximum results",
            "minimum": 1,
            "maximum": 100000,
            "type": "integer",
            "description": "The most rows this run returns and charges for, across all queries. Each read asks Dune only for the rows still left, which also limits the export credits used.",
            "default": 100
          },
          "requestsPerMinute": {
            "title": "Requests per minute",
            "minimum": 1,
            "maximum": 1000,
            "type": "integer",
            "description": "Pacing. Dune allows 70 executions and 200 result reads a minute on the Plus plan and more on Enterprise, and answers 429 above it, which the actor waits out and retries.",
            "default": 30
          },
          "apiKey": {
            "title": "API key",
            "type": "string",
            "description": "Your own Dune API key, from the API keys section of your Dune settings (dune.com/settings/api). Stored as a secret and sent only in the X-Dune-Api-Key header; it is never logged. You can instead set the DATA_API_KEY environment secret."
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}