Added NPM package.json and MIT license.
Improved error handling and API