Skip to main content

Features ›cURL Import & Export

Изменить на GitHub

Эта документация доступна на английском языке.

cURL Import & Export

Most API docs show examples as curl commands. DotFetch can turn one into a request, and turn your request back into a command you can paste into a terminal.

Import a cURL command

  1. Click 📥 Import in the Request Builder toolbar, or Import cURL in Quick Actions.
  2. Paste the command and confirm.
BASH
curl -X POST "https://httpbin.org/post?source=docs" \
  -H "Content-Type: application/json" \
  -H "X-Trace: abc123" \
  -d '{"name":"Ada","role":"admin"}'

becomes:

PartValue
MethodPOST
URLhttps://httpbin.org/post
Paramssource = docs
HeadersContent-Type: application/json, X-Trace: abc123
Body{"name":"Ada","role":"admin"}

What the importer understands:

cURL optionBecomes
-X / --requestThe method
The first http:// or https:// URLURL, with the ?query split into the Params tab
-H / --header (quoted)One header row each
-d, --data, --data-raw, --data-binaryThe body. If there's a body and no -X, the method becomes POST, as curl does.

Line breaks with \ are fine. Other options (-u, -F, --compressed, cookies) aren't imported. After importing, set those up in the right tab, such as Auth → Basic Auth for -u.

Export as cURL

Click 📤 Export to copy the current request as a curl command:

BASH
curl \
  -X POST \
  "https://httpbin.org/post?source=docs" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer eyJhbGciOi..." \
  -d "{\"name\":\"Ada\",\"role\":\"admin\"}"

The command includes:

  • the method, URL, and enabled Params-tab rows
  • enabled headers, plus the header from the Auth tab (Bearer, API key, or OAuth token). Basic Auth becomes -u "user:pass", and an API key in query mode is added to the URL.
  • the body. JSON bodies are compacted onto one line.
  • -k when SSL verification is off for this request

Two things to watch:

  • {{VARIABLES}} are not filled in. The command contains {{BASE_URL}} literally, because curl doesn't know your .env. Replace them before running.
  • Secrets are included if you typed them directly into the Auth tab. Don't paste the command anywhere public. See cURL export and secrets.
cURL Import & Export · DotFetch Docs | dotsuite