Calling your first API

June 03, 20201 minute read

Define a test.json file that holds information about the api you are trying to call. To learn more about test files see Test case template.

{
  "testCases": {
    "my_first_test_case": {
      "path": "/books",
      "query": {
        "id": 1
      },
      "method": "POST"
    }
  },
  "url": "my-api.com"
}

Run the test case

The command run is used to call an API test case. Provide the test file before the run command and then provide the test case you want to run.

api-test -f test.json run my_first_test_case

Response:

Response:
200 OK
BODY:
{
  "id": "1",
  "author": "Subesh Bhandari",
  "title": "The Road to React"
}
META:
{
  "ResponseTime": "0.032478s",
  "Size": "63 Bytes"
}

To view the list of available commands run:

api-test --help

For information on the commands, the detailed explanation can be found in commands section