A Python script to compare API responses between two endpoints based on configurable parameters. It fetches data from old and new APIs, computes differences using DeepDiff, and saves the results to the specified Excel file (default: output/api_diff.xlsx).
-
Clone the repository:
git clone https://github.com/jola16/api_diff.git cd api_diff -
Install dependencies:
pip install -r requirements.txt
Note: This script currently only supports APIs that return JSON responses.
Run the script with a configuration file:
python api_diff.py --config config/api_diff_config_SAMPLE.yamlUse --debug for detailed logging:
python api_diff.py --config config/api_diff_config_SAMPLE.yaml --debugSpecify a custom output file (default: output/api_diff.xlsx):
python api_diff.py --config config/api_diff_config_SAMPLE.yaml --output my_results.xlsx-
Copy the sample config file as a template:
cp config/api_diff_config_SAMPLE.yaml config/api_diff_config.yaml
-
Edit
config/api_diff_config.yamlwith your actual:- API endpoints (old and new)
- Request method (optional, default GET) for old_api and new_api
- Authentication headers (optional)
- Rate limiting settings
- Max concurrent requests (optional, default 1)
- CSV file path (relative to config directory) containing test cases
- Parameter configurations with column mappings
Note: Config files in config/ are gitignored (except the SAMPLE file) to protect sensitive data.
Note: CSV file paths in the config are relative to the config file's directory.
Note: Output files in output/ are gitignored to protect potentially sensitive data.
- deepdiff
- ratelimit
- openpyxl
- pyyaml
utils/create_test_data.py: Helper script to generate CSV test data from parameter configurations. Run with--config utils/create_test_data.yaml --output config/test_data.csvfor example.
This project is licensed under the MIT License - see the LICENSE file for details.