A RESTful API service that analyzes strings and stores their computed properties including length, palindrome detection, unique characters, word count, SHA-256 hash, and character frequency mapping.
API Base URL: https://stringanalyzer-production-0bbb.up.railway.app
- ✅ Analyze and store strings with computed properties
- ✅ Retrieve stored string analyses
- ✅ Filter strings by multiple criteria
- ✅ Natural language query support
- ✅ SQLite database for persistence
- ✅ Complete error handling
- ✅ RESTful API design
- Language: Python 3.13
- Framework: Flask
- Database: SQLite
- Deployment: Railway
- Python 3.11 or higher
- pip (Python package manager)
-
Clone the repository
git clone https://github.com/arithenshaw/String_Analyzer.git cd string-analyzer-api -
Create a virtual environment
python -m venv venv # On Windows venv\Scripts\activate # On macOS/Linux source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Run the application
python app.py
The API will be available at
http://localhost:5000
POST /strings
Request Body:
{
"value": "string to analyze"
}Success Response (201):
{
"id": "sha256_hash_value",
"value": "string to analyze",
"properties": {
"length": 17,
"is_palindrome": false,
"unique_characters": 12,
"word_count": 3,
"sha256_hash": "abc123...",
"character_frequency_map": {
"s": 2,
"t": 2,
...
}
},
"created_at": "2025-08-27T10:00:00Z"
}Error Responses:
400- Invalid request body or missing "value" field409- String already exists in the system422- Invalid data type for "value" (must be string)
GET /strings/{string_value}
Success Response (200):
{
"id": "sha256_hash_value",
"value": "requested string",
"properties": { ... },
"created_at": "2025-08-27T10:00:00Z"
}Error Response:
404- String does not exist in the system
GET /strings
Query Parameters:
is_palindrome(boolean): Filter palindromesmin_length(integer): Minimum string lengthmax_length(integer): Maximum string lengthword_count(integer): Exact word countcontains_character(string): Must contain character
Example:
GET /strings?is_palindrome=true&min_length=5&max_length=20
Success Response (200):
{
"data": [ ... ],
"count": 15,
"filters_applied": {
"is_palindrome": true,
"min_length": 5
}
}GET /strings/filter-by-natural-language?query={natural_language_query}
Examples:
?query=all single word palindromic strings?query=strings longer than 10 characters?query=strings containing the letter z
Success Response (200):
{
"data": [ ... ],
"count": 3,
"interpreted_query": {
"original": "all single word palindromic strings",
"parsed_filters": {
"word_count": 1,
"is_palindrome": true
}
}
}Error Responses:
400- Unable to parse natural language query422- Query parsed but resulted in conflicting filters
DELETE /strings/{string_value}
Success Response:
204- No Content (empty response body)
Error Response:
404- String does not exist in the system
python tests/test_api.pyCreate a string:
curl -X POST http://localhost:5000/strings \
-H "Content-Type: application/json" \
-d '{"value": "racecar"}'Get all palindromes:
curl "http://localhost:5000/strings?is_palindrome=true"Natural language query:
curl "http://localhost:5000/strings/filter-by-natural-language?query=palindromic%20strings"stringanalyzer-production-0bbb.up.railway.app