need code to get the country of the user using IP Address using C#.net with any free api's.
Loading
need code to get the country of the user using IP Address using C#.net with any free api's.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Tuhin PaulPosted Feb 16, 2023, 11:53 AM
Are you asking for source code using the free API provided by a free API to get the country of the user based on their IP address, then below is the sample you can check:
You can call the GetIPInfo method by passing in the user's IP address as a string. The method will return an IPInfo object that contains various information about the IP address, including the country.
Note that the free version of IP-API has some usage limitations and rate limits. You should review the terms and conditions of the service to ensure that you comply with them. There are also many other IP geolocation APIs available that you can use instead if you prefer.
There are several IP geolocation APIs available, both free and paid. Here are some of the popular ones:
See below how you can use the IP Geolocation API to fetch the country name of a user w.r.t their IP address:
In this example, you need to replace YOUR_API_KEY with your actual API key that you get when you sign up for the IP Geolocation API service. The GetIPInfo method takes an IP address as a string and returns an IPInfo object that contains various information about the IP address, including the country.
You can use a similar approach to call other IP geolocation APIs as well. Note that the properties of the IPInfo class may vary depending on the API you use.
Vishal YelvePosted Feb 16, 2023, 10:17 AM
https://rapidapi.com/category/Location
https://ipstack.com/
Naimish MakwanaPosted Feb 16, 2023, 9:00 AM
Hello Rakesh,
You can use blow api which is Free for non-commercial use.
https://ip-api.com/
Thanks
Naimish Makwana