It's much simpler than it sounds, only 7 lines of code in the sample posted. The point is that most people don't want to share their private key or their users' private keys, justifiably so.
The alternative is building the full binary transaction on your end, which involves selecting inputs, generating scripts, worrying about fees, etc. Implementing that is a week's project. Using an API is 5 min.