Skip to content

Mozta/backend-inven-fab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API for Retrieving Google Sheets Inventory Data for Fab24

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.

Environment Setup

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

Installation

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

Environment Variables Configuration

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]

Execution

Start the application with Flask:

$ python app.py

Endpoints

GET /{BASE_URL}

Returns spreadsheet data as JSON.

GET /{BASE_URL}/items

Retrieves values from the 'Items' column of the spreadsheet.

Google Authentication

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.

Error Handling

The API returns an error message in JSON format if no data is found in the spreadsheet.

Production

The application has been deployed on Render. The API is accessible at the following URL: https://backend-inven-fab24.onrender.com/api/v1.

About

Backend for the FAB Workshops Inventory Platform

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages