Adding missing file api.py and test file for it