Rest API 101 - Webcamp KL, May 2013 Code Demo
Create a virtualenv instance.
All commands below are prepended with an expected bash prompt.
- "$" indicates a normal bash prompt, virtualenv is not activated
- "(.env)$" indicates a bash prompt with virtualenv activated
$ virtualenv .env $ source .env/bin/activate (.env)$
Install the required packages.
(.env)$ pip install -r requirements.txt
Create the local settings file and configure it to your liking.
(.env)$ cp restapi_talk/settings/local.example.py restapi_talk/settings/local.py (.env)$ vim restapi_talk/settings/local.py
Generate the database file. Follow any on-screen instructions that is shown.
(.env)$ ./manage.py syncdb && ./manage.py migrate
If needed, you can load up some sample data to get you started:
(.env)$ ./manage.py loaddata restapi_talk/fundtracking/ixtures/sample_data.json
The demo page is implemented in iPython Notebook and for you to execute the code samples of accessing the API, here's what you'd need to do:
Start the Django server
python manage.py runserver
Start the iPython Notebook server
ipython notebok --pprint
If the iPython Notebook web interface is not loaded on your default web browser, you can access it by visiting http://localhost:8888/
Access the "REST API Demo" notebook and you can execute all codes that are listed there by selecting the cell and click on the "Run Cell" button.
The presentation slides are available at presentation/build/slides/index.html. You can also read the slide deck in one page.
If you want to adapt the content, you can follow the steps below:
Install the requirements for documentation generation:
(.env)$ pip install -r requirements.docs.txt
Edit presentation/source/index.rst, it's a ReStructured Text document.
Once you make the edits, you can generate the new slide show with the following command.
(.env)$ cd presentation (.env)$ make slides
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.