Improved the Javascript API example.
Better handling of missing optional parameters.