PyScrambleAPI is a Flask API that unscrambles sets of characters into actual words. It leverages its very own PyScramble module, which ranks potential matches based on their likelihood of being correct.
- Simple endpoints: Quickly unscramble letters by sending a POST or GET request with the letters you have.
- Ranked results: Returns a sorted list of possible words, ranked in order of likelihood by the PyScramble module.
- Modular: Built with Flask, making it easy to extend or integrate into larger systems.
Make sure you have the following installed:
-
Python 3.9.6+
-
pip (or another Python package manager)
-
Flask
-
Flask-Limiter
-
python-dotenv
-
gunicorn (for prod)
-
(Optional) A virtual environment tool (e.g. venv)
- Clone the repository:
git clone https://github.com/arthurauffray/PyScramble.git
- Navigate to the project directory:
cd PyScramble
- Install the dependencies:
If desired, create and activate a virtual environment first.
pip install -r requirements.txt
- Set the worldist file path: Open the .env file in your editor of choice and set the path of the words.json file (sample provided in /pyscramble/data/)
-
Start the Flask server:
python app.py
By default, the server runs on
http://127.0.0.1:8080
. -
Send requests to the API endpoints (see below). You can use tools like curl or Postman to test.
Below is a list of the API's endpoints.
Description: Accepts a JSON payload containing scrambled letters. Returns a list of possible words ordered by their rank.
Request body:
{
"letters": "hist"
}
Example:
curl -X POST -H "Content-Type: application/json" \
-d '{"letters":"hist"}' \
http://127.0.0.1:8080/unscramble
Response:
{
"status": "ok",
"message": [
"hist",
"hits",
"isth",
"shit",
"sith",
"this",
"tshi"
]
}
Description: Accepts a query parameter containing scrambled letters. Returns a list of possible words ordered by their rank.
Request URL:
http://127.0.0.1:8080/unscramble?letters=hist
Example:
curl -G \
-d "letters=hist" \
http://127.0.0.1:8080/unscramble
Response:
{
"status": "ok",
"message": [
"hist",
"hits",
"isth",
"shit",
"sith",
"this",
"tshi"
]
}
Description: Returns a status message to check for uptime.
Response:
{
"status": "ok",
"message": "Pong!",
}
Description: Returns a simple status to have a home page.
Response:
{
"status": "ok"
}
This project is available under the MIT License. Feel free to fork, extend, and submit pull requests.
If you have any questions or run into issues, please open an issue in this repository.