API Agent - Automated Testing and API Management
The API Agent is PostQode's powerful feature that bridges the gap between API collections and comprehensive test automation. It enables you to automatically generate test suites, create test cases, manage datasets, and build automation scripts from your Collection API.
What is the API Agent?
The API Agent is an intelligent system that understands your API collections and can:
- Generate Test Suites from collection API with smart path suggestions
- Create Test Cases for individual or multiple API requests
- Manage Datasets for data-driven testing scenarios
- Update Test Scripts and individual API request configurations
- Build Automation Scripts for complex multi-request workflows
- Learn and Analyze API request patterns and behaviors
Key Scenarios and Workflows
1. Creating Test Suites from Collection API
When you import API collections, the API Agent provides intelligent suggestions for organizing your tests:
Smart Path Suggestions
After importing collections with multiple folders and API requests, the API Agent will:
- Analyze your collection structure and suggest optimal test suite organization
- Present three path options:
- 🆕 Create new test suite with suggested path based on collection structure
- 📁 Add to existing test suite showing available existing paths
- 🎯 Create in custom location allowing you to specify your preferred path
Example Workflow
📁 Collection API: "E-commerce API"
├── 📂 User Management
│ ├── POST /users/register
│ ├── POST /users/login
│ └── GET /users/profile
├── 📂 Product Catalog
│ ├── GET /products
│ ├── GET /products/{id}
│ └── POST /products/search
└── 📂 Order Processing
├── POST /orders
├── GET /orders/{id}
└── PUT /orders/{id}/status
API Agent Suggestions:
✅ Create new test suite: "testSuites/ecommerce-api/"
✅ Add to existing: "testSuites/api-integration/"
✅ Custom location: [User specified path]
2. Updating Test Cases with Datasets and Scripts
The API Agent provides comprehensive test case management capabilities:
Dataset Integration
- Create CSV datasets for data-driven testing scenarios
- Link datasets to specific test cases automatically
- Update existing datasets with new test data variations
Script Management
- Update test scripts with enhanced assertions and validations
- Modify individual API requests within test cases
- Add pre-request scripts for setup and authentication
- Implement post-request scripts for data extraction and cleanup
Example Dataset Creation
username,email,password,expected_status
valid_user,[email protected],password123,201
invalid_email,invalid-email,password123,400
empty_password,[email protected],,400
existing_user,[email protected],password123,409
3. Creating Test Cases for Individual Requests
Generate focused test cases for specific API endpoints:
Single Request Test Generation
- Positive test scenarios with valid data
- Negative test scenarios with invalid inputs
- Boundary value testing for edge cases
- Authentication and authorization testing
- Error handling validation
Example: User Registration Test Cases
Generated Test Cases for POST /users/register:
├── ✅ Create User with Valid Data
├── ❌ Create User with Invalid Email Format
├── ❌ Create User with Missing Required Fields
├── ❌ Create User with Duplicate Email
├── 🔒 Create User without Authentication
└── 📊 Create User with Dataset Variations
4. Learning About API Requests
The API Agent can analyze and explain API requests in detail:
Request Analysis Features
- Parameter breakdown and validation rules
- Expected response formats and status codes
- Authentication requirements and security considerations
- Usage patterns and best practices
- Error scenarios and troubleshooting guidance
Example Analysis Output
📋 API Request Analysis: POST /users/register
🔍 Request Details:
- Method: POST
- Endpoint: /users/register
- Content-Type: application/json
- Authentication: Bearer token required
📝 Parameters:
- username (string, required): 3-50 characters
- email (string, required): Valid email format
- password (string, required): Min 8 characters
- firstName (string, optional): Display name
- lastName (string, optional): Display name
✅ Success Response (201):
{
"id": "uuid",
"username": "string",
"email": "string",
"createdAt": "timestamp"
}
❌ Error Responses:
- 400: Invalid input data
- 409: User already exists
- 401: Authentication required
5. Creating Automation Scripts for Multiple Requests
Build complex workflows that chain multiple API requests:
Multi-Request Automation
- Sequential request execution with data passing between requests
- Conditional logic based on response data
- Error handling and retry mechanisms
- Variable extraction and reuse across requests
- Comprehensive reporting and logging
Example Automation Workflow
🔄 E-commerce Order Automation Script:
1. 🔐 Authenticate User
POST /auth/login → Extract access_token
2. 👤 Get User Profile
GET /users/profile → Extract user_id
3. 🛍️ Browse Products
GET /products → Extract product_ids
4. 🛒 Add to Cart
POST /cart/items → Use product_id, user_id
5. 💳 Create Order
POST /orders → Extract order_id
6. ✅ Verify Order
GET /orders/{order_id} → Validate order status
7. 📧 Send Confirmation
POST /notifications/email → Complete workflow
Getting Started with API Agent
Step-by-Step Setup
1. Check Collections and API Requests
First, verify that you have API collections available in your workspace:
1. Check if collections directory exists in your workspace
2. Verify API request files are present (.request.yaml files)
3. If no collections exist, create or import them first
4. Ensure API requests are properly structured and accessible
2. Initialize API Agent
Once you have collections available, initialize the API Agent:
1. Open PostQode chat interface
2. Mention your Collection API: @collections/your-collection
3. Request test suite generation: "Generate test cases for this collection"
4. Choose from suggested path options provided by the agent
3. Update with Datasets
Enhance your test cases with data-driven testing:
1. Review generated test cases for data requirements
2. Create CSV datasets for test scenarios that need multiple data variations
3. Link datasets to appropriate test cases
4. Validate dataset integration with test execution
4. Execute and Iterate
Run and refine your automated testing workflow:
1. Execute generated test suites to validate functionality
2. Review test results and identify coverage gaps
3. Update test cases based on findings and requirements
4. Expand automation scripts for complex multi-request workflows
5. Iterate on datasets and test scenarios as needed
Related Documentation
- Collections Overview - Understanding API collections
- Test Suites - Creating and managing test suites
- Variables - Working with variables and datasets
The API Agent transforms your API Collection into comprehensive testing solutions, enabling you to build robust, maintainable, and automated testing workflows that scale with your development needs.