This API provides endpoints to retrieve information from a data source (currently an Excel file). It's designed to be easily configurable and demonstrates a basic API using Python and Flask.
The API exposes two primary endpoints:
/get_id: Retrieves the ID associated with a product name./get_info: Retrieves specific information about a record based on its ID and column name./get_pregnancy_data: Retrieves pregnancy risk data for a drug.
The path to the data file is configurable through an environment variable.
- Python
- Flask
- Pandas
- AWS Elastic Beanstalk
Retrieve the ID of the first row where the Product Name column contains a given name (case-insensitive, partial match).
name(required): The name or partial name to search for in theProduct Namecolumn.
Returns the ID of the first matching row.
{
"id": "123"
}curl "http://{ENDPOINT}/get_id?name=Reactonz Women's Daily Vitality"Retrieve a specific value from the Excel file based on an id and a column name.
id(required): The ID of the row to retrieve.column(required): The name of the column to retrieve the value from.
Returns the value from the specified column for the given ID.
{
"value": "value_from_column"
}curl "http://{ENDPOINT}/get_info?id=483073&column=Sponsor Name"Retrieve pregnancy risk data for a drug based on its name.
name(required): The name or partial name of the drug to search for.
Returns the pregnancy risk data for the first matching drug.
{
"Category": "A",
"Classification Level 1": "X",
"Classification Level 2": "Y",
"Classification Level 3": "Z"
}curl "http://{ENDPOINT}/get_pregnancy_data?name=abacavir"DATA_FILE: Path to the Excel file. Defaults todata.xlsx.
The API was deployed on AWS using Elastic Beanstalk, EC2 and S3.