Skip to content
Course outline

cURL to API test ideas

Paste a cURL command; it reads the request and lists the tests worth writing for it, from sign-in to repeats.

  • Free, no sign-up
  • Runs in your browser
  • Nothing you type is sent anywhere

Browsers and API tools can copy any request as a cURL command: the method, the address, the headers and the body in one line. That line is also the best start for API tests, because everything worth varying is in it: who is signed in, each field of the body, each query parameter, the method and the content type.

Paste a cURL command. The tool reads the request and lists the tests worth writing for it, grouped by what they check. It runs in this page only: the command, and any token in it, is never sent anywhere. Tokens are hidden in the summary.

Use the tool

Bash (lines ending in \) and Windows (lines ending in ^) commands both work. Nothing you paste leaves this page.

Method
POST
Address
https://practice.qaia.io/api/coupons/apply
Authorization
Bearer YOUR… (hidden)
Content-Type
application/json
Body
{"code":"CEDAR10"}

15 test ideas:

Happy path

  • Send it as it is: expect a success status (2xx) and an answer whose fields and types match the documentation.

Sign-in

  • Send it without the Authorization header (or the cookie): expect 401, and no data in the answer.
  • Send it with a changed or expired token: expect 401.
  • Send it with another user's sign-in: expect 403 or 404, never that user's data.

Body fields

  • Leave out "code": expect 400 with a message that names the field.
  • Send "code" empty (""), and as spaces only: expect 400.
  • Add a field the API does not know ("isAdmin": true): expect it ignored or refused, never acted on.

Limits

  • Send a very long "code" (10,000 characters): expect 400 or a clear limit, never a 500.

Types

  • Send "code" as a number instead of text: expect 400.

Security

  • Put markup and SQL text in "code" (<script>, ' OR 1=1 --): expect it refused or stored as plain text.

Body

  • Send a body that is not valid JSON (cut it in half): expect 400, not a 500.

Content type

  • Send the same body as text/plain instead of application/json: expect 415 or 400.

Method

  • Send it with another method (GET instead of POST): expect 405, not a 500 and not a success.

Repeats

  • Send it twice, quickly: the change must happen once (a coupon applied once, one order).

Speed

  • Time the answer, and send it 20 times in a row: it stays within the agreed time and every answer is the same.

Run it with QAIA: API Analysis reads the same command, writes the tests and runs them.

See API AnalysisRequest accessStart freeGet started

Copy the command and open API Analysis

How the method works

A good API test set starts with the request as it is (the happy path), then changes one thing at a time and checks the status code and the message: no sign-in (401), someone else's sign-in (403 or 404), each required field left out or empty (400), a field of the wrong type, values past their limits, the wrong method (405) and the wrong content type (415).

Two more checks catch the costly bugs. Repeats: the same request sent twice, quickly, must change things once (one order, one discount). Speed: the answer must stay within the agreed time when the request is sent many times in a row. The ideas tell you what to check; the expected status codes come from the API's documentation.

  1. Copy a request as cURL: in the browser's developer tools (Network, then "Copy as cURL"), or from the API's documentation.
  2. Paste it here and read the test ideas.
  3. Write the tests in your API tool, or let QAIA write and run them: "Run it with QAIA" copies the command and opens API Analysis.

A worked example on Cedar Books

Cedar Books applies a coupon through POST /api/coupons/apply (its API docs give the cURL of every call). For that command, the first test ideas are:

Test ideas for the Cedar Books coupon call
ChecksTest
Happy pathSend it as it is: expect a success status (2xx) and an answer whose fields and types match the documentation.
Sign-inSend it without the Authorization header (or the cookie): expect 401, and no data in the answer.
Sign-inSend it with a changed or expired token: expect 401.
Sign-inSend it with another user's sign-in: expect 403 or 404, never that user's data.
Body fieldsLeave out "code": expect 400 with a message that names the field.
Body fieldsSend "code" empty (""), and as spaces only: expect 400.
LimitsSend a very long "code" (10,000 characters): expect 400 or a clear limit, never a 500.
TypesSend "code" as a number instead of text: expect 400.

The list goes on with types, limits, repeats and speed. Compare each answer with the shop's OpenAPI document: where they differ, you have found a bug. The API tests lab walks through it with QAIA.

Learn more

Put the lessons to work on a real site

Describe a user journey in plain English. QAIA walks it in a real browser and hands back the test cases, the automation code and the evidence of every step.