Do not quit on API call on invalid object

Fix #1339
rename 'api' namespace to 'nwapi'