Turn curl commands into a reusable API collection

curl is the lingua franca of APIs. Every API's docs have curl examples, every teammate pastes one into chat when something breaks, and every browser can copy a network request as curl. What curl doesn't do is remember: the command you got working last Tuesday is somewhere in your shell history, with a token that has expired.

Requestarium turns curl commands into saved requests you can edit, share, test and run again.

Paste a single command

Copy a command, for example from your browser's DevTools (right-click a request → Copy → Copy as cURL):

Terminal
curl 'https://api.example.com/v1/orders?status=open' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOi...'

In the app, the quickest way is to paste it straight into the URL field of a new request: the method, URL, headers, body and auth are all filled in from the command. To add it from a terminal instead:

Terminal
requestarium import --curl "curl https://api.example.com/v1/orders?status=open -H 'Accept: application/json'" --into "Orders API"

--into adds the request to an existing collection instead of creating a new one.

What is understood

curlBecomes
Method and URL, including the query stringMethod, URL and query parameters
-H headersHeaders
-d, --data-raw, --data-urlencode, --jsonThe request body
-FA multipart form body
-u user:passwordBasic auth
-H 'Authorization: Bearer …'Bearer auth

Shell variables ($TOKEN) and pipes are not evaluated, because they belong to your shell, not to the request.

Import a whole file of commands

If you keep a .sh file of curl commands, the kind every team has in a scripts/ folder, import the file. Each curl command becomes a request, and a # comment line above a command becomes its name:

Terminal
# List open orders
curl https://api.example.com/v1/orders?status=open

# Create an order
curl -X POST https://api.example.com/v1/orders --json '{"sku":"A-100","qty":1}'
Terminal
requestarium import ./api-examples.sh --name "Orders API"
Import preview of a file of curl commands: three requests, and two bearer tokens moved into a secret variable
Three commands, three requests. The bearer tokens become {{bearerToken}}, stored as a secret.

Clean it up once

A pasted command carries literal values. Two quick changes make it reusable:

  1. Replace the host with {{baseUrl}} and the token with {{token}}, then define both in an environment. Now the request works against local, staging and production.
  2. Add a check in the Scripts tab:
JavaScript
pm.test('returns a list', () => {
  pm.expect(pm.response.code).to.equal(200);
  pm.expect(Array.isArray(pm.response.json().items)).to.equal(true);
});

The request is now a test you can run from the app, the CLI, or CI.

And back to curl

Going the other way is just as useful: you've built a request in Requestarium and need to hand it to someone without the app, or paste it into a bug report. Open the request's Code panel and copy it as curl, or as fetch, Python, Go and other languages. The app snippet contains the resolved values, so check it for tokens before you paste it anywhere public.

The Code panel next to a request, showing it as a curl command
The Code panel: the request as curl, ready to copy
Terminal
requestarium snippet "List open orders" --collection "Orders API" --env Staging