I am looking forward to an api that can convert html to mobi/epub format and can do a job really well.
My preference is JavaScript but any suggestions for java/perl or some other language api (which does a good job) are greatly welcome.
You can try to use EBook::Tools CPAN package. It supports epub format for both encoding/decoding.