Migrated API code to api.c - Cleanup of some code - Initial code for reading credential data