Geobaza Overview

Geobaza is the product for identifying geolocation by the IP-address, developed and supported by CN-Software Ltd. Taking a certain IP-address, Geobaza outputs its local registration data — a country and a city with geographic coordinates. Geobaza optionally stores: object identifier ISO 3166, translations, up-to-date information about population size and official languages.

Features

  • Database files are in standard binary format
  • Monthly updates
  • Open-source, new-style BSD API license in the following languages: C/C++, Python, Perl, PHP, .NET.
  • Translations of geographical objects names in different languages (optional)
  • High precision of the geolocation identification for Russia and ex-USSR countries
  • High speed of processing
  • Autonomy and security—Geobaza is stored on your site and does not call the external sources while working

Geobaza provides detailed information about the place:

  • Names (different variants: official, informal, abbreviation and etc.)
  • Translations
  • Object type: country, region, city
  • Latitude
  • Longitude
  • Object identifier ISO 3166 (optional)
  • Population size (optional)
  • Official languages (optional)

Geobaza Includes

Database file in standard binary format

geobaza.dat is a binary file and is used by the API.

All records in CSV format

Ranges of IP-addresses in text and numerical formats together with the corresponding geographical objects.

geobaza.csv file, in the text format, provides information that is stored in geobaza.dat. It is not used by API, but it can be useful.

geobaza.csv format
PositionTypeDescription
1StringStart of the range in IPv4 form (aa.bb.cc.dd)
2StringEnd of the range in IPv4 form
332-bit IntegerStart of the range in decimal integer form
4IntegerRange size (end − start + 1)
5StringCountry TLD
6IntegerThe numeric identifier of the geographical location (city, region, country). We pledge not to change the identifier of the object in further releases. In case of special networks, the text description of the network is provided instead of the identifier, for example, Loopback.
7JSON (string)A detailed description of the geographical object in JSON format.

Example of the CSV-file containing all database records.

"0.0.0.0", "0.255.255.255", 0, 16777216, "", "This" Network, "{\"special\":\"\\"This\\" Network\"}"
"1.0.0.0", "1.0.0.255", 16777216, 256, "AU", 33316, "{\"population\":null,\"lang\":\"EN\",\"lat\":-27.466,\"name\":{\"EN\":\"Brisbane\"},\"name_official\":{\"RU\":\"Брисбен\",\"EN\":\"Brisbane\"},\"iso_id\":null,\"type\":\"locality\",\"id\":\"33316\",\"lon\":153.033}"
"1.0.1.0", "1.0.3.255", 16777472, 768, "CN", 33444, "{\"population\":null,\"lat\":26.071,\"name\":{\"EN\":\"Fuzhou\"},\"name_official\":{\"RU\":\"Фучжоу\",\"EN\":\"Fuzhou\"},\"iso_id\":null,\"type\":\"locality\",\"id\":\"33444\",\"lon\":119.303}"
"1.0.4.0", "1.0.7.255", 16778240, 1024, "AU", 11, "{\"population\":\"20001546\",\"hid\":\"/AU\",\"lang\":\"EN\",\"lat\":-25,\"name\":{\"RU\":\"Австралия\",\"EN\":\"Australia\"},\"name_official\":{\"EN\":\"Australia\"},\"iso_id\":\"AU\",\"type\":\"country\",\"id\":\"11\",\"lon\":135}"
"1.0.8.0", "1.0.15.255", 16779264, 2048, "CN", 33445, "{\"population\":null,\"lat\":23.127,\"name\":{\"EN\":\"Guangzhou\"},\"name_official\":{\"RU\":\"Гуанчжоу\",\"EN\":\"Guangzhou\"},\"iso_id\":null,\"type\":\"locality\",\"id\":\"33445\",\"lon\":113.247}"
"1.0.16.0", "1.0.31.255", 16781312, 4096, "JP", 103, "{\"population\":\"127078679\",\"hid\":\"/JP\",\"lang\":\"JA\",\"lat\":35.15,\"name\":{\"RU\":\"Япония\",\"JA\":\"日本\",\"EN\":\"Japan\"},\"name_official\":{\"EN\":\"Japan\"},\"iso_id\":\"JP\",\"type\":\"country\",\"id\":\"103\",\"lon\":136.06}"
"1.0.32.0", "1.0.63.255", 16785408, 8192, "CN", 33445, "{\"population\":null,\"lat\":23.127,\"name\":{\"EN\":\"Guangzhou\"},\"name_official\":{\"RU\":\"Гуанчжоу\",\"EN\":\"Guangzhou\"},\"iso_id\":null,\"type\":\"locality\",\"id\":\"33445\",\"lon\":113.247}"
"1.0.64.0", "1.0.127.255", 16793600, 16384, "JP", 103, "{\"population\":\"127078679\",\"hid\":\"/JP\",\"lang\":\"JA\",\"lat\":35.15,\"name\":{\"RU\":\"Япония\",\"JA\":\"日本\",\"EN\":\"Japan\"},\"name_official\":{\"EN\":\"Japan\"},\"iso_id\":\"JP\",\"type\":\"country\",\"id\":\"103\",\"lon\":136.06}"
"1.0.128.0", "1.0.255.255", 16809984, 32768, "TH", 29390, "{\"population\":null,\"lang\":\"TH\",\"lat\":13.75,\"name\":{\"EN\":\"Bangkok\"},\"name_official\":{\"RU\":\"Бангкок\",\"TH\":\"กรงเทพฯ, กรงเทพมหานคร\",\"EN\":\"Bangkok\"},\"iso_id\":null,\"type\":\"locality\",\"id\":\"29390\",\"lon\":100.516}"
"1.1.0.0", "1.1.0.255", 16842752, 256, "CN", 33444, "{\"population\":null,\"lat\":26.071,\"name\":{\"EN\":\"Fuzhou\"},\"name_official\":{\"RU\":\"Фучжоу\",\"EN\":\"Fuzhou\"},\"iso_id\":null,\"type\":\"locality\",\"id\":\"33444\",\"lon\":119.303}"

Ranges and objects in CSV format (in different files)

geobaza.ranges.csv and geobaza.objects.csv files store the same information as geobaza.csv file, but in relational form.

geobaza.ranges.csv file is similar to geobaza.csv, but instead of the detailed description of object it has only numeric identifier. The detailed description of the object is provided in geobaza.objects.csv file.

Example of CSV-file containing IP-addresses ranges.

"ip_start", "ip_end", "ip_int", "length", "tld", "descr"
"0.0.0.0", "0.255.255.255", 0, 16777216, "", "This" Network
"1.0.0.0", "1.0.0.255", 16777216, 256, "AU", 33316
"1.0.1.0", "1.0.3.255", 16777472, 768, "CN", 33444
"1.0.4.0", "1.0.7.255", 16778240, 1024, "AU", 11
"1.0.8.0", "1.0.15.255", 16779264, 2048, "CN", 33445
"1.0.16.0", "1.0.31.255", 16781312, 4096, "JP", 103
"1.0.32.0", "1.0.63.255", 16785408, 8192, "CN", 33445
"1.0.64.0", "1.0.127.255", 16793600, 16384, "JP", 103
"1.0.128.0", "1.0.255.255", 16809984, 32768, "TH", 29390

Example of CSV-file containing geographical objects.

"id", "parent_id", "type", "name_en", "name_ru", "lat", "lon"
33316, 339, "locality", "Brisbane", "Брисбен", -27.466, 153.033
339, 11, "region", "Queensland", "Квинсленд", -27.466, 153.033
11, 0, "country", "Australia", "Австралия", -25, 135
33444, 1908, "locality", "Fuzhou", "Фучжоу", 26.071, 119.303
1908, 98, "region", "Fujian", "Фуцзянь", 26.071, 119.303
98, 0, "country", "China", "Китай", 32.8, 103.08
33445, 1910, "locality", "Guangzhou", "Гуанчжоу", 23.127, 113.247
1910, 98, "region", "Guangdong", "Гуандун", 23.127, 113.247
103, 0, "country", "Japan", "Япония", 35.15, 136.06

Open-source API with usage examples

Currently the following languages and technologies are supported: C/C++, Python, Perl, PHP, .NET.

MySQL Import

Tip

We do not recommend importing data into MySQL (or other relational DB). Binary file, included into the distribution kit, is optimized for information fast search using API.

It is easy to export data from files geobaza.ranges.csv & geobaza.objects.csv, into MySQL database, so that you can use it later in your projects. To do this, you should place files on server where MySQL is running. Also you should make these files and the folder, they are contained in, public readable. For example, you can place the files into /tmp folder.

Then, you should run the attached script csv2mysql.sql:

$ mysql -u  -p

mysql> source /path/to/geobaza/csv2mysql.sql

This script creates two tables and fills them with data from *.csv files.

Let's make request for ip address 8.8.8.8:

mysql> SELECT * FROM geobaza_ranges WHERE ip_int <= inet_aton('8.8.8.8') and ip_int + length >= inet_aton('8.8.8.8');
+---------+-----------+-----------+--------+------+------+
| start   | end       | ip_int    | length | tld  | id   |
+---------+-----------+-----------+--------+------+------+
| 8.8.8.0 | 8.8.8.255 | 134744064 |    256 | US   | 7392 |
+---------+-----------+-----------+--------+------+------+
1 row in set (0.82 sec)

And now — recursive requests for object 7392 and its parents.

mysql> SELECT * FROM geobaza_objects WHERE id = 7392;
+------+-----------+----------+---------------+-----------------------+--------+----------+
| id   | parent_id | type     | name_en       | name_ru               | lat    | lon      |
+------+-----------+----------+---------------+-----------------------+--------+----------+
| 7392 |      2817 | locality | Mountain View | Маунтин Вью           | 37.402 | -122.077 |
+------+-----------+----------+---------------+-----------------------+--------+----------+
1 row in set (0.00 sec)

mysql> SELECT * FROM geobaza_objects WHERE id = 2817;
+------+-----------+--------+------------+----------------------+--------+---------+
| id   | parent_id | type   | name_en    | name_ru              | lat    | lon     |
+------+-----------+--------+------------+----------------------+--------+---------+
| 2817 |       143 | region | California | Калифорния           | 35.367 | -119.33 |
+------+-----------+--------+------------+----------------------+--------+---------+
1 row in set (0.00 sec)

mysql> SELECT * FROM geobaza_objects WHERE id = 143;
+-----+-----------+---------+---------+---------+------+------+
| id  | parent_id | type    | name_en | name_ru | lat  | lon  |
+-----+-----------+---------+---------+---------+------+------+
| 143 |         0 | country | USA     | США     |   40 | -100 |
+-----+-----------+---------+---------+---------+------+------+
1 row in set (0.00 sec)

The last request returns zero value in parent_id field, so, this is the last request.

Accuracy of location determination

The determination precision can be different and vary from city to country.

Notes

In some cases, it is impossible to determine the geographical location of the IP-address. For example, in cases when a user logs in Internet via 4G/3G/GPRS of the Moscow provider being at that time in St. Petersburg.

Geobaza Lite

Geobaza Lite—free version of Geobaza. The only difference from the full version is that you get only country name and region determination by the IP-address.

To check if the Geobaza is implemented correctly, enter, for instance, 85.142.15.254 IP address that belongs to Novgorod region.

Updates

Geobaza is extended, updated, and replenished regularly. We try to issue updates at least once a month. You can download the latest version of Geobaza Lite at http://geobaza.ru/download/.

Automatic Updates

Only for users of the free version Geobaza Lite. To check the current version of Geobaza, you can use the URL http://geobaza.ru/check-update/, which holds the JSON with the latest distributions versions and download links.