Skip to content

Latest commit

 

History

History
172 lines (152 loc) · 4.07 KB

README.md

File metadata and controls

172 lines (152 loc) · 4.07 KB

SkincareAPI

SkincareAPI is a skincare product API. The API was created as part of a capstone project for Ada Developers Academy.

The idea is to provide users with a catalog of products with brand, name, and ingredients that can be used for test projects.

API

Base URL

GET https://skincare-api.herokuapp.com

Products

GET /products

Returns a list of all products

[
    {
        "id": 1,
        "brand": "amorepacific",
        "name": "age spot brightening pen",
        "ingredient_list": [
            "water",
            "butylene glycol",
            "alcohol",
        ]
    },
    {
        "id": 2,
        "brand": "amorepacific",
        "name": "all day balancing care serum",
        "ingredient_list": [
            "camellia sinensis leaf water",
            "phyllostachis bambusoides juice",
            "panax ginseng root extract",
        ]
    },
    {
        "id": 3,
        "brand": "amorepacific",
        "name": "bio-enzyme refining complex",
        "ingredient_list": [
            "panax ginseng root extract",
            "cyclopentasiloxane",
            "dimethicone",
        ]
    },
]

GET /products/1

Returns a single product by id number

{
    "id": 1,
    "brand": "amorepacific",
    "name": "age spot brightening pen",
    "ingredient_list": [
        "water",
        "butylene glycol",
        "alcohol",
        "dipropylene glycol",
        "peg-75",
        "glycereth-26",
        "ascorbyl glucoside",
    ]
}

POST /products

Adds a product, new ingredients are added to the ingredient database
Accepted params (all fields must be present):

  • brand (string)
  • name (string)
  • ingredients (string, separated by commas) ex. "water,alcohol,citric acid,..."

Ingredients

GET /ingredients

Returns a list of all unique ingredients

[
    {
        "id": 1,
        "ingredient": "water"
    },
    {
        "id": 2,
        "ingredient": "butylene glycol"
    },
    {
        "id": 3,
        "ingredient": "alcohol"
    },
]

Queries

Products and ingredients can both be queried at their singular route

GET /product?q=rose+water

Searches brand, name, and ingredients for LIKE values

[
    {
        "id": 564,
        "brand": "lioele",
        "name": "a.c control mousse cleanser trouble hunter",
        "ingredient_list": [
            "water",
            "ammonium lauryl sulfate",
            "cocamidopropyl betaine",
            "peg-8",
            "polysorbate 20",
            "salicylic acid",
            "fragrance",
            "henoxyethanol",
            "potassium hydroxide",
            "methylparaben",
            "sodium methyl cocoyl taurate",
            "sodium citrate",
            "tetrasodium edta",
            "dipotassium glycyrrhizate",
            "tocopheryl acetate",
            "benzophenone-4",
            "rose water",
            "camillia sinensis leaf extract."
        ]
    },
]

GET /ingredient?q=rose+water

Searches ingredient for LIKE values

[
    {
        "id": 2493,
        "ingredient": "rose water"
    },
    {
        "id": 3103,
        "ingredient": "damask rose water"
    }
]

Query Pagination

Addition params can be sent for pagination results

  • limit (default 10)
  • page

Example

GET https://skincare-api.herokuapp.com/product?q=rose&limit=25&page=1

Cheatsheet

Method Endpoint Description
GET /products Returns an array of product
GET /products/:id Returns an object with matching :id. If the id doesn't exist response will be 404
POST /products Adds a new product with the correct params. Invalid entries response will be 400
GET /ingredients Returns an array of ingredient
GET /product?q= Returns an array of searched product. Empty array for no results (pagination params: limit, page)
GET /ingredient?q= Returns an array of searched ingredient. Empty array for no results (pagination params: limit, page)