Git Product home page Git Product logo

item-api's Introduction

item-api

Version

Overview:

This is a product API for grocery and item data. It will return information including prices, names, images descriptions, ids, nutrition information, and much more.

I built this API when I tried finding product data for a project, but couldn't find any that worked for my needs. The database is small and only contains 99 products, but new products are added every so often.

Newly introduced was the idea of multiple countries. Now, this project will include data from multiple countries.

By the Numbers:

* 99 total items
* 92 categories
* 70 different brands
* 2 countries
* 99 images
* $262.29 worth of products
* 122,761 total calories*

*some products may not be accounted for due to unreadable or incomplete nutritional information

Contents

* names
* price data in USD
* images for every product
* nutrition information
* descriptions
* desired temperatures
* displays stats on entire database
  * perfect for admin dashboard
* ingredients
* country of sale
* seasonal
* unique ids
* brands
* categories

Requirements

  • Node.js
  • command line

Installation:

git clone https://github.com/yZipperer/item-api.git

Running and Usage:

  1. Navigate into the cloned folder and type node app.js to start the server
  2. Once the server is running use the command line to call the routes listed below

Routes:

http://localhost:8080/            /*all data*/
http://localhost:8080/docs            /*returns the docs for the routes*/

--- Please Note ---
For the country parameter below (see masterList for all country codes), select one of the following (case sensitive):
  - "US"
  - "JP"

http://localhost:8080/food/:country            /*returns all food data based on country provided*/


--- Searching ---

http://localhost:8080/food?brand=putbrandhere            /*search based on brand*/
http://localhost:8080/food?cat=putcategoryhere            /*search based on category*/
http://localhost:8080/food?country=putcountrycodehere            /*search based on country*/
http://localhost:8080/food?cat=putcategoryhere&brand=putbrandhere&country=putcountrycodehere            /*search based on category and brand and country*/

--- Admin ---
http://localhost:8080/stats            /*shows stats on the items in the data set*/
example search: http://localhost:8080/stats?country=US /*see masterList in data folder for country codes*/

How to Search the Data (/food route)

  1. You will begin by typing one of the above routes into either a search bar, or you can make a request through a command line
  2. there are 2 route parameters to know
cat     This parameter is used to search based on category
brand     This parameter is used to search based on brand
country     This parameter is used to search based on country (see country code list)
  1. Use different parameter values to search for what you need

Sample URL:

http://localhost:8080/food?cat=putCATEGORYhere&brand=putBRANDhere&country=putCOUNTRYCODEhere


Sample URL Search for Franz Bread:

http://localhost:8080/food?cat=bakery&brand=Franz

Categories and Brands

Available Categories:

Categories for United States Data

Note: these are case sensitive

  Available Categories:
    * produce
      * bakery
          * sliced-bread
          * white-bread
          * multigrain-bread
          * buttermilk-bread
          * butter-bread
          * hawaiian-bread
          * wheat-bread
          * rolls-bread
          * hoagie
          * muffins
          * english-muffins
      * dry-goods
          * flour
          * sugar
          * oats
          * dry-coffee
          * mixes
            * brownie-mix
      * brownies
      * canned
          * canned-produce
      * dairy
          * milk
              * whole-milk
              * 1-percent-milk
          * Eggs
          * cheese
              * sliced-cheese
              * cream-cheese
          * yogurt
      * water
          * bottled-water
          * case-water
          * jug-water
      * candy
          * boxed-candy
          * bar-candy
          * bagged-candy
      * seafood
          * tuna
      * crackers
        * cheddar-crackers
        * peanut-butter-crackers
      * cookies
        * chocolate-cookies
      * (flavors)
          * strawberry
          * chocolate
          * vanilla
          * cheddar
          * chili-cheese
          * honey
          * cinnamon
          * fruit
      * pasta
          * ravioli
          * meatballs
      * coffee
      * cereal
      * breakfast
      * seasoning
          * extract
          * seasoning mix
      * vegan
      * vegetarian
      * meat-alternative
      * snacks
        * nuts
        * popcorn
        * chips
          * corn-chip
          * potato-chip
        * granola
      * bar
      * sauce
      * jar
      * cup
      * preserves
      * quick-meal
        * quick-lunch
        * quick-dinner
        * quick-breakfast
      * pizza
Categories for Japan Data

Note: these are case sensitive

  Available Categories:
    * candy
      * wafer
      * gummy
    * (flavors)
        * orange
        * chocolate
        * corn
        * matcha
        * peach
        * green-apple
        * pizza
    * snacks
        * popcorn
        * chips
    * breadsticks

Available Brands:

Brands for United States Data

Note: these are case sensitive

  Available Brands:
    * unknown (This is for things like produce and products that don't have a clear brand name)
    * Franz
    * Del Monte
    * Bush's
    * Hunt's
    * Dole
    * Rosarita
    * Manwich
    * Chef Boyardee
    * Gold Medal
    * C&H
    * Quaker
    * Eggland's Best
    * Sargento
    * Meadow Gold
    * TruMoo
    * Grandma Sycamore's
    * Sara Lee
    * Great Grains
    * Aquafina
    * Nestle
    * Crystal Geyser
    * Ball Park
    * Bolthouse Farms
    * Hershey's
    * Yoplait
    * Kraft
    * Campbell's
    * StarKist
    * Whoppers
    * Twizzlers
    * Philadelphia
    * Honey Maid
    * Lay's
    * Nabisco
      * Ritz
      * Chips Ahoy!
      * Nilla
    * Cheez-It
    * Kellogg's
      * Club
      * Froot Loops
    * Pepperidge Farm
      * Goldfish
    * Folgers
    * Pillsbury
      * Funfetti
    * Oreo
    * Thomas'
    * Cheetos
    * Doritos
    * General Mills
      * Cheerios
        * Honey Nut Cheerios
      * Cinnamon Toast Crunch
      * Lucky Charms
    * SunChips
    * McCormick
    * MorningStar Farms
    * Nature Valley
    * Mott's
    * Smucker's
    * Lunchables
    * Totino's
    * Planters
    * Knorr
Brands for Japan Data

Note: these are case sensitive

  Available Brands:
    * Nestle
      * KitKat
    * Yaokin
    * Glico
      * Pocky
    * Calbee

For a more comprehensive list see the masterList in the data folder of each country.

Data Layout:

Sample Data Layout:

    {
        "name": "Planters Mixed Nuts with Peanuts, Almonds, Cashews, Hazelnuts, and Pecans",
        "id": "fnm230",
        "country": "United States",
        "seasonal": "all",
        "category": ["nuts", "snacks"],
        "brand": "Planters",
        "weight": "10.3 ounces",
        "hot": false,
        "cold": false,
        "frozen": false,
        "description": "Planters Mixed Nuts offer a crunchy combination of peanuts, almonds, cashews, hazelnuts and pecans, making them a perfect on-the-go snack to curb your cravings for a crunchy treat. These mixed nuts contain sea salt for a savory flavor that satisfies. Planters mixed nuts are roasted and packed in the USA. Sprinkle these Kosher mixed nuts over a salad, or serve them with soups.",
        "price": {
            "USD": {
                "default": "4.62",
                "formatted": "$4.62/each"
            }
        },
        "image": "http://localhost:8080/fnm230.jpeg",
        "nutrition": {
            "serving size": "1 ounce (28 grams/32 pieces)",
            "servings per container": "10",
            "calories": "170",
            "fat": "15 grams",
            "cholesterol": "0 milligrams",
            "sodium": "90 milligrams",
            "potassium": "200 milligrams",
            "carbohydrates": "6 grams",
            "sugars": "0 grams",
            "dietary fiber": "3 grams",
            "protein": "6 grams"
        },
        "ingredients": "PEANUTS, ALMONDS, CASHEWS, HAZELNUTS (FILBERTS), PECANS, PEANUT OIL, SEA SALT."
    }

Getting Images:

  1. make a request to the desired category
  2. In the returned json there will be an image link
  3. Put the link into the address bar of any browser
  4. As long as the server is running, you should get the image associated with the product

Contributions:

Contributions are welcome, especially for product data. Just open up an issue with what you would like to add.

To contribute, locate the data.json file in the data folder. Then, copy and paste one of the latest product entries (at bottom of data.json file). Modify this to include information on the new product. Then, add a corresponding image in the images folder (make sure the file name and product id match)

*You should also make sure the product has not already been added. Simply ctrl+F as search through the data.json file, or check the masterList to make sure the product has not been added.

Troubleshooting

If you have any problems in usage or contributing, simply open up an issue with your questions.

item-api's People

Contributors

yzipperer avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

alejo8591

item-api's Issues

Finish Ingredient Implementation

With the recent addition of 4 new products, I have added a new field to the data titled 'ingredients'. It is located just underneath the nutrition section of each product. So far, 4/58 products have ingredients included. The rest have the field, but it is empty.

The ingredients need to be displayed for the rest of the products.

Create Master Item List

There is a need for a master list of every item in the data file. This list needs to be alphabetized and easily searchable.

This list would not only give a quick reference, but it would also create a way to see if something has already been entered to avoid duplicate items.

Alphabetization Adjustment

As the data set is growing larger and larger, I think it would be a good idea to alphabetize things like categories and brands so they can be found easier.

Target files:
The Readme has lists of categories and brands that need to be organized as well as the masterList in the data folder.

Data Layout

I think it would be a good idea to add a data layout to the Readme. It would be nice to show what the data looks like, so the users can see what is exactly included and how to work with it.

New Categories

There is an increasing need for more and more smaller categories with the addition of new products. Some categories should be split down with smaller tags added.

For example, a pack of sliced cheese could have a category of dairy, cheese, sliced, etc.
This is going to take some time to add.

Shelf Life

There is a need for some sort of shelf life for each product. It would be very beneficial to add in a shelf life data value to each product.

This would open up the possibility of items being removed from the database if their shelf life has been passed and possibly moved to clearance if it is close to end of life.

External Search Program

I think it would be beneficial to have some sort of external search program. This way, anyone could easily search the database and have possible categories and brands all in the program without needing to make separate calls for each search.

Stats Route

I think it would be cool to have a stats route for development purposes and admin purposes.

This stats route would be a route for developers to see how much data/brands/categories/prices are contained in the database.
It would also be pretty nice to have a stats route so that a possible admin dashboard could use this data to see basic stats on the data.

Code Refactor

Now that the database of items is further growing, I think it would be a good idea to refactor some things to make it easier for the end user to parse the data.

One thing I would like to add is to combine all of the data into a single document. There are just way too many files. Splitting up the files makes it easier to find and add new items, but it makes it less uniform.

I would also like to add a single route maybe with parameters. These parameters would sort the data based off of category, price, size, nutrition, etc.

Another thing I would like to change is the uniformity of the data. As it stands, a lot of the data is not the same. There are pieces missing and other pieces that are completely new. One thing is the serving size. Instead of having one attribute saying amount, there are multiple data types for cups, pieces, grams, etc. I would like to combine these into one so that anyone using this API can easily parse the data for their project.

The final thing I am looking to implementing is proper versioning. There is no proper versioning and I would like to introduce that.

env variables in JSON

Find a way to implement env variables in the JSON data files. Every image link is hard coded as localhost, since the images are hosted on the same server. Env variables would allow for easier deployment outside of the local machine.

Names not showing

When I made a request to the default food route with no search parameters, I get the names of the items. Then, when I make a request with parameters, I get no names of products, just the data associated with the products.

To fix this it might be a good idea to split up the data and create a name attribute.

Temperature Regulation

There needs to be something in place to distinguish between hot/cold items.

In a real world situation, the website admins may need to know if an item requires special temperature regulation. It may also be useful when it comes to shipping to possibly calculate an extra dry ice cost or thermal box cost to keep the item at its desired temperature.

I imagine this could easily be implemented with two new data values per product specifying hot or cold, with a Boolean value. This would be best added now, before the data set grows too large.

Temperature URL Parameter

After including the temperature values into each item, I think it would be a good idea to include this in a search.

There are some cases when there may be a frozen foods sale or something similar. Maybe at the end of the day all of the hot chicken is sold at discount. This presents an issue, because as it stands, there is no way to search through the data based on temperature.

Adding a route parameter for searching based on temperature would be beneficial.

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.