Create custom method and call it via api

How can I create a custom method with parameters and call it via API.

I need a sample guide to implement this.

thanks.