diff --git a/api-reference/crud/endpoint/archive.mdx b/api-reference/crud/endpoint/archive.mdx new file mode 100644 index 00000000..20990092 --- /dev/null +++ b/api-reference/crud/endpoint/archive.mdx @@ -0,0 +1,4 @@ +--- +title: 'Archive Query' +openapi: 'POST /v1/query/{queryId}/archive' +--- \ No newline at end of file diff --git a/api-reference/crud/endpoint/create.mdx b/api-reference/crud/endpoint/create.mdx new file mode 100644 index 00000000..6fcb90e9 --- /dev/null +++ b/api-reference/crud/endpoint/create.mdx @@ -0,0 +1,4 @@ +--- +title: 'Create Query' +openapi: 'POST /v1/query' +--- \ No newline at end of file diff --git a/api-reference/crud/endpoint/private.mdx b/api-reference/crud/endpoint/private.mdx new file mode 100644 index 00000000..495be1f7 --- /dev/null +++ b/api-reference/crud/endpoint/private.mdx @@ -0,0 +1,4 @@ +--- +title: 'Private Query' +openapi: 'POST /v1/query/{queryId}/private' +--- \ No newline at end of file diff --git a/api-reference/crud/endpoint/read.mdx b/api-reference/crud/endpoint/read.mdx new file mode 100644 index 00000000..6d63d99f --- /dev/null +++ b/api-reference/crud/endpoint/read.mdx @@ -0,0 +1,4 @@ +--- +title: 'Create Query' +openapi: 'GET /v1/query/{queryId}' +--- \ No newline at end of file diff --git a/api-reference/crud/endpoint/unarchive.mdx b/api-reference/crud/endpoint/unarchive.mdx new file mode 100644 index 00000000..2bc84e15 --- /dev/null +++ b/api-reference/crud/endpoint/unarchive.mdx @@ -0,0 +1,4 @@ +--- +title: 'Unarchive Query' +openapi: 'POST /v1/query/{queryId}/unarchive' +--- \ No newline at end of file diff --git a/api-reference/crud/endpoint/unprivate.mdx b/api-reference/crud/endpoint/unprivate.mdx new file mode 100644 index 00000000..495be1f7 --- /dev/null +++ b/api-reference/crud/endpoint/unprivate.mdx @@ -0,0 +1,4 @@ +--- +title: 'Private Query' +openapi: 'POST /v1/query/{queryId}/private' +--- \ No newline at end of file diff --git a/api-reference/crud/endpoint/update.mdx b/api-reference/crud/endpoint/update.mdx new file mode 100644 index 00000000..b9f87d7f --- /dev/null +++ b/api-reference/crud/endpoint/update.mdx @@ -0,0 +1,4 @@ +--- +title: 'Create Query' +openapi: 'POST /v1/query/{queryId}' +--- \ No newline at end of file diff --git a/api-reference/crud/openapi.json b/api-reference/crud/openapi.json new file mode 100644 index 00000000..25863d81 --- /dev/null +++ b/api-reference/crud/openapi.json @@ -0,0 +1,1033 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI for CRUD API", + "description": "API for create, read, update, and delete operations on Dune queries.", + "version": "1.0.0" + }, + "servers": [ + { + "url": "https://api.dune.com/api" + } + ], + "paths": { + "/v1/query/{queryId}": { + "get": { + "summary": "Returns the details of a query on Dune", + "description": "This API allows for anyone to read the sql text, parameters, name, tags, and state of a query. For private queries, only the API key generated under the context of the owner of that query will work.", + "operationId": "GetQuery", + "parameters": [ + { + "in": "header", + "name": "X-DUNE-API-KEY", + "schema": { + "type": "string" + }, + "description": "API Key for accessing this service", + "required": true + }, + { + "in": "path", + "name": "queryId", + "required": true, + "schema": { + "type": "integer" + }, + "description": "unique identifier of the query" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetQueryResponse" + } + } + } + }, + "400": { + "description": "Bad Request - The request could not be understood by the server due to malformed syntax or validation failure.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string", + "example": "Core request validation failed" + } + } + } + } + } + }, + "404": { + "description": "Resource not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NotFoundError" + } + } + } + }, + "500": { + "description": "Internal server error occurred. This usually happens due to unexpected issues in processing the request. It may include errors such as failure in core API execution, invalid query parameters, or issues with the customer data provided.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InternalServerError" + } + } + } + } + } + } + + , "patch": { + "summary": "Update the details of a query on Dune", + "description": "This API allows for anyone to update the sql text, parameters, name, tags, and state of a query. Only the API key generated under the context of the owner of that query will work.", + "operationId": "UpdateQuery", + "parameters": [ + { + "in": "header", + "name": "X-DUNE-API-KEY", + "schema": { + "type": "string" + }, + "description": "API Key for accessing this service", + "required": true + }, + { + "in": "path", + "name": "queryId", + "required": true, + "schema": { + "type": "integer" + }, + "description": "unique identifier of the query" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateQueryRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "query_id": { + "type": "integer", + "format": "int32", + "example": 1616880 + } + } + } + } + } + }, + "400": { + "description": "Bad Request - The request could not be understood by the server due to malformed syntax or validation failure.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string", + "example": "Core request validation failed" + } + } + } + } + } + }, + "404": { + "description": "Resource not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NotFoundError" + } + } + } + }, + "500": { + "description": "Internal server error occurred. This usually happens due to unexpected issues in processing the request. It may include errors such as failure in core API execution, invalid query parameters, or issues with the customer data provided.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InternalServerError" + } + } + } + } + } + } + } + , "/v1/query/": { + "post": { + "summary": "Create and save a query on Dune", + "description": "This API allows for anyone to create a query. The owner of the query will be under the context of the API key.", + "operationId": "CreateQuery", + "parameters": [ + { + "in": "header", + "name": "X-DUNE-API-KEY", + "schema": { + "type": "string" + }, + "description": "API Key for accessing this service", + "required": true + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateQueryRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "query_id": { + "type": "integer", + "format": "int32", + "example": 1616880 + } + } + } + } + } + }, + "400": { + "description": "Bad Request - The request could not be understood by the server due to malformed syntax or validation failure.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string", + "example": "Core request validation failed" + } + } + } + } + } + }, + "404": { + "description": "Resource not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NotFoundError" + } + } + } + }, + "500": { + "description": "Internal server error occurred. This usually happens due to unexpected issues in processing the request. It may include errors such as failure in core API execution, invalid query parameters, or issues with the customer data provided.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InternalServerError" + } + } + } + } + } + } + } + + , "/v1/query/{queryId}/archive": { + "post": { + "summary": "Archive a query on Dune", + "description": "This API allows for anyone to archive a query. Only the API key generated under the context of the owner of that query will work. This does not delete the query, but will make it uneditable/unexecutable", + "operationId": "ArchiveQuery", + "parameters": [ + { + "in": "header", + "name": "X-DUNE-API-KEY", + "schema": { + "type": "string" + }, + "description": "API Key for accessing this service", + "required": true + }, + { + "in": "path", + "name": "queryId", + "required": true, + "schema": { + "type": "integer" + }, + "description": "unique identifier of the query" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "query_id": { + "type": "integer", + "format": "int32", + "example": 1616880 + } + } + } + } + } + }, + "400": { + "description": "Bad Request - The request could not be understood by the server due to malformed syntax or validation failure.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string", + "example": "Core request validation failed" + } + } + } + } + } + }, + "404": { + "description": "Resource not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NotFoundError" + } + } + } + }, + "500": { + "description": "Internal server error occurred. This usually happens due to unexpected issues in processing the request. It may include errors such as failure in core API execution, invalid query parameters, or issues with the customer data provided.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InternalServerError" + } + } + } + } + } + } + } + + , "/v1/query/{queryId}/unarchive": { + "post": { + "summary": "Unarchive a query on Dune", + "description": "This API allows for anyone to unarchive a query. Only the API key generated under the context of the owner of that query will work.", + "operationId": "UnarchiveQuery", + "parameters": [ + { + "in": "header", + "name": "X-DUNE-API-KEY", + "schema": { + "type": "string" + }, + "description": "API Key for accessing this service", + "required": true + }, + { + "in": "path", + "name": "queryId", + "required": true, + "schema": { + "type": "integer" + }, + "description": "unique identifier of the query" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "query_id": { + "type": "integer", + "format": "int32", + "example": 1616880 + } + } + } + } + } + }, + "400": { + "description": "Bad Request - The request could not be understood by the server due to malformed syntax or validation failure.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string", + "example": "Core request validation failed" + } + } + } + } + } + }, + "404": { + "description": "Resource not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NotFoundError" + } + } + } + }, + "500": { + "description": "Internal server error occurred. This usually happens due to unexpected issues in processing the request. It may include errors such as failure in core API execution, invalid query parameters, or issues with the customer data provided.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InternalServerError" + } + } + } + } + } + } + } + + , "/v1/query/{queryId}/private": { + "post": { + "summary": "Private a query on Dune", + "description": "This API allows for anyone to private a query. Only the API key generated under the context of the owner of that query will work.", + "operationId": "PrivateQuery", + "parameters": [ + { + "in": "header", + "name": "X-DUNE-API-KEY", + "schema": { + "type": "string" + }, + "description": "API Key for accessing this service", + "required": true + }, + { + "in": "path", + "name": "queryId", + "required": true, + "schema": { + "type": "integer" + }, + "description": "unique identifier of the query" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "query_id": { + "type": "integer", + "format": "int32", + "example": 1616880 + } + } + } + } + } + }, + "400": { + "description": "Bad Request - The request could not be understood by the server due to malformed syntax or validation failure.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string", + "example": "Core request validation failed" + } + } + } + } + } + }, + "404": { + "description": "Resource not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NotFoundError" + } + } + } + }, + "500": { + "description": "Internal server error occurred. This usually happens due to unexpected issues in processing the request. It may include errors such as failure in core API execution, invalid query parameters, or issues with the customer data provided.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InternalServerError" + } + } + } + } + } + } + } + + , "/v1/query/{queryId}/unprivate": { + "post": { + "summary": "Private a query on Dune", + "description": "This API allows for anyone to unprivate a query. Only the API key generated under the context of the owner of that query will work.", + "operationId": "UnprivateQuery", + "parameters": [ + { + "in": "header", + "name": "X-DUNE-API-KEY", + "schema": { + "type": "string" + }, + "description": "API Key for accessing this service", + "required": true + }, + { + "in": "path", + "name": "queryId", + "required": true, + "schema": { + "type": "integer" + }, + "description": "unique identifier of the query" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "query_id": { + "type": "integer", + "format": "int32", + "example": 1616880 + } + } + } + } + } + }, + "400": { + "description": "Bad Request - The request could not be understood by the server due to malformed syntax or validation failure.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string", + "example": "Core request validation failed" + } + } + } + } + } + }, + "404": { + "description": "Resource not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NotFoundError" + } + } + } + }, + "500": { + "description": "Internal server error occurred. This usually happens due to unexpected issues in processing the request. It may include errors such as failure in core API execution, invalid query parameters, or issues with the customer data provided.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InternalServerError" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "GetQueryResponse": { + "type": "object", + "properties": { + "query_id": { + "type": "integer" + ,"description": "Unique identifier of the query." + ,"example": 1252207 + }, + "name": { + "type": "string" + ,"description": "Name of the query." + ,"example": "erc20 balances (user address) API" + }, + "description": { + "type": "string" + ,"description": "Description of the query." + ,"example": "Get the ERC20 token balances for a given user address." + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + ,"description": "Tags associated with the query." + ,"example": ["erc20", "balances", "user address"] + }, + "version": { + "type": "integer" + ,"description": "Version of the query." + ,"example": 17 + }, + "parameters": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ParameterObject" + } + ,"example": [ + { + "key": "address", + "value": "0x2ae8c972fb2e6c00dded8986e2dc672ed190da06", + "type": "text" + }, + { + "key": "blocknumber", + "value": "0", + "type": "number" + }, + { + "key": "chain", + "value": "ethereum", + "type": "enum", + "enumOptions": [ + "ethereum", + "polygon", + "optimism", + "arbitrum", + "avalanche_c", + "gnosis", + "bnb" + ] + }, + { + "key": "dust", + "value": "keep", + "type": "enum", + "enumOptions": [ + "keep", + "remove" + ] + } + ] + }, + "query_engine": { + "type": "string" + ,"description": "The query engine used to execute the query." + ,"example": "v2 Dune SQL" + }, + "query_sql": { + "type": "string" + ,"description": "The SQL query text." + ,"example": "with\n erc20_balances as (\n WITH erc20_in as ( \n SELECT \n contract_address\n , SUM(tr.value) as token_funded\n FROM erc20_{{chain}}.evt_Transfer tr\n WHERE tr.to = {{address}}\n AND ({{blocknumber}} = 0 OR tr.evt_block_number <= {{blocknumber}})\n GROUP BY 1\n ),\n \n erc20_out as (\n SELECT \n contract_address\n , SUM(tr.value) as token_spent\n FROM erc20_{{chain}}.evt_Transfer tr\n WHERE tr.\"from\" = {{address}}\n AND ({{blocknumber}} = 0 OR tr.evt_block_number <= {{blocknumber}})\n GROUP BY 1\n )\n \n SELECT\n tk.symbol as symbol\n , erc20_in.contract_address\n , (cast(token_funded as double) - COALESCE(cast(token_spent as double), 0))/pow(10,COALESCE(tk.decimals,18)) as balance\n FROM erc20_in\n LEFT JOIN erc20_out ON erc20_in.contract_address = erc20_out.contract_address\n LEFT JOIN tokens.erc20 tk ON tk.contract_address = erc20_in.contract_address\n WHERE cast(token_funded as double) - COALESCE(cast(token_spent as double), 0) > 0\n -- WHERE tk.symbol is not null\n )\n\nSELECT\n bal.symbol\n , round(bal.balance,5) as notional_value\n , round(bal.balance*p.price,3) as total_value\n , p.price as token_price\nFROM erc20_balances bal\nLEFT JOIN prices.usd_latest p \n ON p.contract_address = bal.contract_address\n AND p.blockchain = '{{chain}}' --AND p.rn = 1 \nWHERE bal.balance > 0\nAND ('{{dust}}' = 'keep' OR bal.balance*p.price > 0.01)\nORDER BY total_value DESC\nNULLS LAST" + }, + "is_private": { + "type": "boolean" + ,"description": "Indicates if the query is private." + ,"example": false + }, + "is_archived": { + "type": "boolean" + ,"description": "Indicates if the query is archived." + ,"example": false + }, + "is_unsaved": { + "type": "boolean" + ,"description": "Indicates if the query is unsaved." + ,"example": false + }, + "owner": { + "type": "string" + ,"description": "The owner of the query." + ,"example": "Dune" + } + } + } + , "UpdateQueryRequest": { + "type": "object", + "properties": { + "query_id": { + "type": "integer" + ,"description": "Unique identifier of the query." + ,"example": 1252207 + }, + "name": { + "type": "string" + ,"description": "Name of the query." + ,"example": "erc20 balances (user address) API" + }, + "description": { + "type": "string" + ,"description": "Description of the query." + ,"example": "Get the ERC20 token balances for a given user address." + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + ,"description": "Tags associated with the query." + ,"example": ["erc20", "balances", "user address"] + }, + "parameters": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ParameterObject" + } + ,"example": [ + { + "key": "address", + "value": "0x2ae8c972fb2e6c00dded8986e2dc672ed190da06", + "type": "text" + }, + { + "key": "blocknumber", + "value": "0", + "type": "number" + }, + { + "key": "chain", + "value": "ethereum", + "type": "enum", + "enumOptions": [ + "ethereum", + "polygon", + "optimism", + "arbitrum", + "avalanche_c", + "gnosis", + "bnb" + ] + }, + { + "key": "dust", + "value": "keep", + "type": "enum", + "enumOptions": [ + "keep", + "remove" + ] + } + ] + }, + "query_sql": { + "type": "string" + ,"description": "The SQL query text." + ,"example": "with\n erc20_balances as (\n WITH erc20_in as ( \n SELECT \n contract_address\n , SUM(tr.value) as token_funded\n FROM erc20_{{chain}}.evt_Transfer tr\n WHERE tr.to = {{address}}\n AND ({{blocknumber}} = 0 OR tr.evt_block_number <= {{blocknumber}})\n GROUP BY 1\n ),\n \n erc20_out as (\n SELECT \n contract_address\n , SUM(tr.value) as token_spent\n FROM erc20_{{chain}}.evt_Transfer tr\n WHERE tr.\"from\" = {{address}}\n AND ({{blocknumber}} = 0 OR tr.evt_block_number <= {{blocknumber}})\n GROUP BY 1\n )\n \n SELECT\n tk.symbol as symbol\n , erc20_in.contract_address\n , (cast(token_funded as double) - COALESCE(cast(token_spent as double), 0))/pow(10,COALESCE(tk.decimals,18)) as balance\n FROM erc20_in\n LEFT JOIN erc20_out ON erc20_in.contract_address = erc20_out.contract_address\n LEFT JOIN tokens.erc20 tk ON tk.contract_address = erc20_in.contract_address\n WHERE cast(token_funded as double) - COALESCE(cast(token_spent as double), 0) > 0\n -- WHERE tk.symbol is not null\n )\n\nSELECT\n bal.symbol\n , round(bal.balance,5) as notional_value\n , round(bal.balance*p.price,3) as total_value\n , p.price as token_price\nFROM erc20_balances bal\nLEFT JOIN prices.usd_latest p \n ON p.contract_address = bal.contract_address\n AND p.blockchain = '{{chain}}' --AND p.rn = 1 \nWHERE bal.balance > 0\nAND ('{{dust}}' = 'keep' OR bal.balance*p.price > 0.01)\nORDER BY total_value DESC\nNULLS LAST" + }, + "is_private": { + "type": "boolean" + ,"description": "Indicates if the query is private." + ,"example": false + }, + "is_archived": { + "type": "boolean" + ,"description": "Indicates if the query is archived." + ,"example": false + } + } + } + , "CreateQueryRequest": { + "type": "object", + "properties": { + "name": { + "type": "string" + ,"description": "Name of the query." + ,"example": "erc20 balances (user address) API" + }, + "description": { + "type": "string" + ,"description": "Description of the query." + ,"example": "Get the ERC20 token balances for a given user address." + }, + "parameters": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ParameterObject" + } + ,"example": [ + { + "key": "address", + "value": "0x2ae8c972fb2e6c00dded8986e2dc672ed190da06", + "type": "text" + }, + { + "key": "blocknumber", + "value": "0", + "type": "number" + }, + { + "key": "chain", + "value": "ethereum", + "type": "enum", + "enumOptions": [ + "ethereum", + "polygon", + "optimism", + "arbitrum", + "avalanche_c", + "gnosis", + "bnb" + ] + }, + { + "key": "dust", + "value": "keep", + "type": "enum", + "enumOptions": [ + "keep", + "remove" + ] + } + ] + }, + "query_sql": { + "type": "string" + ,"description": "The SQL query text." + ,"example": "with\n erc20_balances as (\n WITH erc20_in as ( \n SELECT \n contract_address\n , SUM(tr.value) as token_funded\n FROM erc20_{{chain}}.evt_Transfer tr\n WHERE tr.to = {{address}}\n AND ({{blocknumber}} = 0 OR tr.evt_block_number <= {{blocknumber}})\n GROUP BY 1\n ),\n \n erc20_out as (\n SELECT \n contract_address\n , SUM(tr.value) as token_spent\n FROM erc20_{{chain}}.evt_Transfer tr\n WHERE tr.\"from\" = {{address}}\n AND ({{blocknumber}} = 0 OR tr.evt_block_number <= {{blocknumber}})\n GROUP BY 1\n )\n \n SELECT\n tk.symbol as symbol\n , erc20_in.contract_address\n , (cast(token_funded as double) - COALESCE(cast(token_spent as double), 0))/pow(10,COALESCE(tk.decimals,18)) as balance\n FROM erc20_in\n LEFT JOIN erc20_out ON erc20_in.contract_address = erc20_out.contract_address\n LEFT JOIN tokens.erc20 tk ON tk.contract_address = erc20_in.contract_address\n WHERE cast(token_funded as double) - COALESCE(cast(token_spent as double), 0) > 0\n -- WHERE tk.symbol is not null\n )\n\nSELECT\n bal.symbol\n , round(bal.balance,5) as notional_value\n , round(bal.balance*p.price,3) as total_value\n , p.price as token_price\nFROM erc20_balances bal\nLEFT JOIN prices.usd_latest p \n ON p.contract_address = bal.contract_address\n AND p.blockchain = '{{chain}}' --AND p.rn = 1 \nWHERE bal.balance > 0\nAND ('{{dust}}' = 'keep' OR bal.balance*p.price > 0.01)\nORDER BY total_value DESC\nNULLS LAST" + }, + "is_private": { + "type": "boolean" + ,"description": "Indicates if the query is private." + ,"example": false + } + } + }, + "SyntaxErrorMetadata": { + "type": "object", + "properties": { + "line": { + "type": "integer", + "description": "The line number at which the syntax error occurred." + }, + "column": { + "type": "integer", + "description": "The column number at which the syntax error occurred." + } + } + }, + "ExecutionResultMetadata": { + "type": "object", + "properties": { + "column_names": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Names of the columns in the result set." + }, + "result_set_bytes": { + "type": "integer", + "format": "int64", + "description": "Total number of bytes in the result set." + }, + "total_row_count": { + "type": "integer", + "description": "Total number of rows in the result set." + }, + "datapoint_count": { + "type": "integer", + "format": "int64", + "description": "The count of datapoints used for billing/pricing, based on the result set." + }, + "pending_time_millis": { + "type": "integer", + "description": "Time in milliseconds that the query was pending before execution." + }, + "execution_time_millis": { + "type": "integer", + "description": "Time in milliseconds that the query took to execute." + } + }, + "description": "Metadata about the execution of the query, including details like column names, row counts, and execution times." + }, + "ParameterObject": { + "type": "object", + "required": [ + "key" + ], + "properties": { + "key": { + "type": "string", + "description": "The key name of the parameter." + }, + "description": { + "type": "string", + "description": "A brief description of the parameter." + }, + "value": { + "type": "string", + "description": "The default value used by this parameter during execution, format depends on the type." + }, + "values": { + "type": "array", + "items": { + "type": "string" + }, + "description": "An array of string values, used when multiple selections are allowed." + }, + "type": { + "type": "string", + "enum": [ + "number", + "text", + "datetime", + "enum" + ], + "description": "The type of the parameter, determines the format of 'value(s)'. 'number': Numeric parameters, the value must be a number (e.g., '20'). 'text': String parameters, value can be any text including hex 0x-prefixed values (e.g., '0xae2fc...'), an empty value defaults to an empty string. 'datetime': Date and time parameters, value must be in 'YYYY-MM-DD hh:mm:ss' format (e.g., '2021-12-31 23:59:59'). 'enum': Parameters with a specific list of values, 'EnumValues' field is mandatory, providing a JSON list of strings representing valid options, the 'value' must be one of these options (e.g., 'Option1')." + }, + "EnumValues": { + "type": "array", + "items": { + "type": "string" + }, + "description": "List of valid options for 'enum' type parameters." + }, + "isMultiselect": { + "type": "boolean", + "description": "Indicates if multiple selections are allowed for this parameter." + }, + "isFreeformAllowed": { + "type": "boolean", + "description": "Indicates if freeform input is allowed for this parameter." + }, + "enumFromResults": { + "$ref": "#/components/schemas/EnumFromResults" + } + } + }, + "EnumFromResults": { + "type": "object", + "properties": { + "queryId": { + "type": "integer", + "description": "The ID of the query to fetch results from." + }, + "columnName": { + "type": "string", + "description": "The column name to use from the query results." + } + } + }, + "NotFoundError": { + "type": "object", + "required": [ + "error", + "message" + ], + "properties": { + "error": { + "type": "integer", + "format": "int32", + "description": "Error code for resource not found", + "example": 404 + }, + "message": { + "type": "string", + "description": "Error message for resource not found", + "example": "The requested resource was not found." + } + } + }, + "InternalServerError": { + "type": "object", + "properties": { + "error": { + "type": "integer", + "format": "int32", + "example": 500 + }, + "message": { + "type": "string", + "example": "internal error" + } + }, + "description": "Generic error message, given when an unexpected condition is encountered and no more specific message is available. Please consult the API documentation for more details." + } + } + } +} \ No newline at end of file diff --git a/api-reference/endpoint/create.mdx b/api-reference/endpoint/create.mdx deleted file mode 100644 index faa67581..00000000 --- a/api-reference/endpoint/create.mdx +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: 'Create Plant' -openapi: 'POST /plants' ---- - - - -```bash Request - curl --request POST \ - --url https://dog-api.kinduff.com/api/facts -``` - - \ No newline at end of file diff --git a/api-reference/endpoint/delete.mdx b/api-reference/endpoint/delete.mdx deleted file mode 100644 index 657dfc87..00000000 --- a/api-reference/endpoint/delete.mdx +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: 'Delete Plant' -openapi: 'DELETE /plants/{id}' ---- diff --git a/api-reference/endpoint/get.mdx b/api-reference/endpoint/get.mdx deleted file mode 100644 index 56aa09ec..00000000 --- a/api-reference/endpoint/get.mdx +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: 'Get Plants' -openapi: 'GET /plants' ---- diff --git a/api-reference/openapi.json b/api-reference/openapi.json deleted file mode 100644 index b1509be0..00000000 --- a/api-reference/openapi.json +++ /dev/null @@ -1,195 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "OpenAPI Plant Store", - "description": "A sample API that uses a plant store as an example to demonstrate features in the OpenAPI specification", - "license": { - "name": "MIT" - }, - "version": "1.0.0" - }, - "servers": [ - { - "url": "http://sandbox.mintlify.com" - } - ], - "security": [ - { - "bearerAuth": [] - } - ], - "paths": { - "/plants": { - "get": { - "description": "Returns all plants from the system that the user has access to", - "parameters": [ - { - "name": "limit", - "in": "query", - "description": "The maximum number of results to return", - "schema": { - "type": "integer", - "format": "int32" - } - } - ], - "responses": { - "200": { - "description": "Plant response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Plant" - } - } - } - } - }, - "400": { - "description": "Unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - }, - "post": { - "description": "Creates a new plant in the store", - "requestBody": { - "description": "Plant to add to the store", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/NewPlant" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "plant response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Plant" - } - } - } - }, - "400": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - } - }, - "/plants/{id}": { - "delete": { - "description": "Deletes a single plant based on the ID supplied", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of plant to delete", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "204": { - "description": "Plant deleted", - "content": {} - }, - "400": { - "description": "unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "Plant": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "name": { - "description": "The name of the plant", - "type": "string" - }, - "tag": { - "description": "Tag to specify the type", - "type": "string" - } - } - }, - "NewPlant": { - "allOf": [ - { - "$ref": "#/components/schemas/Plant" - }, - { - "required": [ - "id" - ], - "type": "object", - "properties": { - "id": { - "description": "Identification number of the plant", - "type": "integer", - "format": "int64" - } - } - } - ] - }, - "Error": { - "required": [ - "error", - "message" - ], - "type": "object", - "properties": { - "error": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - }, - "securitySchemes": { - "bearerAuth": { - "type": "http", - "scheme": "bearer" - } - } - } -} \ No newline at end of file diff --git a/api-reference/upload/endpoint/upload.mdx b/api-reference/upload/endpoint/upload.mdx new file mode 100644 index 00000000..3e1b79c3 --- /dev/null +++ b/api-reference/upload/endpoint/upload.mdx @@ -0,0 +1,4 @@ +--- +title: 'Upload CSV' +openapi: 'POST /v1/query/{queryId}' +--- \ No newline at end of file diff --git a/api-reference/upload/openapi.json b/api-reference/upload/openapi.json new file mode 100644 index 00000000..a94cc4b0 --- /dev/null +++ b/api-reference/upload/openapi.json @@ -0,0 +1,166 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI for Upload API", + "description": "API for uploading CSVs to Dune", + "version": "1.0.0" + }, + "servers": [ + { + "url": "https://api.dune.com/api" + } + ], + "paths": { + "/v1/table/upload/csv": { + "post": { + "summary": "Upload a CSV as a table in Dune.", + "description": "This API allows for anyone to upload a CSV as a table in Dune. The size limit per upload is currently 200MB. Your storage is limited by plan, 1MB on free, 15GB on plus, and 50GB on premium.", + "operationId": "UploadCSV", + "parameters": [ + { + "in": "header", + "name": "X-DUNE-API-KEY", + "schema": { + "type": "string" + }, + "description": "API Key for accessing this service", + "required": true + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CSVUploadRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "query_id": { + "type": "integer", + "format": "int32", + "example": 1616880 + } + } + } + } + } + }, + "400": { + "description": "Bad Request - The request could not be understood by the server due to malformed syntax or validation failure.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string", + "example": "Core request validation failed" + } + } + } + } + } + }, + "404": { + "description": "Resource not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NotFoundError" + } + } + } + }, + "500": { + "description": "Internal server error occurred. This usually happens due to unexpected issues in processing the request. It may include errors such as failure in core API execution, invalid query parameters, or issues with the customer data provided.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InternalServerError" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "CSVUploadRequest": { + "type": "object", + "properties": { + "Data": { + "type": "string", + "description": "The data to be uploaded in CSV format.", + "example": "DATE,DGS10,\n2023-12-04,4.28,\n2023-12-05,4.18,\n2023-12-06,4.12,\n2023-12-07,4.14,\n2023-12-08,4.23,\n2023-12-11,4.23" + }, + "Description": { + "type": "string", + "description": "Description of the upload.", + "example": "10 year daily interest rates, sourced from https://fred.stlouisfed.org/series/DGS10" + }, + "TableName": { + "type": "string", + "description": "The name of the table to store the data.", + "example": "ten_year_us_interest_rates" + }, + "IsPrivate": { + "type": "boolean", + "description": "Indicates if the upload is private.", + "example": false + } + } + }, + "NotFoundError": { + "type": "object", + "required": [ + "error", + "message" + ], + "properties": { + "error": { + "type": "integer", + "format": "int32", + "description": "Error code for resource not found", + "example": 404 + }, + "message": { + "type": "string", + "description": "Error message for resource not found", + "example": "The requested resource was not found." + } + } + }, + "InternalServerError": { + "type": "object", + "properties": { + "error": { + "type": "integer", + "format": "int32", + "example": 500 + }, + "message": { + "type": "string", + "example": "internal error" + } + }, + "description": "Generic error message, given when an unexpected condition is encountered and no more specific message is available. Please consult the API documentation for more details." + } + } + } +} \ No newline at end of file