If you're searching for an updated/accurate database I recommend to use this one here because it was showing my exact location which was not included in many other services when I was testing.
(My city was Rasht
and my country was Iran
with this ip address: 2.187.21.235
when I was testing.)
I recommend to use database rather than API methods, because it will be processed much faster locally.