Added minimal error/exception handling and optional API URL parameter