A tester tool for APIs with templates and dependencies.
Example:
project: test my awesome API
-- first delete the resource if it exists
depends-on: delete-resource
====
POST /path/to/resource
Host: api.example.com
Content-Type: application/json
{"name":"Awesome resource","description":"Awesome resource used for tests"}
====
-- evaluate the response
status-code equals: 200
response-body contains: idgreq is a Rust-based command-line tool for parsing, validating, and executing HTTP-like requests from .greq files. Ideal for API developers, maintainers, test engineers and developers working with raw HTTP interactions.
- Parse
.greqrequest files with structured metadata, body, and evaluation conditions - Run requests and validate responses
- Supports inheritance, templating, placeholders, and chain of dependencies
- Set environment variables from response data with
set-environment.<name>properties - Execute shell commands before and after HTTP requests with
execute-beforeandexecute-after - Environment variable placeholders with
$(environment.VAR_NAME)syntax - Allow dependency failure handling with
allow-dependency-failureproperty - Configurable warning system with
show-warningsproperty - Graceful placeholder replacement when dependencies fail
- Works with JSON, status codes, etc.
- Built for performance and flexibility
- Process requests simultaneously
git clone https://github.com/sgchris/greq.git
cd greq
cargo build --release# Run a single test
cargo run -- test.greq
# Run multiple tests in parallel
cargo run -- auth.greq users.greq posts.greq
# Enable verbose logging
cargo run -- --verbose api-tests.greqproject: User API Test
is-http: true
timeout: 5000
====
POST /users HTTP/1.1
host: api.example.com
content-type: application/json
{
"name": "John Doe",
"email": "[email protected]"
}
====
status-code equals: 201
response-body.id exists: true
response-body.name equals: John Doe
For complete documentation including all properties, operators, and advanced features, see:
The greq-examples/ directory contains various example files demonstrating different features:
- Basic tests: Simple GET/POST requests
- Inheritance: Using base configurations
- Dependencies: Chaining tests with data flow
- Environment variables: Setting and using environment variables from response data
- Dependency failure handling: Using
allow-dependency-failurefor robust test workflows - Shell commands: Using
execute-beforeandexecute-afterfor test automation - Advanced conditions: Complex validation scenarios
Capture values from API responses and use them in subsequent requests:
-- login.greq
project: Login and Capture Token
is-http: true
set-environment.AUTH_TOKEN: $(dependency.response-body.auth_token)
set-environment.USER_ID: $(dependency.response-body.user.id)
====
POST /auth/login HTTP/1.1
host: api.example.com
content-type: application/json
{"username": "testuser", "password": "pass123"}
====
status-code equals: 200
response-body.auth_token exists: true
-- protected-resource.greq
depends-on: login.greq
project: Access Protected Resource
====
GET /api/users/$(environment.USER_ID) HTTP/1.1
host: api.example.com
authorization: Bearer $(environment.AUTH_TOKEN)
====
status-code equals: 200
This project follows idiomatic Rust patterns and coding standards. Please ensure all code: Please check CONTRIBUTING instructions.
- Compiles without warnings (
cargo clippy) - Is properly formatted (
cargo fmt) - Includes appropriate tests (
cargo test) - Follows the project's error handling patterns
See LICENSE file for details.