Search code examples
javascriptip

Get info of a IP address


I personally use an API to get info about an Ip address like, it's origin, company etc. But how does that API get's that much info about the IP? If anyone knows it please answer. Knowing how to get that in Javascript and help very much.


Solution

  • It’s surprisingly not very complicated.

    At its core, every IP address is registered to a company. That company has an address. GeoIP companies created databases of IP addresses and their associated address information. The addresses can be converted to coordinates, include things like postal codes, city/county/state/country information, and more. Even more data can be associated if the GeoIP company can differentiate between…say…IPs assigned to customers of an ISP or IPs assigned to server farms, colleges, starbucks, etc… You can even start to come up with your own ‘reputation’ scheme for various IPs. Some IPs might be ‘bad’ because they send a lot of spam, or host scam sites.

    Now-a-days, GeoIP is used by a lot of services. A well-known example is Netflix. They use GeoIP databases to figure out if a user is in the United States and should see certain content verses someone in the UK who should see different content due to licensing restrictions.

    Because of this, internet providers, server providers, and businesses have an inventive to ‘register’ their IP addresses and make sure they are listed correctly with GeoIP companies—otherwise users might not be able to watch Netflix, Amazon Video, or some other service. Registering provides more and more data to the GeoIP companies for their databases.

    The databases aren’t accurate in the sense that someone knowing your IP knows where your house is, but they probably know the city.

    I just checked my IP and it comes back to my local internet provider (a small local provider unlike Comcast or the other big players) and it has GeoIP coordinates that are about 4 miles away from my house at their central office.