Modified api.go - Added some basic error checking and command line flag ...

...handling

	modified:   api.go