The Wikipedia API allows users to perform text analysis tasks on Wikipedia articles. It provides two primary endpoints:
- Word Frequency Analysis Endpoint
- Search History Endpoint
The Wikipedia API allows users to analyze Wikipedia articles by providing insights into word frequency and search history.
-
Clone the Repository:
git clone https://github.com/itsRkator/wiki-text-analyzer.git cd wikipedia_api
-
Create a Virtual Environment:
python -m venv venv
-
Activate the Virtual Environment:
- For Windows:
venv\Scripts\activate
- For Unix or MacOS:
source venv/bin/activate
- For Windows:
-
Install Dependencies:
pip install -r requirements.txt
-
Run the Application:
python app.py
-
Access the API: The API will be running at
http://127.0.0.1:5000/
. Use this base URL for making requests.
- URL:
/word_frequency
- Method: POST
- Parameters:
topic
(string): Subject of the Wikipedia article.n
(integer): Number of top frequent words to return.
{
"topic": "Python",
"n": 5
}
{
"topic": "Python",
"top_words": [
{ "word": "python", "frequency": 10 },
{ "word": "language", "frequency": 5 }
// ...
]
}
- URL:
/search_history
- Method: GET
[
{
"topic": "Python",
"top_words": [
{ "word": "python", "frequency": 10 },
{ "word": "language", "frequency": 5 }
// ...
]
}
// ...
]
Example 1: Successful Request
curl -X POST -H "Content-Type: application/json" -d '{"topic": "Python", "n": 5}' http://127.0.0.1:5000/word_frequency
Example 2: Missing Parameter in Request
curl -X POST -H "Content-Type: application/json" -d '{"n": 5}' http://127.0.0.1:5000/word_frequency
Example: Retrieve Search History
curl http://127.0.0.1:5000/search_history
To run unit tests, use the following command:
python test_app.py