Check out these links http://stackoverflow.com/questions/23682393/upload-a-video-via-php-and-encode-to-mp4-and-webm-on-the-server and http://stackoverflow.com/questions/6954845/how-to-create-a-webm-video-file
A PHP class won’t be able to do this on its own, it will take things like FFMPEG, but this is hard to install on your server. However in the title you wrote API, although API have several meanings, I suppose you may be if referendum on a "service", in this case try this answer I formulated In the title you say via API, I suppose this answer can help you http://en.stackoverflow.com/a/113600/3635
Can use this solution for server-side conversions.
– gato
Check out these links http://stackoverflow.com/questions/23682393/upload-a-video-via-php-and-encode-to-mp4-and-webm-on-the-server and http://stackoverflow.com/questions/6954845/how-to-create-a-webm-video-file
– Marcos Xavier
A PHP class won’t be able to do this on its own, it will take things like FFMPEG, but this is hard to install on your server. However in the title you wrote API, although API have several meanings, I suppose you may be if referendum on a "service", in this case try this answer I formulated In the title you say via API, I suppose this answer can help you http://en.stackoverflow.com/a/113600/3635
– Guilherme Nascimento