Country Calling Code from IP Address

ipapi ~ ipapi.co
Feb 10, 2018 · 2 min read

A country calling code (or dial in code or international subscriber dialing or ISD code) is a variable length numerical prefix that’s required when dialing a telephone number in another country.

Each country is assigned a unique code e.g. +1 for USA, +7 for Russia,+33 for France, +44 for UK,+49 for Germany, +61 for Australia,+852 for Hong Kong,+86 for China, +91 for India and so on.

Say you want to reach the New York Times from outside USA, you would prefix their number (i.e. “844 698 6397”) with +1, so the international number becomes “+1 844 698 6397”.

Automatic country code from IP address

Suppose you’ve got a website or a mobile app where you want to programmatically determine the international calling code of your visitor, we’ve got an API to make it super easy for you.

If you have the IP address of your visitor (e.g. 8.8.8.8), the following request will return a string with the international calling code : https://ipapi.co/8.8.8.8/country_calling_code/

It’s that easy, there’s no complex data structure data to parse.

If you are using the API on client side, you don’t even need to pass the IP address.
Simply making an AJAX call to https://ipapi.co/country_calling_code/ will return the country calling code.

Try it out in this codepen.

Reference : ipapi.co & API docs

ipapi ~ ipapi.co

Written by

IP Lookup | IP Location | Geolocation API — Best IP Address Finder — https://ipapi.co

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade