Skip to content
REST API for restaurants using Django REST Framework. 🍕
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Restaurants REST API


List all the restaurants.

    GET /restaurants/

Optional parameter available to sort all the restaurants by name.

    GET /restaurants/?sort=true

Add a restaurant to the list of known restaurants. Names are unique and a message will be returned if there is duplication.

    POST /restaurants/
    {'name': 'Burger1'}

Delete a restaurant from the list of restaurants.

    DELETE /restaurants/<name>/

Pick a random restaurant from the list of restaurants.

    GET /restaurants/random/


If you don't have Python you can follow the instructions from

Make sure to install Python 3.x

First, create an environment.

$ virtualenv env

If you have both python 2.x and 3.x versions, use the below command.

$ virtualenv --python=/usr/bin/python3 env

You can activate it.

$ source ./env/bin/activate

Verify the version of python with the below command.

$ python
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.

When not using you can deactivate it.

$ deactivate


$ pip install -r requirements.txt

Database configuration

Default values are: user=api, password=restaurantapi. Set environment variables with your own values.

$ export DB_USER=<USER>
$ export DB_PASS=<PASS>


$ python runserver

You can go to http://localhost:8000 and use the Django REST Framework API interface

or use cURL:

$ curl -X GET
curl -X POST \
  -H 'content-type: application/json' \
  -d '{"name": "New Restaurant"}'
curl -X DELETE
curl -X GET


$ python test
You can’t perform that action at this time.