Skip to content

An API to search for recipes by country and provide learning opportunities about said country's culture!

Notifications You must be signed in to change notification settings

naomiyocum/lunch_and_learn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

58 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Lunch and Learn πŸ±πŸ“š

GitHub Contributors GitHub language count GitHub top language

Table of Contents

General Info

My team is working in a service-oriented architecture. The front-end will communicate with my back-end through the API exposed.

We are building an application that allows users to search for cuisines by country, and provide opportunity to learn more about that country's culture. This app will allow users to search for recipes by country, favorite recipes, and learn more about a particular country via a YouTube video and a variety of images.

Learning Goals

  • Expose an API that aggregates data from multiple external APIs
  • Expose an API that requires an authentication token
  • Expose an API for CRUD functionality
  • Determine completion criteria based on the needs of other developers
  • Create appropriate error messages to assist developers
  • Test both API consumption and exposure, making use of Webmock and VCR

Technologies

  • Ruby 2.7.4
  • Rails 5.2.8

Usage

You will need to get your own free API keys from the following services:

  1. Edamam Recipe API
  2. YouTube API
  3. Unsplash API

After getting your 3 keys, fork and clone this repo to your local machine.

Then, run the following commands:

cd lunch_and_learn
bundle install
bundle exec figaro install
rails db:{drop,create,migrate,seed}

In the config/application.yml file, copy and paste the code block below and replace the values with your API keys:

edamam-app-id: <YOUR_EDAMAM_API_ID>
edamam-app-key: <YOUR_EDAMAM_API_KEY>
youtube-key: <YOUR_YOUTUBE_API_KEY>
unsplash-key: <YOUR_UNSPLASH_API_KEY>

Start your server in the root directory:

rails s

Lastly, head to your web browser or Postman to consume my API. The base URL is http://localhost:3000 and endpoints are listed below!

You can stop the server by clicking Ctrl + C on your keyboard.

API Endpoints

REQUIRED HEADERS

{
'Content-Type': 'application/json',
'Accept': 'application/json'
}
  • GET /api/v1/recipes

    fetch recipes based on a particular country

    Query Parameter Type
    country string Optional

    if no country is provided, a random country will be searched for you

    Example Response

    {
      "data": [
          {
              "id": null,
              "type": "recipe",
              "attributes": {
                  "title": "Passport to Japan: Edamame, Gyoza, Rice and Teriyaki Beef",
                  "url": "https://www.foodnetwork.com/recipes/rachael-ray/passport-to-japan-edamame-gyoza-rice-and-teriyaki-beef-recipe-2013871",
                  "country": "japan",
                  "image": "https://edamam-product-images.s3.amazonaws.com/web-img/237/2374bd7d348b32ba325739f8d9169119.jpeg..."
              }
          },
          {
              "id": null,
              "type": "recipe",
              "attributes": {
                  "title": "Zero Proof: Shiso Limeade Recipe",
                  "url": "http://www.seriouseats.com/recipes/2011/08/zero-proof-shiso-limeade.html",
                  "country": "japan",
                  "image": "https://edamam-product-images.s3.amazonaws.com/web-img/847/8475a2dca7024c9d5a7fa2a3e2806979.jpg..."
              }
          }
       ]
    }

  • GET /api/v1/learning_resources

    fetch learning resources for a particular country

    Query Parameter Type
    country string Optional

    if no country is provided, a random country will be searched for you

    Example Response

    {
      "data": {
          "id": null,
          "type": "learning_resource",
          "attributes": {
              "country": "philippines",
              "video": {
                  "title": "A Super Quick History of the Philippines",
                  "youtube_video_id": "De08VKktvJ4"
              },
              "images": [
                  {
                      "alt_tag": "landscape photography of island with boats",
                      "url": "https://images.unsplash.com/photo-1531761535209-180857e963b9?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwzOTkxMzV8MHwxfHNlYXJjaHwyfHxwaGlsaXBwaW5lc3xlbnwwfHx8fDE2NzM4MDYyOTc&ixlib=rb-4.0.3&q=80&w=1080"
                  },
                  {
                      "alt_tag": "aerial photo of body of water between mountains",
                      "url": "https://images.unsplash.com/photo-1518509562904-e7ef99cdcc86?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwzOTkxMzV8MHwxfHNlYXJjaHwzfHxwaGlsaXBwaW5lc3xlbnwwfHx8fDE2NzM4MDYyOTc&ixlib=rb-4.0.3&q=80&w=1080"
                  }
               ]
           }
        }
    }

  • POST /api/v1/users

    registers a user with Lunch and Learn

    Body (JSON) Type
    name string Required
    email string Required
    password string Required
    password_confirmation string Required

    Example Response

    {
      "data": {
          "id": "3",
          "type": "user",
          "attributes": {
              "name": "Roronoa Zoro",
              "email": "piratehunter@onepiece.jp",
              "api_key": "D+W0GG0gYdj85zquv2U12w=="
            }
        }
    }

  • POST /api/v1/sessions

    logs user in

    Body (JSON) Type
    email string Required
    password string Required

    Example Response

    {
      "data": {
          "id": "4",
          "type": "user",
          "attributes": {
              "name": "Sanji",
              "email": "sanji@onepiece.jp",
              "api_key": "/cN53CTIOr2xHD/93BVpvg=="
            }
        }
    }

  • POST /api/v1/favorites

    adds recipes to a favorited list for a particular user

    Body (JSON) Type
    api_key string Required
    country string Required
    recipe_link string Required
    recipe_title string Required

    Successful Response

    {
      "success": "Favorite added successfully"
    }

  • GET /api/v1/favorites

    fetch favorites of a particular user

    Query Parameter Type
    api_key string Required

    Example Response

    {
      "data": [
          {
              "id": "7",
              "type": "favorite",
              "attributes": {
                  "recipe_title": "Okinawa Soba 沖縄そば",
                  "recipe_link": "https://www.justonecookbook.com/okinawa-soba/",
                  "country": "japan",
                  "created_at": "2023-01-16T03:28:49.956Z"
                }
            },
            {
              "id": "10",
              "type": "favorite",
              "attributes": {
                  "recipe_title": "Kare Kare",
                  "recipe_link": "https://panlasangpinoy.com/kare-kare-recipe/",
                  "country": "Philippines",
                  "created_at": "2023-01-16T03:42:22.956Z"
                }
            }
        ]
    }

  • DELETE /api/v1/favorites

    deletes a favorite

    Query Parameters Type
    api_key string Required
    recipe_link string Required

About

An API to search for recipes by country and provide learning opportunities about said country's culture!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published