开源api
Geo-location is the identification or estimation of the real-world geographic location of an Internet-connected computer terminal or device.
地理位置是对互联网连接的计算机终端或设备的真实地理位置的标识或估计。
Basically, we can get location data from their IP address.
基本上,我们可以从其IP地址获取位置数据。
Geo-location offers a lot of advantages and increase level of customization to a website. We can:
地理位置提供了很多优势,并提高了网站的自定义级别。 我们可以:
and many, many more features.
还有很多其他功能
If you do a Google search, there are many services that offer Geo-location for a price. Or, companies like MaxMind that offer a subset of the data they’ve gathered over the years for free.
如果您进行Google搜索,则有许多服务可以按价格提供地理位置。 或者,像MaxMind这样的公司免费提供了这些年来收集的部分数据。
With companies like MaxMind, you have to download their database every now and then to make sure the data is up to date, manage your own servers, and all other house-keeping. That’s what IP Geolocation API will do for you.
对于像MaxMind这样的公司,您必须不时下载其数据库,以确保数据是最新的,管理自己的服务器以及所有其他整理工作。 这就是IP Geolocation API会为您做的。
IP Geolocation API, is a free to use Geo-location service.
IP Geolocation API ,是免费使用的Geo-location服务。
The code is open-source which means you can deploy your version of the product and let it run all the house keeping for you. It is written in Python. So, if you need to fork and modify, you probably need to know how to code in Python.
该代码是开源的 ,这意味着您可以部署产品的版本,并让它为您管理所有事务。 它是用Python编写的。 因此,如果您需要进行派生和修改,则可能需要了解如何使用Python进行编码。
When a request comes into the application,
当请求进入应用程序时,
Heroku is probably the best option since it’s managed.. If you already use Heroku, you can do a quick deploy by clicking this link.
Heroku可能是最好的选择,因为它已经被管理。如果您已经在使用Heroku,则可以通过单击此链接进行快速部署。
Another reason to use heroku is that whenever the database gets updated, deployment is very easy.
使用heroku的另一个原因是,每当数据库更新时,部署都很容易。
Currently, the API has four HTTP endpoints. **Don’t leave the slash at the end of the URL**.
目前,API有四个HTTP端点。 **不要在网址末尾加斜杠**。
GET https://api.ipgeolocationapi.com/geolocate HTTP/1.1
GET https://api.ipgeolocationapi.com/geolocate/ HTTP/1.1
GET https://api.ipgeolocationapi.com/countries HTTP/1.1
GET https://api.ipgeolocationapi.com/countries/ HTTP/1.1
/geolocate
will automatically detect the users IP address and return the location data.
/geolocate
将自动检测用户的IP地址并返回位置数据。
/geolocate/
requires you to supply the users IP address and returns the same data as /geolocate
/geolocate/
要求您提供用户IP地址并返回与/geolocate
相同的数据
/countries
returns a list of the countries in the database and all the information they have about them.
/countries
返回数据库中的国家/countries
列表,以及有关它们的所有信息。
/countries/
returns the information about one country.
/countries/
返回有关一个国家的信息。
Note: If you deployed your own version, you’ll want to replace _https://api.ipgeolocationapi.com with your own domain_
注意:如果您部署了自己的版本,则需要将_ https://api.ipgeolocationapi.com替换为您自己的domain_
Making a request to https://api.ipgeolocationapi.com/geolocate
will give you:
向https://api.ipgeolocationapi.com/geolocate
发出请求将为您提供:
{
"continent":"Europe",
"address_format":"{{recipient}}\n{{street}}\n{{postalcode}} {{city}}\n{{country}}",
"alpha2":"DE",
"alpha3":"DEU",
"country_code":"49",
"international_prefix":"00",
"ioc":"GER",
"gec":"GM",
"name":"Germany",
"national_destination_code_lengths":[
2,
3,
4,
5
],
"national_number_lengths":[
6,
7,
8,
9,
10,
11
],
"national_prefix":"0",
"number":"276",
"region":"Europe",
"subregion":"Western Europe",
"world_region":"EMEA",
"un_locode":"DE",
"nationality":"German",
"eu_member":true,
"eea_member":true,
"vat_rates":{
"standard":19,
"reduced":[
7
],
"super_reduced":null,
"parking":null
},
"postal_code":true,
"unofficial_names":[
"Germany",
"Deutschland",
"Allemagne",
"Alemania",
"ドイツ",
"Duitsland"
],
"languages_official":[
"de"
],
"languages_spoken":[
"de"
],
"geo":{
"latitude":51.165691,
"latitude_dec":"51.20246505737305",
"longitude":10.451526,
"longitude_dec":"10.382203102111816",
"max_latitude":55.0815,
"max_longitude":15.0418962,
"min_latitude":47.2701115,
"min_longitude":5.8663425,
"bounds":{
"northeast":{
"lat":55.0815,
"lng":15.0418962
},
"southwest":{
"lat":47.2701115,
"lng":5.8663425
}
}
},
"currency_code":"EUR",
"start_of_week":"monday"
}
With one request, the API can infer that my Iocation is Germany, the currency, longitude and latitude and so much more.
通过一个请求,API可以推断出我的Iocation是德国,货币,经度和纬度等等。
If you find this project useful, be sure to give them a star on Github, make contributions and support the author however you can. Thanks!
如果您觉得这个项目有用,请确保在Github上给他们一个星,并尽力为作者提供支持。 谢谢!
翻译自: https://scotch.io/tutorials/open-source-ip-geo-location-api
开源api