Calculating Type2 (EIP1559) gasFees

Currently, I am using the metaswap codefi network API.

I find it highly unreliable and uncomfortable to be dependent on an external API for fetching the gas parameters.

Is there any other way, function or formula to calculate the maxFeePerGas and maxPriorityFeePerGas ?

If not, then it is high time to develop a standardized function for the same.

I require the gas parameters between a range : slow, medium and fast.