-
Notifications
You must be signed in to change notification settings - Fork 0
api
Okerew edited this page Sep 13, 2025
·
1 revision
The DNALite API is a Flask-based web service for storing, retrieving, listing, and deleting biological data (e.g., DNA, RNA, Protein sequences) using an SQLDNAEncoder. It provides RESTful endpoints for managing data in a structured manner.
-
Endpoint:
/store -
Method:
POST - Description: Stores biological data in the database.
-
Request Body:
{ "data_name": "string", "data": "object" } -
Responses:
-
Success (201 Created):
{ "message": "Data stored successfully" } -
Error (400 Bad Request):
{ "error": "Missing required fields: data_name and data" } -
Error (500 Internal Server Error):
{ "error": "Error message" }
-
Success (201 Created):
-
Endpoint:
/retrieve/<data_name> -
Method:
GET - Description: Retrieves stored biological data by its name.
-
Path Parameter:
-
data_name: Name of the data to retrieve.
-
-
Responses:
-
Success (200 OK):
{ "data": "object" } -
Error (404 Not Found):
{ "message": "Data not found" } -
Error (500 Internal Server Error):
{ "error": "Error message" }
-
Success (200 OK):
-
Endpoint:
/list -
Method:
GET - Description: Lists all stored data names.
-
Responses:
-
Success (200 OK):
[ "data_name_1", "data_name_2", ... ]
-
Error (500 Internal Server Error):
{ "error": "Error message" }
-
Success (200 OK):
-
Endpoint:
/delete/<data_name> -
Method:
DELETE - Description: Deletes stored biological data by its name.
-
Path Parameter:
-
data_name: Name of the data to delete.
-
-
Responses:
-
Success (200 OK):
{ "message": "Data deleted successfully" } -
Error (500 Internal Server Error):
{ "error": "Error message" }
-
Success (200 OK):
-
Endpoint:
/copy -
Method:
POST - Description: Copies the current database to a new database.
-
Request Body:
{ "db_name": "string" } -
Responses:
-
Success (200 OK):
{ "message": "Database copied to {db_name}" } -
Error (400 Bad Request):
{ "error": "Missing required field: db_name" } -
Error (500 Internal Server Error):
{ "error": "Error message" }
-
Success (200 OK):
from dnalite_api import create_app
app = create_app()
if __name__ == "__main__":
app.run(debug=True)curl -X POST http://localhost:5000/store \
-H "Content-Type: application/json" \
-d '{"data_name": "example_dna", "data": {"sequence": "ATGC"}}'curl -X GET http://localhost:5000/retrieve/example_dnacurl -X GET http://localhost:5000/listcurl -X DELETE http://localhost:5000/delete/example_dnacurl -X POST http://localhost:5000/copy \
-H "Content-Type: application/json" \
-d '{"db_name": "new_database"}'- Flask: Web framework for building the API.
- SQLDNAEncoder: Custom class for encoding and managing biological data in a database.
- 400 Bad Request: Missing required fields in the request.
- 404 Not Found: Data not found in the database.
- 500 Internal Server Error: Unexpected errors during data operations.
- The API is designed to be extensible for additional biological data types and operations.
- Ensure the
SQLDNAEncoderis properly initialized with a database connection.