RestCheck is a lightweight, declarative CLI tool for testing and validating REST APIs. Designed for backend developers who prefer the terminal over GUI-heavy tools like Postman and for usage inside CI/CD pipelines. RestCheck uses a simple Domain Specific Language (DSL) to define HTTP requests and assertions.
- Declarative Syntax: Define tests in simple, readable
.rcfiles. - Full HTTP Support: GET, POST, PUT, DELETE with custom headers.
- JSON Body Support: Send complex JSON payloads easily.
- Deep Validation:
- Check Status Codes.
- Set strict Latency thresholds (Performance testing).
- Validate JSON fields using dot-notation (e.g.,
user.address.city). - Text body substring matching.
- Colorized Output: Instant visual feedback (Pass/Fail) in the terminal.
You need the Haskell Tool Stack installed.
# Clone the repository
git clone https://gitlab.com/papakonstantinou/rest-check.git
cd restcheck
# Build with Cabal
stack build
# Install binary to local path (usually ~/.local/bin)
stack install
Create a file named api_test.rc. The syntax is designed to be readable at a glance.
Example: Testing a User Profile
# Define the Request
GET https://jsonplaceholder.typicode.com/users/1
Header: Authorization: Bearer my-secret-token
Header: Accept: application/json
# Define Expectations
EXPECT Status 200
EXPECT Latency < 500
EXPECT JsonPath "username" == "Bret"
EXPECT JsonPath "address.city" == "Gwenborough"
Example: Creating a Resource (POST)
POST https://reqres.in/api/users
Header: Content-Type: application/json
BODY
{
"name": "Morpheus",
"job": "leader"
}
EXPECT Status 201
EXPECT BodyContains "createdAt"
Pass the config file to the CLI:
restcheck api_test.rc
━━━ examples/example_get.rc ━━━
✓ ExpectStatus 200
✓ ExpectLatency 500
✓ ExpectJsonPath "username" (String "Bret")
✓ ExpectJsonPath "address.city" (String "Gwenborough")
| Argument | Description |
|---|---|
CONFIG_FILES... |
One or more config files to process (required) |
| Option | Short | Description |
|---|---|---|
--verbose |
-v |
Enable verbose output with additional details about requests and responses |
--quiet |
-q |
Minimal output showing only failures (suppresses passing tests) |
--no-color |
Disable colored output (useful for CI/CD or piping to files) | |
--concurrent |
-c |
Process multiple config files concurrently for faster execution |
--timeout SECONDS |
-t |
Set request timeout in seconds |
--dry-run |
-n |
Parse and validate config files without executing HTTP requests |
--version |
-V |
Show version information |
--help |
-h |
Show help message |
RestCheck is designed to run in headless environments. It returns standard exit codes (0 for success, 1 for failure), making it perfect for CI/CD pipelines.
Example: GitHub Actions Workflow
name: API Regression Test
on: [push]
jobs:
test-api:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build RestCheck
run: cabal install
- name: Run API Tests
run: restcheck tests/user_api.rc
The RestCheck DSL follows a strict line-based format:
- Request Line:
METHOD URL(Must be the first non-comment line). - Headers:
Header: Key: Value. - Body Block (Optional): Starts with
BODY, ends at the firstEXPECT. - Expectations:
EXPECT Status <Int>- Checks HTTP status code.EXPECT Latency < <Int>- Checks response time in milliseconds.EXPECT BodyContains "<String>"- Checks if raw body contains a substring.EXPECT JsonPath "<path>" == <Value>- Checks specific JSON fields.
Contributions are welcome!
- Fork the project.
- Create your feature branch (
git checkout -b feature/AmazingFeature). - Commit your changes (
git commit -m 'Add some AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a Pull Request.
Distributed under the MIT License. See LICENSE for more information.