Skip to content

API to scrape and fetch random Cookpad recipes using provided ingredients

Notifications You must be signed in to change notification settings

nekkuzuria/cookpad-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cookpad Recipe Scraper API

This project is a simple API to scrape recipes from Cookpad based on provided ingredients. It uses Fastify, Axios, and Cheerio for web scraping.

Prerequisites

  • Node.js (version 14 or higher)
  • npm or yarn
  • API Key from AbstractAPI

Getting Started

  1. Clone the repository:

    git clone https://github.com/yourusername/cookpad-api
    cd cookpad-api
  2. Install dependencies:

    npm install
    # or
    yarn install
  3. Create Environment Configuration:

    • Copy the .env.example file to .env:
      cp .env.example .env
    • Open the .env file and add your AbstractAPI key:
      API_KEY=your_abstractapi_key_here
      You need to generate an API key from AbstractAPI
  4. Start the server:

    node server.js  

    The server will start on http://localhost:3000.



API Endpoint

To search for recipes using specific ingredients, send a GET request to:

http://localhost:3000/recipes?ingredients=your_ingredients

Replace your_ingredients with the ingredients you want to search for.



Functionality

  • The API fetches a list of recipes from Cookpad based on the provided ingredients.
  • It randomly selects a recipe from the list and returns the recipe details.
  • The returned data includes the recipe title, image URL, ingredients, and the Cookpad recipe URL.


Example Request and Response

Request:

http://localhost:3000/api/search?ingredients=tepung%20telur

Response:

{
  "title": "Telur Dadar Buncis Kentang Tepung Beras",
  "image": "https://img-global.cpcdn.com/recipes/96d390d8744a5391/160x176cq30/telur-dadar-buncis-kentang-tepung-beras-foto-resep-utama.jpg",
  "ingredients": "telur ayam,\n      buncis,\n      kentang,\n      Tepung beras,\n      Bahan lainya :,\n      cabe giling,\n      garam,\n      kaldu bubuk,\n      lada bubuk,\n      air putih,\n      minyak goreng",
  "url": "https://cookpad.com/id/resep/17196667-telur-dadar-buncis-kentang-tepung-beras"
}

About

API to scrape and fetch random Cookpad recipes using provided ingredients

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published