|
1 | 1 | # GeoIP2 .NET API #
|
2 | 2 |
|
3 |
| -## Beta Note ## |
4 |
| - |
5 |
| -This is a beta release. The API may change before the first production |
6 |
| -release, which will be numbered 2.0.0. |
7 |
| - |
8 |
| -You may find information on the GeoIP2 beta release process on [our |
9 |
| -website](http://www.maxmind.com/en/geoip2_beta). |
10 |
| - |
11 | 3 | ## Description ##
|
12 | 4 |
|
13 | 5 | This distribution provides an API for the GeoIP2 [web services]
|
@@ -54,30 +46,72 @@ See the API documentation for more details.
|
54 | 46 |
|
55 | 47 | ## Web Service Example ##
|
56 | 48 |
|
| 49 | +### Country Service ### |
| 50 | + |
57 | 51 | ```csharp
|
58 | 52 | // This creates a WebServiceClient object that can be reused across requests.
|
59 | 53 | // Replace "42" with your user ID and "license_key" with your license
|
60 | 54 | // key.
|
61 | 55 | var client = new WebServiceClient(42, "license_key");
|
62 | 56 |
|
63 |
| -// Replace "City" with the method corresponding to the web service that |
64 |
| -// you are using, e.g., "Country", "Insights". |
65 |
| -var city = client.City("128.101.101.101"); |
| 57 | +// Do the lookup |
| 58 | +var response = client.Country("128.101.101.101"); |
66 | 59 |
|
67 |
| -Console.WriteLine(city.Country.IsoCode); // 'US' |
68 |
| -Console.WriteLine(city.Country.Name); // 'United States' |
69 |
| -Console.WriteLine(city.Country.Names["zh-CN"]); // '美国' |
| 60 | +Console.WriteLine(response.Country.IsoCode); // 'US' |
| 61 | +Console.WriteLine(response.Country.Name); // 'United States' |
| 62 | +Console.WriteLine(response.Country.Names["zh-CN"]); // '美国' |
| 63 | +``` |
70 | 64 |
|
71 |
| -Console.WriteLine(city.MostSpecificSubdivision.Name); // 'Minnesota' |
72 |
| -Console.WriteLine(city.MostSpecificSubdivision.IsoCode); // 'MN' |
| 65 | +### City Service ### |
73 | 66 |
|
74 |
| -Console.WriteLine(city.City.Name); // 'Minneapolis' |
| 67 | +```csharp |
| 68 | +// This creates a WebServiceClient object that can be reused across requests. |
| 69 | +// Replace "42" with your user ID and "license_key" with your license |
| 70 | +// key. |
| 71 | +var client = new WebServiceClient(42, "license_key"); |
75 | 72 |
|
76 |
| -Console.WriteLine(city.Postal.Code); // '55455' |
| 73 | +// Do the lookup |
| 74 | +var response = client.City("128.101.101.101"); |
77 | 75 |
|
78 |
| -Console.WriteLine(city.Location.Latitude); // 44.9733 |
79 |
| -Console.WriteLine(city.Location.Longitude); // -93.2323 |
| 76 | +Console.WriteLine(response.Country.IsoCode); // 'US' |
| 77 | +Console.WriteLine(response.Country.Name); // 'United States' |
| 78 | +Console.WriteLine(response.Country.Names["zh-CN"]); // '美国' |
| 79 | +
|
| 80 | +Console.WriteLine(response.MostSpecificSubdivision.Name); // 'Minnesota' |
| 81 | +Console.WriteLine(response.MostSpecificSubdivision.IsoCode); // 'MN' |
| 82 | +
|
| 83 | +Console.WriteLine(response.City.Name); // 'Minneapolis' |
| 84 | +
|
| 85 | +Console.WriteLine(response.Postal.Code); // '55455' |
| 86 | +
|
| 87 | +Console.WriteLine(response.Location.Latitude); // 44.9733 |
| 88 | +Console.WriteLine(response.Location.Longitude); // -93.2323 |
| 89 | +``` |
| 90 | + |
| 91 | +### Insights Service ### |
| 92 | + |
| 93 | +```csharp |
| 94 | +// This creates a WebServiceClient object that can be reused across requests. |
| 95 | +// Replace "42" with your user ID and "license_key" with your license |
| 96 | +// key. |
| 97 | +var client = new WebServiceClient(42, "license_key"); |
| 98 | + |
| 99 | +// Do the lookup |
| 100 | +var response = client.Insights("128.101.101.101"); |
| 101 | + |
| 102 | +Console.WriteLine(response.Country.IsoCode); // 'US' |
| 103 | +Console.WriteLine(response.Country.Name); // 'United States' |
| 104 | +Console.WriteLine(response.Country.Names["zh-CN"]); // '美国' |
| 105 | +
|
| 106 | +Console.WriteLine(response.MostSpecificSubdivision.Name); // 'Minnesota' |
| 107 | +Console.WriteLine(response.MostSpecificSubdivision.IsoCode); // 'MN' |
| 108 | +
|
| 109 | +Console.WriteLine(response.City.Name); // 'Minneapolis' |
| 110 | +
|
| 111 | +Console.WriteLine(response.Postal.Code); // '55455' |
80 | 112 |
|
| 113 | +Console.WriteLine(response.Location.Latitude); // 44.9733 |
| 114 | +Console.WriteLine(response.Location.Longitude); // -93.2323 |
81 | 115 | ```
|
82 | 116 |
|
83 | 117 | ## Database Usage ##
|
|
0 commit comments