Dune MPP: Pay-per-Request API Access for AI Agents
Let AI agents query Dune’s API and pay per request with the Machine Payment Protocol (MPP), with no Dune account or API key.
MPP (Machine Payment Protocol) is an open standard for machine-to-machine HTTP micropayments built on the HTTP 402 challenge-response flow. Dune’s MPP integration lets agents pay per-request through a payment channel - no API keys, no user account, and no credit card required.
How It Works
Your client sends a request to a Dune API endpoint.
Dune responds with HTTP 402 and a WWW-Authenticate: Payment challenge describing the cost.
The mppx client library automatically opens a Tempo payment channel on the first 402, depositing funds into an on-chain escrow.
Subsequent requests are authenticated with signed channel vouchers deducted from the deposit.
When you are done, you close the session and any unspent deposit is returned to your wallet.
Available Endpoints
Endpoint
Description
POST /v1/sql/execute
Execute a SQL query
GET /v1/execution/:execution_id/results
Fetch JSON results for an execution
GET /v1/execution/:execution_id/csv
Download CSV results for an execution
Option 1: Agentic Integration
The fastest way to get started. Ask your AI coding agent to set up Tempo and run a query on Dune - no manual code required. This works with any agent that supports skills or tool use, including Claude Code, Cursor, OpenAI Codex, OpenCode, and others.
Getting Started
Simply give your agent the following prompt:
Read https://tempo.xyz/SKILL.md and set up tempo.After that, use MPP to run the following query on Dune:SELECT * FROM ethereum.transactions LIMIT 10
Your agent will:
Read the Tempo skill instructions and configure itself
Open a payment channel funded from your crypto wallet
Execute the query against Dune’s API via MPP
Return the results directly in your conversation
No Dune account, no API key, and no credit card needed - you pay per-request with crypto.
Closing Your Session
Always ask your agent to close the session when you are done. Closing the session settles the payment channel on-chain and refunds any reserved funds back to your wallet - you are only charged for what you actually used.
When you are finished querying, tell your agent:
Close the tempo session.
This ensures your unspent deposit is returned promptly. If you forget to close, funds remain in escrow until the channel expires.
Option 2: Manual Integration
For full control, you can integrate MPP directly into your application using the mppx client library and viem for EVM account management. The mppx session API wraps the standard fetch and handles the 402 negotiation, channel management, spend tracking, and payment signing transparently.
Step 1 - Install dependencies
npm install mppx viem
Step 2 - Set up your wallet and initialize a session
Create an account from a private key and initialize a Tempo session. The maxDeposit parameter sets the maximum amount (in USD) to escrow when a payment channel is opened.
import { tempo } from "mppx/client";import { privateKeyToAccount } from "viem/accounts";const account = privateKeyToAccount( process.env.PRIVATE_KEY as `0x${string}`);const session = tempo.session({ account, maxDeposit: "10" });
Step 3 - Execute a query
Use session.fetch exactly like the standard Fetch API. On the first call, the session intercepts the 402 response, opens a Tempo payment channel, and retries the request with a valid payment credential - all transparently.
Dune executes queries asynchronously. Poll the status endpoint until the state is QUERY_STATE_COMPLETED.
let state = "";do { const r = await session.fetch( `https://api.dune.com/api/v1/execution/${execution_id}/status` ); state = ((await r.json()) as { state: string }).state; if (state === "QUERY_STATE_FAILED") throw new Error("Query failed"); if (state !== "QUERY_STATE_COMPLETED") await new Promise((r) => setTimeout(r, 2_000));} while (state !== "QUERY_STATE_COMPLETED");
Step 5 - Fetch results
Once the query completes, retrieve the results. Each request is automatically paid through the open channel.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Dune Docs","description":"Official documentation for building with Dune's data platform, query engine, and API.","colors":{"primary":"#0f0f15","light":"#ffffff","dark":"#0f0f15"},"logo":{"light":"https://mintcdn.com/dune/zh-3B8LgVmyrKOaG/logo/dune-logo-light.svg?fit=max\u0026auto=format\u0026n=zh-3B8LgVmyrKOaG\u0026q=85\u0026s=6fec71d5070d0923eb2924321131b1c2","dark":"https://mintcdn.com/dune/zh-3B8LgVmyrKOaG/logo/dune-logo-dark.svg?fit=max\u0026auto=format\u0026n=zh-3B8LgVmyrKOaG\u0026q=85\u0026s=2501750983cc95aa72d40acc6f005bd9","href":"https://docs.dune.com/"},"navbar":{"links":[{"href":"mailto:support@dune.com","label":"Support"}],"primary":{"type":"button","label":"Start building","href":"https://dune.com"}},"footer":{"socials":{"linkedin":"https://www.linkedin.com/company/dune-analytics","github":"https://github.com/duneanalytics","x":"https://x.com/dune","telegram":"https://t.me/dune_updates","youtube":"https://www.youtube.com/@dunecom"}},"seo":{"metatags":{"title":"Dune Docs","description":"Official documentation for building with Dune's data platform, query engine, and API.","og:site_name":"Dune Docs","twitter:card":"summary_large_image"},"indexing":"navigable"},"fonts":{"family":"Geist"},"integrations":{"amplitude":{"apiKey":"e76ce253e6eaa36e3be8e6872101e33a"},"ga4":{"measurementId":"G-H1G057R0KN"},"gtm":{"tagId":"GTM-P46XP3Z5"}},"contextual":{"options":["chatgpt","claude","copy","view"],"display":"header"},"styling":{"latex":true},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"dune","hasAudioNarration":false,"actualSubdomain":"dune","customDomains":["docs.dune.com"],"gitSource":{"type":"github","owner":"duneanalytics","repo":"dune-docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"feedback":{"thumbs":true,"issues":true},"entitlements":{"AI_CHAT":{"status":"DISABLED"}},"buildId":"6b04822390cc9052083183c1","clientVersion":"0.0.4286","searchFilterCounts":[{"language":"default","tag":"Data Catalog","count":1405},{"language":"default","tag":"EVM Networks","count":895},{"language":"default","tag":"Decoded","count":373},{"language":"default","tag":"Raw","count":326},{"language":"default","tag":"Non-EVM Networks","count":270},{"language":"default","tag":"Curated Data","count":156},{"language":"default","tag":"Curated","count":129},{"language":"default","tag":"DEX","count":89},{"language":"default","tag":"API Reference","count":83},{"language":"default","tag":"THORChain","count":72}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[],"googleFontsInlined":true},"customCss":[{"filePath":"styles.css","content":"#topbar-cta-button>a>span,#navigation-items .sidebar-group>li>a,#sidebar-group>li>a,#search-bar-entry,.chat-assistant-floating-input>div{border-radius:9999px}.dark #topbar-cta-button>a>span{background-color:#fff}.dark #topbar-cta-button>a>span+div>span{color:#0f0f15}.dark #topbar-cta-button>a>span+div>svg{color:#0f0f15}#page-context-menu>button:first-child{border-top-left-radius:9999px;border-bottom-left-radius:9999px}#page-context-menu>button:last-child{border-top-right-radius:9999px;border-bottom-right-radius:9999px}.cta-links a,.cta-links a:visited,.cta-links a:hover,.cta-links a:active,aside a,.note-container a,[class*=\"note\"] a,[class*=\"Note\"] a,[class*=\"callout\"] a,div[class*=\"admonition\"] a,div[role=\"note\"] a{text-decoration-color:white!important;text-decoration-thickness:2px!important;text-decoration-line:underline!important}table a{text-decoration:underline!important;text-underline-offset:2px;transition:opacity 0.2s ease}table a:hover{opacity:0.7}"}]}
{"page":{"pagePath":"docs/agents/mpp","slug":"/docs/agents/mpp","pageMetadata":{"title":"Dune MPP: Pay-per-Request API Access for AI Agents","sidebarTitle":"MPP","description":"Let AI agents query Dune's API and pay per request with the Machine Payment Protocol (MPP), with no Dune account or API key.","keywords":["MPP","Machine Payment Protocol","HTTP 402","AI agents","agentic payments","Tempo","Dune API"],"icon":"credit-card","href":"/docs/agents/mpp"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Let AI agents query Dune’s API and pay per request with the Machine Payment Protocol (MPP), with no Dune account or API key.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,hr:`hr`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Table,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`MPP (Machine Payment Protocol) is an open standard for machine-to-machine HTTP micropayments built on the `,_jsx(_components.a,{href:`https://paymentauth.org/draft-httpauth-payment-00.txt`,children:`HTTP 402 challenge-response flow`}),`. Dune’s MPP integration lets agents pay per-request through a payment channel - no API keys, no user account, and no credit card required.`]}),`\n`,_jsx(Heading,{level:`2`,id:`how-it-works`,children:`How It Works`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsx(_components.li,{children:`Your client sends a request to a Dune API endpoint.`}),`\n`,_jsxs(_components.li,{children:[`Dune responds with `,_jsx(_components.strong,{children:`HTTP 402`}),` and a `,_jsx(_components.code,{children:`WWW-Authenticate: Payment`}),` challenge describing the cost.`]}),`\n`,_jsxs(_components.li,{children:[`The `,_jsx(_components.code,{children:`mppx`}),` client library automatically opens a `,_jsx(_components.strong,{children:`Tempo payment channel`}),` on the first 402, depositing funds into an on-chain escrow.`]}),`\n`,_jsx(_components.li,{children:`Subsequent requests are authenticated with signed channel vouchers deducted from the deposit.`}),`\n`,_jsxs(_components.li,{children:[`When you are done, you `,_jsx(_components.strong,{children:`close the session`}),` and any unspent deposit is returned to your wallet.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`available-endpoints`,children:`Available Endpoints`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Endpoint`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`POST /v1/sql/execute`})}),_jsx(_components.td,{children:`Execute a SQL query`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`GET /v1/execution/:execution_id/results`})}),_jsx(_components.td,{children:`Fetch JSON results for an execution`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`GET /v1/execution/:execution_id/csv`})}),_jsx(_components.td,{children:`Download CSV results for an execution`})]})]})]}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`option-1-agentic-integration`,children:`Option 1: Agentic Integration`}),`\n`,_jsx(_components.p,{children:`The fastest way to get started. Ask your AI coding agent to set up Tempo and run a query on Dune - no manual code required. This works with any agent that supports skills or tool use, including Claude Code, Cursor, OpenAI Codex, OpenCode, and others.`}),`\n`,_jsx(Heading,{level:`3`,id:`getting-started`,children:`Getting Started`}),`\n`,_jsx(_components.p,{children:`Simply give your agent the following prompt:`}),`\n`,_jsx(CodeBlock,{numberOfLines:`5`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`5`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Read https://tempo.xyz/SKILL.md and set up tempo.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`After that, use MPP to run the following query on Dune:`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`SELECT * FROM ethereum.transactions LIMIT 10`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(_components.p,{children:`Your agent will:`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsx(_components.li,{children:`Read the Tempo skill instructions and configure itself`}),`\n`,_jsx(_components.li,{children:`Open a payment channel funded from your crypto wallet`}),`\n`,_jsx(_components.li,{children:`Execute the query against Dune’s API via MPP`}),`\n`,_jsx(_components.li,{children:`Return the results directly in your conversation`}),`\n`]}),`\n`,_jsx(_components.p,{children:`No Dune account, no API key, and no credit card needed - you pay per-request with crypto.`}),`\n`,_jsx(Heading,{level:`3`,id:`closing-your-session`,children:`Closing Your Session`}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Always ask your agent to `,_jsx(_components.strong,{children:`close the session`}),` when you are done. Closing the session settles the payment channel on-chain and refunds any reserved funds back to your wallet - you are only charged for what you actually used.`]})}),`\n`,_jsx(_components.p,{children:`When you are finished querying, tell your agent:`}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Close the tempo session.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(_components.p,{children:`This ensures your unspent deposit is returned promptly. If you forget to close, funds remain in escrow until the channel expires.`}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`option-2-manual-integration`,children:`Option 2: Manual Integration`}),`\n`,_jsxs(_components.p,{children:[`For full control, you can integrate MPP directly into your application using the `,_jsx(_components.a,{href:`https://github.com/wevm/mppx`,children:_jsx(_components.code,{children:`mppx`})}),` client library and `,_jsx(_components.a,{href:`https://viem.sh`,children:_jsx(_components.code,{children:`viem`})}),` for EVM account management. The `,_jsx(_components.code,{children:`mppx`}),` session API wraps the standard `,_jsx(_components.code,{children:`fetch`}),` and handles the 402 negotiation, channel management, spend tracking, and payment signing transparently.`]}),`\n`,_jsx(Heading,{level:`3`,id:`step-1-install-dependencies`,children:`Step 1 - Install dependencies`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` mppx`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` viem`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`step-2-set-up-your-wallet-and-initialize-a-session`,children:`Step 2 - Set up your wallet and initialize a session`}),`\n`,_jsxs(_components.p,{children:[`Create an account from a private key and initialize a Tempo session. The `,_jsx(_components.code,{children:`maxDeposit`}),` parameter sets the maximum amount (in USD) to escrow when a payment channel is opened.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`7`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`tempo`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"mppx/client\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`privateKeyToAccount`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"viem/accounts\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` account`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` privateKeyToAccount`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` process`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`env`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`PRIVATE_KEY`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` as`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `0x\"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` session`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` tempo`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`session`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`account`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`maxDeposit:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"10\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`step-3-execute-a-query`,children:`Step 3 - Execute a query`}),`\n`,_jsxs(_components.p,{children:[`Use `,_jsx(_components.code,{children:`session.fetch`}),` exactly like the standard Fetch API. On the first call, the session intercepts the 402 response, opens a Tempo payment channel, and retries the request with a valid payment credential - all transparently.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`6`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` execRes`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` session`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`fetch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://api.dune.com/api/v1/sql/execute\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` method:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"POST\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` headers:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Content-Type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"application/json\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` body:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` JSON`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`stringify`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`sql:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"SELECT * FROM ethereum.transactions LIMIT 10\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }),`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`execution_id`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` execRes`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`json`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`as`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`execution_id`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` };`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`step-4-poll-until-the-query-completes`,children:`Step 4 - Poll until the query completes`}),`\n`,_jsxs(_components.p,{children:[`Dune executes queries asynchronously. Poll the status endpoint until the state is `,_jsx(_components.code,{children:`QUERY_STATE_COMPLETED`}),`.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`10`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`10`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`let`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` state`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`do`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` r`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` session`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`fetch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `https://api.dune.com/api/v1/execution/\"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`execution_id`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"/status`\"})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` );`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` state`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ((`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` r`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`json`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`as`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`state`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }).`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`state`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`state`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ===`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"QUERY_STATE_FAILED\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`throw`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` Error`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Query failed\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`state`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` !==`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"QUERY_STATE_COMPLETED\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` Promise`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`((`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`r`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` setTimeout`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`r`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`2_000`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`));`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`} `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`while`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`state`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` !==`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"QUERY_STATE_COMPLETED\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`step-5-fetch-results`,children:`Step 5 - Fetch results`}),`\n`,_jsx(_components.p,{children:`Once the query completes, retrieve the results. Each request is automatically paid through the open channel.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` resultsRes`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` session`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`fetch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `https://api.dune.com/api/v1/execution/\"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`execution_id`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"/results`\"})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` resultsRes`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`json`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`());`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`step-6-close-the-session`,children:`Step 6 - Close the session`}),`\n`,_jsx(_components.p,{children:`When you are finished, close the session to settle on-chain and reclaim any unspent deposit. You are only charged for what you used.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` session`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`close`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`]})})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`learn-more`,children:`Learn More`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsxs(_components.a,{href:`https://github.com/wevm/mppx`,children:[_jsx(_components.code,{children:`mppx`}),` client library`]}),` - TypeScript SDK for MPP`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`https://paymentauth.org/`,children:`paymentauth.org`}),` - protocol specifications and registry`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/api-reference/overview/introduction`,children:`Dune API Reference`}),` - full list of available API endpoints`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/docs/agents/mcp`,children:`Dune MCP`}),` - connect Claude, Cursor, Codex, and other MCP clients to Dune with your Dune account`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/docs/agents/cli-and-skills`,children:`Dune CLI \u0026 Skills`}),` - give AI coding agents access to Dune from the terminal`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`https://dune.com/agents`,children:`Agents on dune.com`}),` - how AI agents work with Dune data`]}),`\n`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Dune MPP: Pay-per-Request API Access for AI Agents","sidebarTitle":"MPP","description":"Let AI agents query Dune's API and pay per request with the Machine Payment Protocol (MPP), with no Dune account or API key.","keywords":["MPP","Machine Payment Protocol","HTTP 402","AI agents","agentic payments","Tempo","Dune API"],"icon":"credit-card","href":"/docs/agents/mpp"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"How It Works","slug":"how-it-works","depth":2,"children":[]},{"title":"Available Endpoints","slug":"available-endpoints","depth":2,"children":[]},{"title":"Option 1: Agentic Integration","slug":"option-1-agentic-integration","depth":2,"children":[{"title":"Getting Started","slug":"getting-started","depth":3,"children":[]},{"title":"Closing Your Session","slug":"closing-your-session","depth":3,"children":[]}]},{"title":"Option 2: Manual Integration","slug":"option-2-manual-integration","depth":2,"children":[{"title":"Step 1 - Install dependencies","slug":"step-1-install-dependencies","depth":3,"children":[]},{"title":"Step 2 - Set up your wallet and initialize a session","slug":"step-2-set-up-your-wallet-and-initialize-a-session","depth":3,"children":[]},{"title":"Step 3 - Execute a query","slug":"step-3-execute-a-query","depth":3,"children":[]},{"title":"Step 4 - Poll until the query completes","slug":"step-4-poll-until-the-query-completes","depth":3,"children":[]},{"title":"Step 5 - Fetch results","slug":"step-5-fetch-results","depth":3,"children":[]},{"title":"Step 6 - Close the session","slug":"step-6-close-the-session","depth":3,"children":[]}]},{"title":"Learn More","slug":"learn-more","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/_mintlify/custom/dune/3dc9988ffc23fc85/favicon-switcher.js","/_mintlify/custom/dune/11037b9cc10a9f51/amplitude.js"],"subdomain":"dune","siteName":"Dune Docs","title":"Dune MPP: Pay-per-Request API Access for AI Agents - Dune Docs","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-11-20T19:30:31.505Z","originalFileLocation":"docs/agents/mpp.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Let AI agents query Dune\u0026#x27;s API and pay per request with the Machine Payment Protocol (MPP), with no Dune account or API key.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Dune Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"https://mintlify.s3.us-west-1.amazonaws.com/dune/_generated/favicon/apple-touch-icon.png?v=3\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"https://mintlify.s3.us-west-1.amazonaws.com/dune/_generated/favicon/favicon-32x32.png?v=3\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"https://mintlify.s3.us-west-1.amazonaws.com/dune/_generated/favicon/favicon-16x16.png?v=3\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"https://mintlify.s3.us-west-1.amazonaws.com/dune/_generated/favicon/favicon.ico?v=3\">\u003cmeta data-mint-head property=\"og:title\" content=\"Dune MPP: Pay-per-Request API Access for AI Agents - Dune Docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"Let AI agents query Dune\u0026#x27;s API and pay per request with the Machine Payment Protocol (MPP), with no Dune account or API key.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Dune Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.dune.com/docs/agents/mpp\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://dune.mintlify.site/_mintlify/api/og/v2?division=Agents\u0026amp;title=Dune+MPP%3A+Pay-per-Request+API+Access+for+AI+Agents\u0026amp;description=Let+AI+agents+query+Dune%27s+API+and+pay+per+request+with+the+Machine+Payment+Protocol+%28MPP%29%2C+with+no+Dune+account+or+API+key.\u0026amp;theme=58ddaefd9b143c3f6e95ec55\u0026amp;signature=459a23d541b64af68ee7abca4a5268d37511d0fc5f3df85d66cf250f7f4bafc2\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Dune MPP: Pay-per-Request API Access for AI Agents - Dune Docs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Let AI agents query Dune\u0026#x27;s API and pay per request with the Machine Payment Protocol (MPP), with no Dune account or API key.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://dune.mintlify.site/_mintlify/api/og/v2?division=Agents\u0026amp;title=Dune+MPP%3A+Pay-per-Request+API+Access+for+AI+Agents\u0026amp;description=Let+AI+agents+query+Dune%27s+API+and+pay+per+request+with+the+Machine+Payment+Protocol+%28MPP%29%2C+with+no+Dune+account+or+API+key.\u0026amp;theme=58ddaefd9b143c3f6e95ec55\u0026amp;signature=459a23d541b64af68ee7abca4a5268d37511d0fc5f3df85d66cf250f7f4bafc2\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"https://mintlify.s3.us-west-1.amazonaws.com/dune/_generated/favicon/browserconfig.xml?v=3\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Dune Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#0f0f15\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.dune.com/docs/agents/mpp\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/agents/mpp.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.dune.com/#organization\",\"name\":\"Dune Docs\",\"url\":\"https://docs.dune.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/dune/zh-3B8LgVmyrKOaG/logo/dune-logo-light.svg?fit=max\u0026auto=format\u0026n=zh-3B8LgVmyrKOaG\u0026q=85\u0026s=6fec71d5070d0923eb2924321131b1c2\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.dune.com#website\",\"name\":\"Dune Docs\",\"url\":\"https://docs.dune.com\",\"publisher\":{\"@id\":\"https://docs.dune.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.dune.com/docs/agents/mpp#webpage\",\"url\":\"https://docs.dune.com/docs/agents/mpp\",\"name\":\"Dune MPP: Pay-per-Request API Access for AI Agents\",\"description\":\"Let AI agents query Dune's API and pay per request with the Machine Payment Protocol (MPP), with no Dune account or API key.\",\"dateModified\":\"2026-11-20T19:30:31.505Z\",\"isPartOf\":{\"@id\":\"https://docs.dune.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.dune.com/docs/agents/mpp#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.dune.com/docs/agents/mpp#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Agents\",\"item\":\"https://docs.dune.com/docs/agents/mcp\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Dune MPP: Pay-per-Request API Access for AI Agents\",\"item\":\"https://docs.dune.com/docs/agents/mpp\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.dune.com/docs/agents/mpp#article\",\"headline\":\"Dune MPP: Pay-per-Request API Access for AI Agents\",\"name\":\"Dune MPP: Pay-per-Request API Access for AI Agents\",\"description\":\"Let AI agents query Dune's API and pay per request with the Machine Payment Protocol (MPP), with no Dune account or API key.\",\"url\":\"https://docs.dune.com/docs/agents/mpp\",\"mainEntityOfPage\":{\"@id\":\"https://docs.dune.com/docs/agents/mpp#webpage\"},\"dateModified\":\"2026-11-20T19:30:31.505Z\",\"keywords\":\"MPP, Machine Payment Protocol, HTTP 402, AI agents, agentic payments, Tempo, Dune API\",\"publisher\":{\"@id\":\"https://docs.dune.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.dune.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Dune Docs\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Dune Docs\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/docs/agents/mpp.md","siteName":"Dune Docs","nav":{"global":null,"tabs":[{"tab":"Docs","pages":[{"title":"Dune Docs","sidebarTitle":"Introduction","icon":"house","href":""},{"title":"Products Overview","icon":"grid-2","href":"/docs/product-comparison"},{"title":"Changelog","icon":"clock-rotate-left","href":"/docs/changelog"},{"title":"Data Changelog","icon":"database","href":"/docs/data-changelog"},{"group":"Use Cases","pages":[{"title":"Analytics","sidebarTitle":"Analytics","icon":"chart-line","href":"/docs/use-cases/analytics"},{"title":"Engineering","sidebarTitle":"Engineering","icon":"code","href":"/docs/use-cases/engineering"},{"title":"Accounting, Audit \u0026 AML","sidebarTitle":"Accounting, Audit \u0026 AML","icon":"scale-balanced","href":"/docs/use-cases/accounting-audit-aml"}]},{"group":"Data Hub","pages":[{"title":"Data Hub Overview","icon":"star","sidebarTitle":"Overview","href":"/web-app/overview"},{"group":"Write and Run Queries","icon":"code","pages":[{"title":"Query Editor Overview","icon":"code","sidebarTitle":"Query Editor Overview","href":"/web-app/query-editor/index"},{"title":"Create your first query","icon":"code","href":"/learning/how-tos/create-your-first-query"},{"title":"Writing Queries","icon":"pen","href":"/web-app/query-editor/query-window"},{"title":"Find Data Tables with the Data Explorer","icon":"magnifying-glass","sidebarTitle":"Find Data Tables","href":"/web-app/query-editor/data-explorer"},{"title":"Using Parameters","icon":"sliders","href":"/web-app/query-editor/parameters"},{"title":"Query Templates","icon":"file-code","href":"/learning/how-tos/query-templates"},{"title":"AI Query Tools","icon":"robot","sidebarTitle":"AI Query Tools","href":"/web-app/dune-ai"}]},{"group":"Visualize and Present Results","icon":"chart-bar","pages":[{"title":"Create your first visualization","icon":"chart-line","href":"/learning/how-tos/create-your-first-visualization"},{"title":"Charts and Graphs","icon":"chart-bar","sidebarTitle":"Charts and Graphs","href":"/web-app/visualizations/charts-graphs"},{"title":"Counters","icon":"hashtag","sidebarTitle":"Counters","href":"/web-app/visualizations/counters"},{"title":"Tables","icon":"table","sidebarTitle":"Tables","href":"/web-app/visualizations/tables"},{"title":"Build Dashboards","icon":"grid-2","sidebarTitle":"Build Dashboards","href":"/web-app/dashboards"}]},{"group":"Automate and Monitor","icon":"clock","pages":[{"title":"Schedule Queries and Dashboards","icon":"clock","sidebarTitle":"Schedule Queries","href":"/web-app/query-editor/query-scheduler"},{"title":"Set Up Alerts","icon":"bell","sidebarTitle":"Set Up Alerts","href":"/web-app/alerts"},{"title":"Query Lineage","icon":"sitemap","href":"/web-app/query-editor/query-lineage"},{"title":"Version History","icon":"clock-rotate-left","href":"/web-app/query-editor/version-history"}]},{"title":"Share and Embed","icon":"share-nodes","sidebarTitle":"Share and Embed","href":"/web-app/share"},{"group":"Import and Export Data","icon":"arrow-right-arrow-left","pages":[{"title":"Upload Data","icon":"upload","href":"/web-app/upload-data"},{"title":"Export Data","sidebarTitle":"Export Data","icon":"file-export","href":"/learning/how-tos/export-data-out"}]},{"title":"Search and Discover Content","icon":"magnifying-glass","sidebarTitle":"Search and Discover","href":"/web-app/search"},{"group":"Decode Smart Contracts","icon":"file-code","pages":[{"title":"How Contract Decoding Works","icon":"file-code","sidebarTitle":"How Decoding Works","href":"/web-app/decoding/decoding-contracts"},{"title":"Submission Best Practices","icon":"check","sidebarTitle":"Submission Best Practices","href":"/web-app/decoding/best-practices"},{"title":"Contract Submission Guide","sidebarTitle":"Contract Submission Guide","icon":"file-import","href":"/web-app/decoding/short-guide-contract-submission"},{"title":"Solana Program Decoding Submissions","icon":"file-code","sidebarTitle":"Solana Decoding","href":"/web-app/decoding/solana-decoding-submissions"},{"title":"Multichain Decoding","icon":"link","href":"/web-app/decoding/multichain-decoding"},{"title":"Decoding FAQs","icon":"circle-question","sidebarTitle":"FAQs","href":"/web-app/decoding/faqs"}]},{"group":"Manage Your Team","icon":"users","pages":[{"title":"Teams and Roles","icon":"users","sidebarTitle":"Teams and Roles","href":"/web-app/teams"},{"title":"Organizations","sidebarTitle":"Organizations","icon":"building","href":"/web-app/organizations"},{"title":"Google SSO Domain Restriction","sidebarTitle":"Google SSO","icon":"google","href":"/web-app/google-sso-domain-restriction"},{"title":"Okta SSO Setup","sidebarTitle":"Okta SSO","icon":"key","href":"/web-app/okta-sso"}]},{"title":"Enterprise Plan","sidebarTitle":"Enterprise Plan","icon":"building","href":"/enterprise/data-hub/overview"}]},{"group":"Data API","pages":[{"title":"Data API Overview","sidebarTitle":"Data API Overview","icon":"star","href":"/api-reference/api-overview"}]},{"group":"Agents","pages":[{"title":"Dune MCP: Official MCP Server for Claude, Cursor, Codex, and OpenCode","sidebarTitle":"MCP","icon":"robot","href":"/docs/agents/mcp"},{"title":"Dune CLI \u0026 Agent Skills for AI Coding Agents","sidebarTitle":"CLI \u0026 Skills","description":"Give Claude Code, Cursor, Codex, OpenCode, and other AI coding agents access to Dune's blockchain data with the official Dune CLI and Dune Agent Skill.","icon":"terminal","href":"/docs/agents/cli-and-skills"},{"title":"Dune MPP: Pay-per-Request API Access for AI Agents","sidebarTitle":"MPP","icon":"credit-card","href":"/docs/agents/mpp"}]},{"group":"Transform your Data","pages":[{"title":"dbt Connector Overview","description":"Run production-grade dbt projects directly on Dune with full incremental model support","icon":"star","href":"/api-reference/connectors/dbt/overview"},{"title":"Getting Started","icon":"rocket","href":"/api-reference/connectors/dbt/getting-started"},{"title":"Incremental Models","icon":"layer-group","href":"/api-reference/connectors/dbt/incremental-models"},{"title":"dbt Connector + Datashare","icon":"share-nodes","href":"/api-reference/connectors/dbt/datashares"},{"title":"CI/CD \u0026 Workflows","icon":"code-branch","href":"/api-reference/connectors/dbt/cicd-workflows"},{"title":"Pricing \u0026 Best Practices","icon":"credit-card","href":"/api-reference/connectors/dbt/pricing-best-practices"},{"title":"Supported SQL Operations","icon":"code","href":"/api-reference/connectors/sql-operations"}]},{"group":"BI Visualization Tools","pages":[{"title":"Trino Connector Overview","icon":"star","href":"/api-reference/connectors/trino/overview"},{"title":"Hex","icon":"cube","href":"/api-reference/connectors/trino/hex"},{"title":"Metabase","icon":"chart-bar","href":"/api-reference/connectors/trino/metabase"},{"title":"DBeaver","icon":"database","href":"/api-reference/connectors/trino/dbeaver"},{"title":"Trino SDKs","icon":"plug","href":"/api-reference/connectors/trino/sdks"}]},{"group":"Dune Datashare","pages":[{"title":"Datashare Overview","sidebarTitle":"Datashare Overview","icon":"star","href":"/datashare/datashare"},{"title":"Getting Started with Datashare","sidebarTitle":"Getting Started","icon":"rocket","href":"/datashare/datashare-trial"},{"title":"Databricks Datashare","sidebarTitle":"Databricks","icon":"rectangle-terminal","href":"/datashare/datashare-databricks"},{"title":"Snowflake Datashare","sidebarTitle":"Snowflake","icon":"snowflake","href":"/datashare/datashare-snowflake"},{"title":"BigQuery Datashare","sidebarTitle":"BigQuery","icon":"cloud","href":"/datashare/datashare-bigquery"},{"title":"S3 Datashare","sidebarTitle":"S3 Export","icon":"aws","href":"/datashare/datashare-s3"},{"title":"Datashare FAQs","sidebarTitle":"FAQs","icon":"circle-question","href":"/datashare/datashare-faqs"},{"title":"Datashare Enterprise","icon":"building","href":"/enterprise/datashare/overview"}]}]},{"tab":"Data Catalog","pages":[{"title":"Data Catalog","href":"/data-catalog/overview"}]},{"tab":"API Reference","pages":[{"title":"API Reference","href":"/api-reference/overview/introduction"}]},{"tab":"SQL Query Engine","pages":[{"title":"SQL Query Engine","href":"/query-engine/overview"}]},{"tab":"Market Data Feeds","pages":[{"title":"Market Data Feeds","href":"/market-data-feeds/overview"}]},{"tab":"Resources","pages":[{"title":"Resources","href":"/resources/credits-billing/overview"}]}]},"basePath":"","title":"Dune MPP: Pay-per-Request API Access for AI Agents - Dune Docs","deploymentId":"dpl_G6E2ur2Zjq51xGTVZPSFXsWoTxCu","buildId":"dpl_G6E2ur2Zjq51xGTVZPSFXsWoTxCu","dynamics":[],"chunks":[]}