This endpoint allows you to run Python code in a secure sandbox environment. The code is executed using a secure code interpreter and returns both stdout and stderr logs.
{ "commands": "string", // Optional. Install pip packages before code execution e.g. pip install pandas "code": "string", // Required. The Python code to be executed "parseJson": boolean, // Optional. Whether to parse stdout/stderr as JSON}
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"DumplingAI Docs","colors":{"primary":"#000","light":"#fdfdfd","dark":"#000"},"logo":"https://mintcdn.com/dumplingai/ovQfojsBnkaBEyWP/dumplingai-logo.svg?fit=max\u0026auto=format\u0026n=ovQfojsBnkaBEyWP\u0026q=85\u0026s=46740c45e1bef65a42e4a799407a5d32","favicon":"https://mintcdn.com/dumplingai/ovQfojsBnkaBEyWP/dumplingai-logo.svg?fit=max\u0026auto=format\u0026n=ovQfojsBnkaBEyWP\u0026q=85\u0026s=46740c45e1bef65a42e4a799407a5d32","navbar":{"links":[{"href":"mailto:help@dumplingai.com","label":"Support"}],"primary":{"type":"button","label":"Dashboard","href":"https://app.dumplingai.com"}},"footer":{"socials":{"twitter":"https://twitter.com/dumplingai","linkedin":"https://www.linkedin.com/company/dumplingai"}},"contextual":{"options":["copy","view","chatgpt","claude"],"display":"header"},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"dumplingai","hasAudioNarration":false,"actualSubdomain":"dumplingai","customDomains":["docs.dumplingai.com"],"gitSource":{"type":"github","owner":"dumplingai","repo":"dumplingai","deployBranch":"main","contentDirectory":"docs","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6a21e638b8c65e77d6677ad4","collectionId":"71f4a9e0-7aae-4b61-a7a2-ec8cadaf8568","schemaVersion":"v2"},"entitlements":{},"buildId":"6a21e638b8c65e77d6677ad4:success","clientVersion":"0.0.4021","searchFilterCounts":[{"language":"default","tag":"API Reference","count":52},{"language":"default","tag":"Data APIs","count":23},{"language":"default","tag":"Documentation","count":14},{"language":"default","tag":"Document Processing","count":10},{"language":"default","tag":"Core Features","count":7},{"language":"default","tag":"Start Here","count":6},{"language":"default","tag":"Overview","count":5},{"language":"default","tag":"Web Scraping","count":4},{"language":"default","tag":"Usage APIs","count":3},{"language":"default","tag":"AI","count":2}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"pause-universal-search-reconcile","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"per-site-search-delta","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-private-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"api-reference/endpoint/run-python-code","slug":"/api-reference/endpoint/run-python-code","pageMetadata":{"title":"Run Python Code","openapi":"POST /api/v1/run-python-code","description":"Execute sandboxed Python code and return stdout, stderr, and logs.","href":"/api-reference/endpoint/run-python-code"},"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: \"Execute sandboxed Python code and return stdout, stderr, and logs.\"\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={code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`2`,id:`description`,children:`Description`}),`\n`,_jsx(_components.p,{children:`This endpoint allows you to run Python code in a secure sandbox environment. The code is executed using a secure code interpreter and returns both stdout and stderr logs.`}),`\n`,_jsx(Heading,{level:`2`,id:`endpoint`,children:`Endpoint`}),`\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:`POST https://app.dumplingai.com/api/v1/run-python-code`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(Heading,{level:`2`,id:`headers`,children:`Headers`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Content-Type:`}),` `,_jsx(_components.code,{children:`application/json`})]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Authorization:`}),` Bearer `,_jsx(_components.code,{children:`\u003cAPI_KEY>`}),` (required)`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`request-body`,children:`Request Body`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`json`,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:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`5`,children:[_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:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"commands\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"string\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Optional. Install pip packages before code execution e.g. pip install pandas`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"code\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"string\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Required. The Python code to be executed`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"parseJson\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#82071E`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F44747`,\"--shiki-dark-font-style\":`inherit`},children:`boolean`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Optional. Whether to parse stdout/stderr as JSON`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`responses`,children:`Responses`}),`\n`,_jsx(Heading,{level:`3`,id:`success-200`,children:`Success (200)`}),`\n`,_jsx(_components.p,{children:`Returns the output logs from the executed Python code.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`json`,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:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`6`,children:[_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:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"logs\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"stdout\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#82071E`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F44747`,\"--shiki-dark-font-style\":`inherit`},children:`string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[] `}),_jsx(_components.span,{style:{color:`#82071E`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F44747`,\"--shiki-dark-font-style\":`inherit`},children:`|`}),_jsx(_components.span,{style:{color:`#82071E`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F44747`,\"--shiki-dark-font-style\":`inherit`},children:` any`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Array of stdout messages or parsed JSON`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"stderr\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#82071E`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F44747`,\"--shiki-dark-font-style\":`inherit`},children:`string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[] `}),_jsx(_components.span,{style:{color:`#82071E`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F44747`,\"--shiki-dark-font-style\":`inherit`},children:`|`}),_jsx(_components.span,{style:{color:`#82071E`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#F44747`,\"--shiki-dark-font-style\":`inherit`},children:` any`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Array of stderr messages or parsed JSON`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_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`]})})}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Content-Type:`}),` application/json`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`X-RateLimit-Limit:`}),` The rate limit for the user.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`X-RateLimit-Remaining:`}),` The remaining number of requests for the user.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`3`,id:`bad-request-400`,children:`Bad Request (400)`}),`\n`,_jsx(_components.p,{children:`Returned if the request is missing required parameters.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`json`,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:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`3`,children:[_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:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"error\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"code parameter is required\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`internal-server-error-500`,children:`Internal Server Error (500)`}),`\n`,_jsx(_components.p,{children:`Returned if there’s an error during code execution.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`json`,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:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`7`,children:[_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:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"error\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"string\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"value\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"string\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"traceback\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"string\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_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`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`example-request`,children:`Example Request`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`8`,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:`8`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -X`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` POST`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` https://app.dumplingai.com/api/v1/run-python-code`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`-H `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Content-Type: application/json\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`-H `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Authorization: Bearer YOUR_API_KEY\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`-d `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"commands\": \"pip install pandas\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"code\": \"import pandas as pd\\\\ndata = {\\\\\"name\\\\\": [\\\\\"John\\\\\", \\\\\"Jane\\\\\"], \\\\\"age\\\\\": [30, 25]}\\\\ndf = pd.DataFrame(data)\\\\nprint(df.to_json())\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"parseJson\": true`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}'`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`example-response`,children:`Example Response`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`9`,language:`json`,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:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`9`,children:[_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:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"logs\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"stdout\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: { `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"0\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"John\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"1\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Jane\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"age\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: { `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"0\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`30`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"1\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`25`}),_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:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"stderr\"`}),_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`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`notes`,children:`Notes`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`This endpoint uses 50 credits per request.`}),`\n`,_jsx(_components.li,{children:`Code execution timeout is set to 10 seconds`}),`\n`,_jsx(_components.li,{children:`The code is executed in a secure sandbox environment`}),`\n`,_jsxs(_components.li,{children:[`When `,_jsx(_components.code,{children:`parseJson`}),` is true, the system will attempt to parse stdout and stderr as JSON`]}),`\n`,_jsxs(_components.li,{children:[`You can install Python packages by using the `,_jsx(_components.code,{children:`commands`}),` parameter e.g. `,_jsx(_components.code,{children:`pip install pandas`})]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`rate-limiting`,children:`Rate Limiting`}),`\n`,_jsxs(_components.p,{children:[`Rate limit headers (`,_jsx(_components.code,{children:`X-RateLimit-Limit`}),` and `,_jsx(_components.code,{children:`X-RateLimit-Remaining`}),`) are included in the response to indicate the user’s current rate limit status.`]})]})}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":"Run Python Code","openapi":"POST /api/v1/run-python-code","description":"Execute sandboxed Python code and return stdout, stderr, and logs.","href":"/api-reference/endpoint/run-python-code"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Description","slug":"description","depth":2,"children":[]},{"title":"Endpoint","slug":"endpoint","depth":2,"children":[]},{"title":"Headers","slug":"headers","depth":2,"children":[]},{"title":"Request Body","slug":"request-body","depth":2,"children":[]},{"title":"Responses","slug":"responses","depth":2,"children":[{"title":"Success (200)","slug":"success-200","depth":3,"children":[]},{"title":"Bad Request (400)","slug":"bad-request-400","depth":3,"children":[]},{"title":"Internal Server Error (500)","slug":"internal-server-error-500","depth":3,"children":[]}]},{"title":"Example Request","slug":"example-request","depth":2,"children":[]},{"title":"Example Response","slug":"example-response","depth":2,"children":[]},{"title":"Notes","slug":"notes","depth":2,"children":[]},{"title":"Rate Limiting","slug":"rate-limiting","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/_mintlify/custom/dumplingai/88b5ebac9e923e56/featurebase-messenger.js"],"openApiReferenceData":{"operation":{"tags":["Developer Tools"],"summary":"Run Python code","operationId":"runPythonCode","description":"Execute sandboxed Python code and return stdout, stderr, and logs.","requestBody":"75dd040e-b564-4c17-9d78-98a2b802ae6b","responses":{"200":"35e41c07-8edb-4875-87e8-b67b46620b67","400":"417ed4cd-b722-484a-b09a-17c1b47f359b","401":"1a2854f9-435e-40a8-992b-114b4478dde7","500":"8e2574f5-f2b7-4a3d-b68a-d7dc925fc87f"},"method":"post","type":"path","servers":["d723038e-161a-49c3-97eb-5fe7a380caa9"],"security":["5e873bfd-9277-42d8-b67f-596c2b666f90"],"path":"/api/v1/run-python-code","baseUrlOptions":["https://app.dumplingai.com"],"title":"Run Python code","codeSamples":[],"requiredOnlyExamples":false,"requestExampleType":"generated","responseExampleType":"generated"},"dependencies":{"parameters":{},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"Request payload for sandboxed code execution.","required":["code"],"properties":{"code":{"type":"string","description":"Source code to execute inside the sandbox.","isRequired":true,"uniqueKey":"code","typeLabel":"string"},"commands":{"type":"array","description":"Shell commands to run before executing the code.","items":{"type":"string","uniqueKey":"commands.items.[INDEX]","typeLabel":"string"},"uniqueKey":"commands","typeLabel":"string[]"},"parseJson":{"type":"boolean","description":"Attempt to parse stdout/stderr as JSON arrays.","uniqueKey":"parseJson","typeLabel":"boolean"},"requestSource":{"type":"string","description":"Optional identifier describing where the API request originated.","enum":["API","WEB","MAKE_DOT_COM","ZAPIER","N8N","PLAYGROUND","DEFAULT_AUTOMATION","AGENT_PREVIEW","AGENT_LIVE","AUTOPILOT","STUDIO"],"uniqueKey":"requestSource","typeLabel":"enum\u003cstring>"}},"additionalProperties":false,"uniqueKey":"","typeLabel":"object"},"examples":{"default":{"title":"default","value":{"code":"def main():\n return 'hi'"}}},"exampleType":"examples"}},"exampleType":"examples"},"responses":{"35e41c07-8edb-4875-87e8-b67b46620b67":{"description":"Execution results returned.","content":{"application/json":{"schema":{"type":"object","required":["logs"],"properties":{"logs":{"type":"object","required":["stdout","stderr"],"properties":{"stdout":{"oneOf":[{"type":"array","items":{"type":"string","uniqueKey":"logs.stdout.oneOf.0.items.[INDEX]","typeLabel":"string"},"description":"Captured log output, returned either as raw lines or parsed JSON when `parseJson` is enabled.","isRequired":true,"uniqueKey":"logs.stdout.oneOf.0","typeLabel":"string[]"},{"type":"object","description":"Captured log output, returned either as raw lines or parsed JSON when `parseJson` is enabled.","additionalProperties":true,"isRequired":true,"uniqueKey":"logs.stdout.oneOf.1","typeLabel":"object"},{"type":"array","items":{"oneOf":[{}],"uniqueKey":"logs.stdout.oneOf.2.items.[INDEX]","typeLabel":"any"},"description":"Captured log output, returned either as raw lines or parsed JSON when `parseJson` is enabled.","isRequired":true,"uniqueKey":"logs.stdout.oneOf.2","typeLabel":"any[]"},{"type":"string","description":"Captured log output, returned either as raw lines or parsed JSON when `parseJson` is enabled.","isRequired":true,"uniqueKey":"logs.stdout.oneOf.3","typeLabel":"string"},{"type":"number","description":"Captured log output, returned either as raw lines or parsed JSON when `parseJson` is enabled.","isRequired":true,"uniqueKey":"logs.stdout.oneOf.4","typeLabel":"number"},{"type":"boolean","description":"Captured log output, returned either as raw lines or parsed JSON when `parseJson` is enabled.","isRequired":true,"uniqueKey":"logs.stdout.oneOf.5","typeLabel":"boolean"}],"isRequired":true,"uniqueKey":"logs.stdout","typeLabel":"string[] | object | any[] | string | number | boolean"},"stderr":{"oneOf":[{"type":"array","items":{"type":"string","uniqueKey":"logs.stderr.oneOf.0.items.[INDEX]","typeLabel":"string"},"description":"Captured log output, returned either as raw lines or parsed JSON when `parseJson` is enabled.","isRequired":true,"uniqueKey":"logs.stderr.oneOf.0","typeLabel":"string[]"},{"type":"object","description":"Captured log output, returned either as raw lines or parsed JSON when `parseJson` is enabled.","additionalProperties":true,"isRequired":true,"uniqueKey":"logs.stderr.oneOf.1","typeLabel":"object"},{"type":"array","items":{"oneOf":[{}],"uniqueKey":"logs.stderr.oneOf.2.items.[INDEX]","typeLabel":"any"},"description":"Captured log output, returned either as raw lines or parsed JSON when `parseJson` is enabled.","isRequired":true,"uniqueKey":"logs.stderr.oneOf.2","typeLabel":"any[]"},{"type":"string","description":"Captured log output, returned either as raw lines or parsed JSON when `parseJson` is enabled.","isRequired":true,"uniqueKey":"logs.stderr.oneOf.3","typeLabel":"string"},{"type":"number","description":"Captured log output, returned either as raw lines or parsed JSON when `parseJson` is enabled.","isRequired":true,"uniqueKey":"logs.stderr.oneOf.4","typeLabel":"number"},{"type":"boolean","description":"Captured log output, returned either as raw lines or parsed JSON when `parseJson` is enabled.","isRequired":true,"uniqueKey":"logs.stderr.oneOf.5","typeLabel":"boolean"}],"isRequired":true,"uniqueKey":"logs.stderr","typeLabel":"string[] | object | any[] | string | number | boolean"}},"additionalProperties":false,"isRequired":true,"uniqueKey":"logs","typeLabel":"object"}},"additionalProperties":false,"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"logs":{"stdout":["\u003cstring>"],"stderr":["\u003cstring>"]}}}},"exampleType":"generated"}},"exampleType":"generated"},"417ed4cd-b722-484a-b09a-17c1b47f359b":{"description":"Invalid request payload.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","description":"Human-readable description of what went wrong.","isRequired":true,"uniqueKey":"error","typeLabel":"string"}},"required":["error"],"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":"\u003cstring>"}}},"exampleType":"generated"}},"exampleType":"generated"},"1a2854f9-435e-40a8-992b-114b4478dde7":{"description":"Missing or invalid API key.","content":{"_mintlify/placeholder":{"schema":{"type":"object","description":""}}}},"8e2574f5-f2b7-4a3d-b68a-d7dc925fc87f":{"description":"Unexpected server error.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","description":"Human-readable description of what went wrong.","isRequired":true,"uniqueKey":"error","typeLabel":"string"}},"required":["error"],"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":"\u003cstring>"}}},"exampleType":"generated"}},"exampleType":"generated"}},"security":{"5e873bfd-9277-42d8-b67f-596c2b666f90":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","scopes":[]}}},"servers":{"d723038e-161a-49c3-97eb-5fe7a380caa9":{"url":"https://app.dumplingai.com","description":"Production"}},"processedSecurityOptions":[{"schemes":[{"scheme":{"type":"http","scheme":"bearer","bearerFormat":"API Key","scopes":[]},"schema":{"title":"Bearer Auth","type":"string","isRequired":true,"description":"Bearer authentication header of the form `Bearer \u003ctoken>`, where `\u003ctoken>` is your auth token.","format":"bearer","typeLabel":"string\u003cbearer>","deprecated":false},"schemeName":"bearerAuth","name":"Authorization"}],"title":"bearerAuth"}]},"originalFileLocation":"api-reference/openapi-v1.yaml"},"subdomain":"dumplingai","siteName":"DumplingAI Docs","title":"Run Python Code - DumplingAI Docs","navMaps":{"firstHrefInVersion":{"v2":{"href":"/documentation/v2/get-started","matchLevel":4},"v1":{"href":"/api-reference/endpoint/run-python-code","matchLevel":0}},"firstHrefInLanguage":{}},"lastModified":"2025-11-21T00:07:11.731Z","originalFileLocation":"api-reference/endpoint/run-python-code.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=\"Execute sandboxed Python code and return stdout, stderr, and logs.\">\u003cmeta data-mint-head name=\"application-name\" content=\"DumplingAI Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/dumplingai/i_giEhVPqadP-y2_/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/dumplingai/i_giEhVPqadP-y2_/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/dumplingai/i_giEhVPqadP-y2_/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/dumplingai/i_giEhVPqadP-y2_/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/dumplingai/i_giEhVPqadP-y2_/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/dumplingai/i_giEhVPqadP-y2_/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/dumplingai/i_giEhVPqadP-y2_/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/dumplingai/i_giEhVPqadP-y2_/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/dumplingai/i_giEhVPqadP-y2_/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Run Python Code - DumplingAI Docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"Execute sandboxed Python code and return stdout, stderr, and logs.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"DumplingAI Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.dumplingai.com/api-reference/endpoint/run-python-code\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://dumplingai.mintlify.app/_mintlify/api/og/v2?division=Developer+Tools\u0026amp;title=Run+Python+Code\u0026amp;description=Execute+sandboxed+Python+code+and+return+stdout%2C+stderr%2C+and+logs.\u0026amp;theme=f6d65ea4c1e9445145f9cff7\u0026amp;signature=5c2d2e66576f37439b553854e40860855f3c49f1412bb81fe16037d709d1d755\">\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=\"Run Python Code - DumplingAI Docs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Execute sandboxed Python code and return stdout, stderr, and logs.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://dumplingai.mintlify.app/_mintlify/api/og/v2?division=Developer+Tools\u0026amp;title=Run+Python+Code\u0026amp;description=Execute+sandboxed+Python+code+and+return+stdout%2C+stderr%2C+and+logs.\u0026amp;theme=f6d65ea4c1e9445145f9cff7\u0026amp;signature=5c2d2e66576f37439b553854e40860855f3c49f1412bb81fe16037d709d1d755\">\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=\"/mintlify-assets/_mintlify/favicons/dumplingai/i_giEhVPqadP-y2_/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"DumplingAI Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#000\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.dumplingai.com/api-reference/endpoint/run-python-code\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/api-reference/endpoint/run-python-code.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.dumplingai.com/#organization\",\"name\":\"DumplingAI Docs\",\"url\":\"https://docs.dumplingai.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/dumplingai/ovQfojsBnkaBEyWP/dumplingai-logo.svg?fit=max\u0026auto=format\u0026n=ovQfojsBnkaBEyWP\u0026q=85\u0026s=46740c45e1bef65a42e4a799407a5d32\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.dumplingai.com#website\",\"name\":\"DumplingAI Docs\",\"url\":\"https://docs.dumplingai.com\",\"publisher\":{\"@id\":\"https://docs.dumplingai.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.dumplingai.com/api-reference/endpoint/run-python-code#webpage\",\"url\":\"https://docs.dumplingai.com/api-reference/endpoint/run-python-code\",\"name\":\"Run Python Code\",\"description\":\"Execute sandboxed Python code and return stdout, stderr, and logs.\",\"dateModified\":\"2025-11-21T00:07:11.731Z\",\"isPartOf\":{\"@id\":\"https://docs.dumplingai.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.dumplingai.com/api-reference/endpoint/run-python-code#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.dumplingai.com/api-reference/endpoint/run-python-code#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Developer Tools\",\"item\":\"https://docs.dumplingai.com/api-reference/endpoint/run-js-code\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Run Python Code\",\"item\":\"https://docs.dumplingai.com/api-reference/endpoint/run-python-code\"}]},{\"@type\":[\"TechArticle\",\"APIReference\"],\"@id\":\"https://docs.dumplingai.com/api-reference/endpoint/run-python-code#apireference\",\"headline\":\"Run Python Code\",\"name\":\"Run Python Code\",\"description\":\"Execute sandboxed Python code and return stdout, stderr, and logs.\",\"url\":\"https://docs.dumplingai.com/api-reference/endpoint/run-python-code\",\"mainEntityOfPage\":{\"@id\":\"https://docs.dumplingai.com/api-reference/endpoint/run-python-code#webpage\"},\"dateModified\":\"2025-11-21T00:07:11.731Z\",\"publisher\":{\"@id\":\"https://docs.dumplingai.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.dumplingai.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"DumplingAI Docs\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"DumplingAI Docs","nav":{"global":null,"versions":[{"version":"v2","pages":[{"title":"v2","href":"/documentation/v2/get-started"}]},{"version":"v1","tabs":[{"tab":"Documentation","pages":[{"title":"Documentation","href":"/documentation/v1/get-started"}]},{"tab":"API Reference","groups":[{"group":"Overview","pages":[{"title":"API Reference","href":"/api-reference/v1/introduction"},{"title":"Credit Costs","href":"/api-reference/credit-costs"}]},{"group":"Data APIs","pages":[{"title":"Get YouTube Transcript","openapi":"POST /api/v1/get-youtube-transcript","href":"/api-reference/endpoint/get-youtube-transcript"},{"title":"Get YouTube Video","openapi":"POST /api/v1/youtube/video","href":"/api-reference/endpoint/get-youtube-video"},{"title":"Get YouTube Video Comments","openapi":"POST /api/v1/youtube/video/comments","href":"/api-reference/endpoint/get-youtube-video-comments"},{"title":"Get YouTube Channel","openapi":"POST /api/v1/youtube/channel","href":"/api-reference/endpoint/get-youtube-channel"},{"title":"Get YouTube Channel Videos","openapi":"POST /api/v1/youtube/channel-videos","href":"/api-reference/endpoint/get-youtube-channel-videos"},{"title":"Get YouTube Channel Shorts","openapi":"POST /api/v1/youtube/channel/shorts","href":"/api-reference/endpoint/get-youtube-channel-shorts"},{"title":"YouTube Search","openapi":"POST /api/v1/youtube/search","href":"/api-reference/endpoint/search-youtube"},{"title":"Get TikTok Transcript","openapi":"POST /api/v1/get-tiktok-transcript","href":"/api-reference/endpoint/get-tiktok-transcript"},{"title":"Get TikTok Video","openapi":"POST /api/v1/get-tiktok-video","href":"/api-reference/endpoint/get-tiktok-video"},{"title":"Get TikTok Video Comments","openapi":"POST /api/v1/get-tiktok-video-comments","href":"/api-reference/endpoint/get-tiktok-video-comments"},{"title":"Get TikTok Profile","openapi":"POST /api/v1/get-tiktok-profile","href":"/api-reference/endpoint/get-tiktok-profile"},{"title":"Get TikTok Profile Videos","openapi":"POST /api/v1/get-tiktok-profile-videos","href":"/api-reference/endpoint/get-tiktok-profile-videos"},{"title":"Get TikTok User Followers","openapi":"POST /api/v1/get-tiktok-user-followers","href":"/api-reference/endpoint/get-tiktok-user-followers"},{"title":"Get TikTok User Following","openapi":"POST /api/v1/get-tiktok-user-following","href":"/api-reference/endpoint/get-tiktok-user-following"},{"title":"Search TikTok Users","openapi":"POST /api/v1/search-tiktok-users","href":"/api-reference/endpoint/search-tiktok-users"},{"title":"Get LinkedIn Profile","openapi":"POST /api/v1/linkedin/profile","href":"/api-reference/endpoint/get-linkedin-profile"},{"title":"Get LinkedIn Company","openapi":"POST /api/v1/linkedin/company","href":"/api-reference/endpoint/get-linkedin-company"},{"title":"Search","openapi":"POST /api/v1/search","href":"/api-reference/endpoint/search"},{"title":"Search News","openapi":"POST /api/v1/search-news","href":"/api-reference/endpoint/search-news"},{"title":"Search Maps","openapi":"POST /api/v1/search-maps","href":"/api-reference/endpoint/search-maps"},{"title":"Search Places","openapi":"POST /api/v1/search-places","href":"/api-reference/endpoint/search-places"},{"title":"Get Autocomplete","openapi":"POST /api/v1/get-autocomplete","href":"/api-reference/endpoint/get-autocomplete"},{"title":"Get Google Reviews","openapi":"POST /api/v1/get-google-reviews","href":"/api-reference/endpoint/get-google-reviews"}]},{"group":"Web Scraping","pages":[{"title":"Scrape","openapi":"POST /api/v1/scrape","href":"/api-reference/endpoint/scrape"},{"title":"Crawl Website","openapi":"POST /api/v1/crawl","href":"/api-reference/endpoint/crawl"},{"title":"Screenshot","openapi":"POST /api/v1/screenshot","href":"/api-reference/endpoint/screenshot"},{"title":"Extract","openapi":"POST /api/v1/extract","href":"/api-reference/endpoint/extract"}]},{"group":"Document Processing","pages":[{"title":"Doc to Text","openapi":"POST /api/v1/doc-to-text","href":"/api-reference/endpoint/doc-to-text"},{"title":"Convert to PDF","openapi":"POST /api/v1/convert-to-pdf","href":"/api-reference/endpoint/convert-to-pdf"},{"title":"Merge PDFs","openapi":"POST /api/v1/merge-pdfs","href":"/api-reference/endpoint/merge-pdfs"},{"title":"Read PDF Metadata","openapi":"POST /api/v1/read-pdf-metadata","href":"/api-reference/endpoint/read-pdf-metadata"},{"title":"Write PDF Metadata","openapi":"POST /api/v1/write-pdf-metadata","href":"/api-reference/endpoint/write-pdf-metadata"},{"title":"Extract Document","openapi":"POST /api/v1/extract-document","href":"/api-reference/endpoint/extract-document"},{"title":"Extract Image","openapi":"POST /api/v1/extract-image","href":"/api-reference/endpoint/extract-image"},{"title":"Extract Audio","openapi":"POST /api/v1/extract-audio","href":"/api-reference/endpoint/extract-audio"},{"title":"Extract Video","openapi":"POST /api/v1/extract-video","href":"/api-reference/endpoint/extract-video"},{"title":"Trim Video","openapi":"POST /api/v1/trim-video","href":"/api-reference/endpoint/trim-video"}]},{"group":"AI","pages":[{"title":"Generate Agent Completion","openapi":"POST /api/v1/agents/generate-completion","href":"/api-reference/endpoint/generate-agent-completion"},{"title":"Generate AI Image","openapi":"POST /api/v1/generate-ai-image","href":"/api-reference/endpoint/generate-ai-image"}]},{"group":"Developer Tools","pages":[{"title":"Run JavaScript Code","openapi":"POST /api/v1/run-js-code","description":"Execute sandboxed JavaScript and return stdout, stderr, and logs.","href":"/api-reference/endpoint/run-js-code"},{"title":"Run Python Code","openapi":"POST /api/v1/run-python-code","href":"/api-reference/endpoint/run-python-code"}]}]}]}]},"title":"Run Python Code - DumplingAI Docs","buildId":"dpl_EnxDqhjaNc9a8MVa833TGULPd9uJ","deploymentId":"dpl_EnxDqhjaNc9a8MVa833TGULPd9uJ","dynamics":["c2aa737661","2b790eda92","b0f84f53ff","a9bb46feb3"],"chunks":["OpenApiReferenceProvider-26-lDe7V.js","utils-CWQmgYtH.js","cloneDeep-izs3Hzxb.js","_Uint8Array-BVIqJ90l.js","isObjectLike-C8vmzPEN.js","isArray-Dcu1dQ5t.js","utils-4-Aw3rSD.js","toString-BX-iyh8G.js","isSymbol-CSH9U2Gm.js","addUniqueKeysToSchema-C2zjXYA5.js","snippetPresets-DFmpFA7C.js","style-to-object-BY3JEAdk.js","v4-DIgz8zy6.js","ApiExamples-FJpQavWq.js","isEqual-BfaiBbcl.js","usePlaygroundInputsStore-D_GvPF7k.js","shallow-Bs2ZB0NO.js","getApiPlaygroundDisplay-DCcqJJk-.js","CodeSnippet-DzDxawVe.js","CodeSnippets-aUr7fU-7.js","Page-CT9uE8Ip.js","getPastedJson-Y1fKsj_I.js","icon-DI4zTsDr.js","MethodPill-C0nDlmSQ.js","DuplicateIcon-NUXbx2nQ.js","createIcon-BdTHrPAi.js","DynamicMarkdown-CtpgKJwj.js","SectionHeading-B3x35tOt.js","axios-vUo_bRtp.js","Markdown-3OmurJMP.js","clsx-DMKzROTp.js","lib-DuNMoZ05.js","lib-B8HbPgcC.js","html-void-elements-mCSPHezU.js","dist-1ms6tsT-.js","katex-YMM-FMeD.js","marked.esm-CZWythHk.js","AssistantPageLink-Ke9xIMFx.js"]}