Where can I find the spec of the RPC api's of a EVM compatible URL? I wanted to create a custom RPC url that will work with metamask and other compatible eth wallets. But I need to know what does metamask and other wallets look for when they connect to a custom RPC node like polygon, avalanche, fantom, smart chain, etc...
Ethereum provides RPC JSON standard which are implemented by all the ethreum VM based clients like eth/geth and partity. The RPC API standard can be found at below git repository. execution-apis
To use it you need to build and then refer to openrpc.json file.
Alternatively you can also visit Ethereum-RPC-APIs that provides HTTP version for the same.
Metamask and other wallet applications call these APIs to fulfil their requirements. Client nodes expose the URL for RPC API requests. This url is provided to wallet applications using add network[in metamask] functionality. Wallet applications connect on that port and issue standard RPCs which gets honoured by the client node.
@NitBit's answer covers what JSON-RPC methods all Ethereum clients are expected to support, but I suspect it doesn't completely address the question because the initial wording of "custom RPC url" highlights to me there's a misunderstanding about what exactly a "RPC url" does.
RPC is used when talking about JSON-RPC, a way to design APIs to be used. While REST APIs are standard in web applications, Ethereum, and other blockchains have chosen JSON-RPC, mainly because the APIs serve different needs. REST stands for Representational State Transfer, where batches of data (resources) can be associated with methods (GET/POST/DELETE). RPC stands "Remote Procedure Call", and its goal is to tell a system to run a routine as if it was being executed on the machine directly. The JSON just clarifies that the data is transmitted using JSON.
The URL that accepts Ethereum RPC commands, (eventually) points to some machine running an Ethereum client, and the same is true for any other EVM compatible chain that you can use MetaMask with. This means that at the end of the day, that URL is always pointing back to some blockchain node. What non-Ethereum EVM compatible chains do is simply copy the Ethereum RPC standard and then process that RPC method in their blockchain clients to do what needs to be done.
MetaMask and URLs
In the vast majority of cases, it doesn't make sense to expose your node to public RPC traffic, since it costs money to run, and you see no financial gain from doing so. Additionally, a single node can only support so much traffic. "Custom" public RPC endpoints you see for chains that aren't Ethereum, or "Custom" private RPC endpoints in the case of Infura/Alchemy are actually pointing to a server hosted by someone who is running a large number of nodes, and will use that server to route your RPC request to a node that can respond to it.