You will need to write a plugin for that. See Developing Discourse Plugins - Part 1 - Create a basic plugin.
No need for API calls, as Discourse ships with MaxMind integration out of the box, and you can simply call DiscourseIpInfo.get(ip)
from your plugin.
If you are on our hosting, please contact our support. We can help you with custom plugins in our Enterprise plan.