Skip to main content

Simple GET Request

The most basic test checks if an API endpoint returns the expected status code:
GET https://jsonplaceholder.typicode.com/users/1
Accept: application/json

//# status == 200
This test:
  1. Makes a GET request to the JSONPlaceholder API
  2. Sets the Accept header to request JSON
  3. Asserts that the response status is 200 (OK)

Running Your First Test

Save the above code to a file called basic.http and run:
httpspec basic.http
You should see output like:
✓ GET https://jsonplaceholder.typicode.com/users/1 (200ms)
  1 assertion passed

Tests: 1 passed, 1 total

Multiple Assertions

You can add multiple assertions to validate different aspects of the response:
### Test JSONPlaceholder API
GET https://jsonplaceholder.typicode.com/users/1
Accept: application/json

//# status == 200
//# body contains "Leanne Graham"
This test validates:
  • The response status is 200
  • The response body contains the string “Leanne Graham”
The ### prefix creates a named test. This helps identify tests in output and makes your test files more organized.

Multiple Requests in One File

HTTPSpec executes requests sequentially, making it easy to test multiple endpoints:
### Test successful response
GET http://httpbin.org/status/200
Content-Type: application/json

### Test not found response
GET http://httpbin.org/status/404
Content-Type: application/json
Each request is separated by the ### marker. HTTPSpec runs them in order and reports results for each.

Expected Output

When you run HTTPSpec, you get clear feedback on each test:
 Test JSONPlaceholder API (150ms)
  2 assertions passed

Tests: 1 passed, 1 total
Time: 0.15s

Best Practices

Name your tests clearly with ### so failures are easy to identify:
### Test user creation endpoint returns 201
POST https://api.example.com/users
Begin with status code assertions, then add more specific checks:
//# status == 200
//# body contains "success"

Next Steps

API Testing

Learn how to test REST APIs with body and header validation

Advanced Assertions

Explore all assertion types and operators

Build docs developers (and LLMs) love