API Collections
Collections are the foundation of SmartAPI, allowing you to organize, share, and execute groups of API requests.
bilgi
Coming Soon This feature is currently in development.
Understanding Collections
What is a Collection?
A collection is a group of related API requests organized in a logical structure:
Collection: E-Commerce API
├── 📁 Authentication
│ ├── POST /auth/login
│ ├── POST /auth/register
│ ├── POST /auth/refresh
│ └── POST /auth/logout
├── 📁 Products
│ ├── GET /products
│ ├── GET /products/{id}
│ ├── POST /products
│ ├── PUT /products/{id}
│ └── DELETE /products/{id}
└── 📁 Orders
├── GET /orders
├── POST /orders
└── GET /orders/{id}
Creating Collections
Manual Creation
- Click New Collection
- Enter collection name and description
- Add folders for organization
- Create requests within folders
Import Options
| Source | Format |
|---|---|
| OpenAPI/Swagger | JSON, YAML |
| Postman | Collection v2.1 |
| Insomnia | Export format |
| HAR Files | Browser recordings |
| cURL | Command line imports |
Collection Structure
Folders
Organize requests into logical groups:
- By resource (Users, Products, Orders)
- By functionality (Auth, CRUD, Search)
- By test type (Smoke, Regression, Performance)
Requests
Each request contains:
| Component | Description |
|---|---|
| Method | HTTP method (GET, POST, etc.) |
| URL | Endpoint path with variables |
| Headers | Request headers |
| Body | Request payload |
| Auth | Authentication settings |
| Tests | Assertions and validations |
| Pre-request | Setup scripts |
Variables
Use variables for dynamic values:
// Collection variables
{{baseUrl}}/api/v1/users/{{userId}}
// Environment variables
Authorization: Bearer {{accessToken}}
Request Builder
HTTP Methods
| Method | Use Case |
|---|---|
| GET | Retrieve resources |
| POST | Create new resources |
| PUT | Replace resources |
| PATCH | Partial updates |
| DELETE | Remove resources |
| HEAD | Headers only |
| OPTIONS | CORS preflight |
Headers
Common header configurations:
| Header | Value |
|---|---|
| Content-Type | application/json |
| Authorization | Bearer {{token}} |
| Accept | application/json |
| X-API-Key | {{apiKey}} |
Request Body
Supported formats:
- JSON - Structured data
- Form Data - File uploads
- URL Encoded - Form submissions
- Raw - Plain text, XML
- Binary - File content
Authentication
| Type | Configuration |
|---|---|
| Bearer Token | JWT, OAuth tokens |
| Basic Auth | Username/password |
| API Key | Header or query param |
| OAuth 2.0 | Full OAuth flow |
| AWS Signature | AWS services |
Test Scripts
Pre-request Scripts
Execute before sending request:
// Generate timestamp
pm.collectionVariables.set('timestamp', Date.now());
// Create signature
const signature = CryptoJS.HmacSHA256(data, secret);
pm.request.headers.add('X-Signature', signature);
Test Scripts
Validate responses:
// Status code check
pm.test('Status is 200', () => {
pm.response.to.have.status(200);
});
// JSON structure
pm.test('Response has user data', () => {
const json = pm.response.json();
pm.expect(json).to.have.property('id');
pm.expect(json).to.have.property('email');
});
// Response time
pm.test('Response time < 500ms', () => {
pm.expect(pm.response.responseTime).to.be.below(500);
});
Collection Runner
Running Collections
Execute entire collections or folders:
| Option | Description |
|---|---|
| Iterations | Run multiple times |
| Delay | Pause between requests |
| Data File | CSV/JSON for data-driven tests |
| Environment | Select environment |
Execution Order
Control request sequence:
- Folder order (top to bottom)
- Request order within folders
- Conditional flow with scripts
Data-Driven Testing
Use external data files:
email,password,expectedStatus
[email protected],pass123,200
[email protected],wrong,401
,pass123,400
Sharing & Collaboration
Team Sharing
- Share collections with team members
- Role-based access (View, Edit, Admin)
- Version history and rollback
Export Options
| Format | Use Case |
|---|---|
| JSON | Backup, sharing |
| OpenAPI | Documentation |
| HTML | Static documentation |
| Markdown | README files |
Best Practices
Organization
- Use consistent naming conventions
- Group by domain/resource
- Include descriptions
Variables
- Use environment variables for URLs
- Store secrets securely
- Document variable usage
Testing
- Add assertions to every request
- Test both success and error cases
- Validate response schema
Maintenance
- Regular cleanup of unused requests
- Update documentation
- Review and refactor periodically