This project provides a Flask web server that interacts with a Neo4j database. It includes functionality for managing API keys, logging API key usage, and processing user requests to generate and execute Cypher queries.
- Python 3.13+
- pip
- Install the required packages:
pip install -r requirements.txt
- Set up environment variables:
cp .env.example .env
The main application logic is in src/cypher_query.py
. To run it, you can use the following command:
python src/cypher_query.py
To start the Flask web server, run:
python src/server.py
The server will be available at http://127.0.0.1:5000/
.
To add a desired API key, modify the src/add_api_key.py
file. Replace the placeholder values with your desired user and API key:
cursor.execute('''
INSERT INTO api_keys (user, api_key)
VALUES (?, ?)
''', ('your_user', 'your_unique_api_key'))
then run:
python src/add_api_key.py
It will add your API key to the local sqlite DB
- GET
/
- Returns a simple message indicating the server is running.
- POST
/query
- Headers:
X-API-KEY
: Your API key
- Body:
{ "query": "your_query", "output_format": "your_output_format" }
- Returns the results of the processed query.
This is the sample curl to use cypher query for your app (replace your_unique_api_key
with the API key you added in step 5):
curl --location '127.0.0.1:5000/query' \
--header 'X-API-KEY: your_unique_api_key' \
--header 'Content-Type: application/json' \
--data '{
"query":"I want to hear about projects impact kids health",
"output_format": "{project_id, project_title, raised_amount, giv_power, related_chunks: [text]}"
}'