Fixed bugs in the examples/api.py file.