Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

API Endpoints

Kelvin Tay edited this page Feb 8, 2015 · 8 revisions

List of callable API Endpoints

Important Notes

Because Snakebite aspires to follow the best conventions for RESTful web services, all HTTP requests that typically sends a payload (i.e., POST, PUT and PATCH methods) should have their payload written in JSON.

As such, the following is needed:

In HTTP request's headers: Content-Type: application/json

Dashboard / Overview

Endpoint Method Description Permissions* Progress Notes
/restaurants GET Get all restaurants. Possible to filter based on criteria All Users 100% Filters undone
/restaurants POST Create a new restaurant. Required fields listed below Admin & Owners 100% -
/restaurants/<id> GET Get details of restaurant (of supplied id) All Users 100% -
/restaurants/<id> PATCH Update particular details of restaurant (of id) Admin & Owners 0% we are not using UPDATE. see this article for explanation
/restaurants/<id> DELETE Delete this restaurant (of id) Admin 100% -
/tags GET Get all tags sorted in popularity / frequency All 100% -

GET /restaurants

Get all restaurants. You can set search criteria in the query parameters of the request URL, such as the following:

query param description notes
name restaurant name name=KFC searches for restaurants with names containing KFC
description restaurant description description=curry search for restaurants with curry word in description
email restaurant email searches for exact match in emails
menus.name menu name menus.name=karaagesearches for restaurants with menu names matching karaage
tags restaurant tags tags=chicken,curry searches for restaurants with both chicken and curry tags
menus.tags menu tags menus.tags=breakfast,western searches for restaurants with menu(s) containing breakfast and western tags
start pagination offset defaults to 0, if start=1, results return from 2nd restaurant
limit query size limit defaults to 20; returns a maximum of 20 items by default

Example

retrieving all restaurants of email info@diya-dining.jp and has been tagged curry

Request:

GET /restaurants?tags=curry&email=info@diya-dining.jp

Response:

{
    "count": 1,
    "items": [
        {
            "geolocation": {
                "lat": 35.6604935,
                "lon": 139.7300985
            },
            "address": "ROPPONGI HILLS HILL SIDE B1 6-10-1 ROPPONGI, MINATO-KU",
            "description": "The first Contemporary Indian dining restaurant in Tokyo",
            "name": "Diya",
            "_id": {
                "$oid": "54d5b9be81b4b70009bc0bac"
            },
            "menus": [
                {
                    "tags": [
                        "india"
                    ],
                    "images": [
                        "https://drive.google.com/open?id=0BxDkA70TnFRFLWpwMURLcDFIN1E&authuser=1"
                    ],
                    "currency": "JPY",
                    "name": "Diya's Course",
                    "price": 3500,
                    "rating": 0
                },
                {
                    "tags": [
                        "chicken"
                    ],
                    "images": [
                        "https://drive.google.com/open?id=0BxDkA70TnFRFQ0NoeHRxNDdEdVU&authuser=1"
                    ],
                    "currency": "JPY",
                    "name": "CHICKEN TIKKA MAKHANI",
                    "price": 1480,
                    "rating": 0
                }
            ],
            "email": "info@diya-dining.jp",
            "tags": [
                "curry",
                "indian",
                "lunch buffet"
            ]
        }
    ]
}

POST /restaurants

Create a new restaurant with menus (optional, encouraged). If success, returns the saved details.

Example

creating a new Yoshinoya Restaurant with 2 menus

Request:

POST / restaurants
{
    "name": "Yoshinoya", 
    "address": "5-2-1 Tsukiji, Chuo-ku, Tokyo", 
    "geolocation": {
        "lat": 35.663968,
        "lon": 139.770473",  // optional
    },
    "email": "steaks@gmail.com", 
    "tags": "beef, franchise, japanese",  // optional
    "menus": [
        {
             "name": "Gyudon", 
             "price": 300.00,
             "currency": "JPY", // defauls to JPY nonetheless
             "images": ["http://example.com/1.jpg"]
        },
        {
             "name": "Curry Rice Set", 
             "price": 500.00,
             "currency": "JPY",
             "images": ["http://example.com/2.jpg", "http://example.com/3.jpg"]
        }
    ]
}

Response:

{
    "_id": "27342859401923012401", // with ID returned!
    "name": "Yoshinoya", 
    "address": "5-2-1 Tsukiji, Chuo-ku, Tokyo", 
    "geolocation": {
        "lat": 35.663968,
        "lon": 139.770473",  // optional
    },
    "email": "steaks@gmail.com", 
    "tags": "beef, franchise, japanese",  // optional
    "menus": [
        {
             "name": "Gyudon", 
             "price": 300.00,
             "currency": "JPY", // defauls to JPY nonetheless
             "images": ["http://example.com/1.jpg"]
        },
        {
             "name": "Curry Rice Set", 
             "price": 500.00,
             "currency": "JPY",
             "images": ["http://example.com/2.jpg", "http://example.com/3.jpg"]
        }
    ]
}

GET restaurants/<:id>

Get the details of a particular restaurant of ID :id

Example

Get the details of restaurant with ID 27342859401923012401

Request:

GET / restaurants/27342859401923012401

Response:

{
    "_id": "27342859401923012401", // with ID returned!
    "name": "Yoshinoya", 
    "address": "5-2-1 Tsukiji, Chuo-ku, Tokyo", 
    "geolocation": {
        "lat": 35.663968,
        "lon": 139.770473",  // optional
    },
    "email": "steaks@gmail.com", 
    "tags": "beef, franchise, japanese",  // optional
    "menus": [
        {
             "name": "Gyudon", 
             "price": 300.00,
             "currency": "JPY", // defaults to JPY nonetheless
             "images": ["http://example.com/1.jpg"]
        },
        {
             "name": "Curry Rice Set", 
             "price": 500.00,
             "currency": "JPY",
             "images": ["http://example.com/2.jpg", "http://example.com/3.jpg"]
        }
    ]
}

DELETE restaurant restaurants/<:id>

Delete the restaurant of ID :id

Example

Deleting the Yoshinoya restaurant above

Request:

DELETE / restaurants/27342859401923012401

Response:

http status code -> 200


GET / tags

Get tags used in Snakebite, ordered by most frequently used Available query params:

query params description notes
start pagination offset defaults to 0, if start=1, results return from 2nd restaurant
limit query size limit defaults to 20; returns a maximum of 20 items by default

Example

Get the 6th - 10th most frequently used tags (5 tags in total)

Request:

GET / tags?start=5&limit=5

Response:

{
    "count": 5,
    "items": [
        [
            "bar",
            0.09090909090909091
        ],
        [
            "roppongi",
            0.09090909090909091
        ],
        [
            "japanese food",
            0.09090909090909091
        ],
        [
            "lunch buffet",
            0.09090909090909091
        ],
        [
            "grill",
            0.09090909090909091
        ]
    ]
}