How to integrate API with appium simulator

Can someone please help in using login api to run in the background and login using emulator? I’m using javascript.
Thanks in advance.