Skip to content

This project is a Food Search API built with FastAPI and OAuth2 integration for secure access to the FatSecret API. It allows users to search for food items, filter results, and fetch detailed nutritional information. The API manages token generation, validation, and expiry for seamless interaction.

Notifications You must be signed in to change notification settings

Aditya-chauhann/FoodSeachAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Food Search API with FastAPI This project provides a FastAPI-powered Food Search API that integrates with the FatSecret API. It allows users to search for food items, filter results, and retrieve detailed nutritional information with OAuth2 authentication.

Features Food Search: Search food items with various filters. OAuth2 Authentication: Secure access with token-based authentication. Token Management: Automatic token generation and validation with expiry handling. Customizable Results: Control the number of results, pagination, and food details. Requirements Python 3.7 or higher FastAPI Requests library Uvicorn (for running the app) Installation Clone the repository:

bash Copy Edit git clone https://github.com/your-username/food-search-api.git Navigate to the project folder:

bash Copy Edit cd food-search-api Install dependencies:

bash Copy Edit pip install -r requirements.txt Setup Add your FatSecret API credentials in the API_KEY and API_SECRET variables in the main.py file. Start the FastAPI application: bash Copy Edit uvicorn main:app --reload API Endpoints

  1. /foods/search Search for food items.

Method: GET

Query Parameters:

query: Search expression for food. max_results: Maximum number of results per page (max 50). page_number: Zero-based page number. include_sub_categories: Include sub-categories (default False). include_food_images: Include images of food items (default False). include_food_attributes: Include dietary preferences and allergens (default False). flag_default_serving: Flag default serving (default False). region: Region for results (optional). language: Language for results (optional). format: Response format (default json). Response:

JSON object containing search results and nutritional information. 2. /token Generate a new access token.

Method: POST

Response:

JSON object containing access_token and token_type. Testing the API Test Token Generation: First, call the /token endpoint to get a bearer token. Search Food Items: Use the /foods/search endpoint with the valid token to search for food. License MIT License. See LICENSE for more details.

About

This project is a Food Search API built with FastAPI and OAuth2 integration for secure access to the FatSecret API. It allows users to search for food items, filter results, and fetch detailed nutritional information. The API manages token generation, validation, and expiry for seamless interaction.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages