Code Monkey home page Code Monkey logo

lunch_and_learn's Introduction

This project is a backend API that allows you to find recipes for specific countries and learning resources. It also allows you to create and authenticate users, and save favorites recipes to those users.

JSON API Contract

GET api/v1/recipes

OR

GET api/v1/recipes?country=laos

For this endpoint you can either specify a country or not. If a country is not specified than a random country will be selected. It returns recipes from the country.

{
    "data": [
        {

            "id": "null",
            "type": "recipe",
            "attributes": {
                "title": "Tiger Salad (Lao Hu Cai) Recipe, à la Xi'an Famous Foods",
                "url": "https://www.seriouseats.com/recipes/2019/06/tiger-salad-recipe.html",
                "country": "laos",
                "image": "https://edamam-product-images.s3.amazonaws.com/..."

        },
        {
            "id": "null",
            "type": "recipe",
            "attributes": {
                "title": "Nam Khao",
                "url": "https://food52.com/recipes/67233-nam-khao",
                "country": "laos",
                "image": "https://edamam-product-images.s3.amazonaws.com/..."
            }
        }, ...
        }
    ]
}

GET /api/v1/learning_resources?country=laos

For this endpoint you have to specify a country, it returns a video and images for the country.

{
    "data": {
        "id": "null",
        "type": "learning_resource",
        "attributes": {
            "country": "laos",
            "video": {
                "title": "A Super Quick History of Laos",
                "youtube_video_id": "uw8hjVqxMXw"
            },
            "images": [
                {
                    "alt_tag": "The picture taken in Laos, 06:00, from hot baloon",
                    "url": "https://images.unsplash.com/photo-1540611025311-01df3cef54b5?ixid=M3w0ODUxNjh8MHwxfHNlYXJjaHwxfHxsYW9zfGVufDB8fHx8MTY5MTg2MjczOHww&ixlib=rb-4.0.3"
                },
                ...
            ]
        }
    }
}

POST /api/v1/users

This endpoint creates new users that store favorites. When making a post request to this endpoint send a JSON payload as specified below. An api key will also be created for you.

request:

{
  "name": "Odell",
  "email": "[email protected]",
  "password": "treats4lyf",
  "password_confirmation": "treats4lyf"
}

response:

{
    "data": {
        "id": "1",
        "type": "user",
        "attributes": {
            "name": "Odell",
            "email": "[email protected]",
            "api_key": "ac757e90b18b8d9bbaf75fb35b5fbee5"
        }
    }
}

POST /api/v1/sessions

This endpoint will authenticate you as a user and return your API key.

request:

{
  "email": "[email protected]",
  "password": "treats4lyf"
}

response:

{
    "data": {
        "id": "1",
        "type": "user",
        "attributes": {
            "name": "Odell",
            "email": "[email protected]",
            "api_key": "ac757e90b18b8d9bbaf75fb35b5fbee5"
        }
    }
}

POST /api/v1/favorites

This endpoint will save a favorite recipe to your user. This enpoint requires an API key.

request:

{
    "api_key": "ac757e90b18b8d9bbaf75fb35b5fbee5",
    "recipe_link": "www.google.com",
    "recipe_title": "food",
    "country": "laos"
}

response:

{
    "success": "Favorite added successfully"
}

GET /api/v1/favorites?api_key=ac757e90b18b8d9bbaf75fb35b5fbee5

This endpoint will fetch all favorites saved under your user(api key).

{
    "data": [
        {
            "id": "1",
            "type": "favorite",
            "attributes": {
                "recipe_title": "food",
                "recipe_link": "www.google.com",
                "country": "laos",
                "created_at": "2023-08-12T18:16:34.547Z"
            }
        },
        {
            "id": "2",
            "type": "favorite",
            "attributes": {
                "recipe_title": "food",
                "recipe_link": "www.google.com",
                "country": "laos",
                "created_at": "2023-08-12T18:16:51.762Z"
            }
        }
    ]
}

lunch_and_learn's People

Contributors

boomclear avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.