Backend code

You will need to write a plugin for that. See Developing Discourse Plugins - Part 1 - Create a basic plugin.

But will I be able to use that plugin with the SaaS version of Discourse (with the standard plan)?

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.

Is this precise enough to target user from Quebec, Canada only. Most GeoIP services I found had a country precision but were not able to target a specific province in Canada.

If you are on our hosting, please contact our support. We can help you with custom plugins in our Enterprise plan.

So not possible with the Standard plan? My guess is the Enterprise plan is at least 3x the price of the Standard plan.