This project simulates an API environment to capture and analyze network traffic data from both automated bots and human interactions. Note that this project captures data for educational/ML purposes.
api.py: A Flask-based web server that exposes/loginand/searchendpoints. It logs details of every incoming request (Timestamp, IP, Endpoint, Method, etc.) to a CSV file.botsimulator.py: A python script that simulates bot behavior by sending automated, periodic requests to the API.
- Python 3.x
pippackage manager
Install the required Python libraries:
pip install flask requestsOpen a terminal in the project directory and run:
python api.pyThis will start the server at http://127.0.0.1:5000 and create/reset the api_logs.txt file.
While the API server is running, open a second terminal and run the bot simulator:
python botsimulator.pyThis acts as a bot, sending requests with fixed time intervals to /login and /search.
To generate "Human" data, manually interact with the API while the server is running:
- Open your web browser and navigate to:
http://127.0.0.1:5000/search - Refresh the page at random intervals.
- You can also use tools like Postman or curl to send POST requests to
http://127.0.0.1:5000/login.
All traffic is logged to api_logs.txt in the root directory. The log includes:
- Timestamp
- IP Address
- Endpoint
- HTTP Method
- Response Code
- Request Time Gap (Placeholder)
- Label (Default: Unknown)
Here is a snippet of what the api_logs.txt file looks like:
Timestamp,IP Address,Endpoint,HTTP Method,Response Code,Request Time Gap,Label
2026-02-05T02:44:10.698723,127.0.0.1,/login,POST,200,0,Unknown
2026-02-05T02:44:29.200568,127.0.0.1,/search,GET,200,0,Unknown
2026-02-05T02:45:20.451665,127.0.0.1,/login,POST,200,0,Unknown
2026-02-05T02:45:36.588449,127.0.0.1,/search,GET,200,0,Unknown
2026-02-05T02:45:49.722016,127.0.0.1,/login,POST,200,0,Unknown