I'm using py.test for REST API automation using python request library. 
How to get coverage using pytest-cov tool. I'm running the automation on build server and code is executed in application server.
The usual coverage tools are built for the much more common case of the measured code being run inside the same process as the test runner.  You not only are running in a different process, but a different machine.
You can use coverage.py directly on the remote machine when you start the process running the code under test.  How you would do that depends on how you start that process today.  The simple rule of thumb is that wherever you had been saying, "python my_prog.py", you can say, "coverage run my_prog.py".
pytest-cov get automation coverage from remote server