How to create a Stock Entry from a Custom App?

In a custom app that I am building.

I want to create Stock Entry for material movement.

I have been trying to us the APIs provided in Stock module but it keeps failing.

BTW I want to achieve this using JavaScript.

What is the best way to create a Stock Entry from my Custom App?