This API establishes a connection with Google Sheets to extract data from a designated spreadsheet. In the development environment, Flask serves as the backend framework. For the production environment, the application has been deployed on Render (https://render.com). The WebService is accessible at the following URL: https://backend-inven-fab24.onrender.com.
Before running the API, ensure you have the following tools and files:
- Python 3.x
- pip (Python package manager)
token.json
file from Google Cloud Platform with OAuth 2.0 credentials.env
file with necessary environment variables
Clone the repository and navigate to its directory:
$ git clone https://github.com/Mozta/backend-inven-fab
$ cd backend-inven-fab
Install dependencies:
$ pip install -r requirements.txt
Create a .env
file in the root directory of the project with the following variables:
SCOPES=[Your Google Sheets scopes]
SPREADSHEET_ID=[Your Google Sheets spreadsheet ID]
RANGE_NAME=[Cell range to access]
SHEET_REGISTERS=[Sheet of spreadsheet]
BASE_URL=[Base path for your endpoints]
SENDGRID_API_KEY=[Api key for the email sender Sendgrid]
SENDGRID_TEMPLATE_ID=[Template id Sendgrid]
SENDGRID_FROM_EMAIL=[Email from for Sendgrid]
Start the application with Flask:
$ python app.py
Returns spreadsheet data as JSON.
Retrieves values from the 'Items' column of the spreadsheet.
The API uses the OAuth 2.0 flow to authenticate with the Google Sheets API. On first run, you'll be prompted to log in with your Google account to grant the necessary permissions.
The API returns an error message in JSON format if no data is found in the spreadsheet.
The application has been deployed on Render. The API is accessible at the following URL: https://backend-inven-fab24.onrender.com/api/v1.