ts-api-automation
v1.1.2
Published
TypeScript API Automation Framework for testing and interacting with RESTful APIs
Downloads
167
Maintainers
Readme
TypeScript API Automation Framework
A robust and extensible TypeScript framework for API testing and automation. This framework provides features like request queuing, caching, error handling, and more to make API testing easier and more reliable.
Features
- Request Management
- Automatic request queuing with configurable concurrency
- Response caching for GET requests
- Configurable retry mechanism
- Error Handling
- Custom error types (NetworkError, ValidationError)
- Detailed error information including status codes and response data
- Request Customization
- Support for custom headers and authentication
- Request interceptors for modifying requests
- Performance
- Efficient request queuing to prevent API overload
- Configurable caching to reduce unnecessary requests
Project Structure
ts-api-automation/
├── src/
│ ├── config/
│ │ └── apiConfig.ts # API configuration (base URL, endpoints)
│ ├── services/
│ │ └── apiService.ts # Main API service implementation
│ ├── utils/
│ │ ├── errors.ts # Custom error classes
│ │ └── logger.ts # Logging utility
│ ├── tests/
│ │ └── api.test.ts # API tests
│ └── index.ts # Main entry point
├── docs/
│ ├── README.md # This documentation
│ └── USAGE.md # Detailed usage guide
├── package.json
├── tsconfig.json
└── .gitignore
Quick Start
- Install the package:
npm install ts-api-automation
- Import and use:
import { ApiService } from 'ts-api-automation';
const api = new ApiService({
baseUrl: 'https://api.example.com'
});
// Make API requests
const users = await api.get('/users');
const newUser = await api.post('/users', {
name: 'John Doe',
email: '[email protected]'
});
Documentation
For detailed information about using this framework in your projects, please refer to our Usage Guide. The guide covers:
- Complete setup and configuration
- Making type-safe API requests
- Error handling strategies
- Authentication and interceptors
- Caching and request queuing
- Best practices and examples
- Service layer implementation
Development
- Clone the repository:
git clone https://github.com/Sharma-IT/ts-api-automation.git
cd ts-api-automation
- Install dependencies:
npm install
- Run tests:
npm test
- Build the package:
npm run build
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the GNU v3.0 License - see the LICENSE file for details.