How to create a custom method and call it using API

How to create a custom method and call it using API.

I need a sample code and explanation.

https://frappeframework.com/docs/user/en/api/rest#remote-method-calls