|
5 | 5 |
|
6 | 6 | This is the official C# .NET SDK for the [IPinfo.io](https://ipinfo.io) IP address API, allowing you to look up your own IP address, or get any of the following details for other IP addresses: |
7 | 7 |
|
8 | | - - [IP geolocation](https://ipinfo.io/ip-geolocation-api) (city, region, country, postal code, latitude, and longitude) |
9 | | - - [ASN details](https://ipinfo.io/asn-api) (ISP or network operator, associated domain name, and type, such as business, hosting, or company) |
10 | | - - [Firmographics data](https://ipinfo.io/ip-company-api) (the name and domain of the business that uses the IP address) |
11 | | - - [Carrier information](https://ipinfo.io/ip-carrier-api) (the name of the mobile carrier and MNC and MCC for that carrier if the IP is used exclusively for mobile traffic) |
| 8 | +- [IP geolocation](https://ipinfo.io/ip-geolocation-api) (city, region, country, postal code, latitude, and longitude) |
| 9 | +- [ASN details](https://ipinfo.io/asn-api) (ISP or network operator, associated domain name, and type, such as business, hosting, or company) |
| 10 | +- [Firmographics data](https://ipinfo.io/ip-company-api) (the name and domain of the business that uses the IP address) |
| 11 | +- [Carrier information](https://ipinfo.io/ip-carrier-api) (the name of the mobile carrier and MNC and MCC for that carrier if the IP is used exclusively for mobile traffic) |
12 | 12 |
|
13 | 13 | ## Getting Started |
14 | 14 |
|
@@ -85,8 +85,8 @@ IPResponse ipResponse = client.IPApi.GetDetails(ip); |
85 | 85 |
|
86 | 86 | `ipResponse.CountryName` will return the country name, whereas `ipResponse.Country` can be used to fetch the country code. |
87 | 87 |
|
88 | | -Additionally `ipResponse.IsEU` will return `true` if the country is a member of the European Union (EU), `response.CountryFlag` |
89 | | -will return the emoji and Unicode of the country's flag, `response.CountryCurrency` will return the code and symbol of the country's currency |
| 88 | +Additionally `ipResponse.IsEU` will return `true` if the country is a member of the European Union (EU), `response.CountryFlag` |
| 89 | +will return the emoji and Unicode of the country's flag, `response.CountryCurrency` will return the code and symbol of the country's currency |
90 | 90 | ,and `response.Continent` will return the code and name of the continent. `response.CountryFlagURL` will return a public link to the country's flag image as an SVG which can be used anywhere. |
91 | 91 |
|
92 | 92 | ```csharp |
@@ -153,6 +153,85 @@ Console.WriteLine($"IPResponse.Country: {ipResponse.Country}"); |
153 | 153 | Console.WriteLine($"IPResponse.CountryName: {ipResponse.CountryName}"); |
154 | 154 | ``` |
155 | 155 |
|
| 156 | +### Core API |
| 157 | + |
| 158 | +The library also supports the [Core API](https://ipinfo.io/developers/data-types#core-data), which provides city-level geolocation with nested geo and AS objects. Authentication with your token is required. |
| 159 | + |
| 160 | +```csharp |
| 161 | +// namespace |
| 162 | +using IPinfo; |
| 163 | +using IPinfo.Models; |
| 164 | + |
| 165 | +// initializing IPinfo client for Core API |
| 166 | +string token = "MY_TOKEN"; |
| 167 | +IPinfoClientCore client = new IPinfoClientCore.Builder() |
| 168 | + .AccessToken(token) |
| 169 | + .Build(); |
| 170 | + |
| 171 | +// making API call |
| 172 | +string ip = "8.8.8.8"; |
| 173 | +IPResponseCore ipResponse = await client.IPApi.GetDetailsAsync(ip); |
| 174 | + |
| 175 | +// accessing details from response |
| 176 | +Console.WriteLine($"IPResponse.IP: {ipResponse.IP}"); |
| 177 | +Console.WriteLine($"IPResponse.Geo.City: {ipResponse.Geo.City}"); |
| 178 | +Console.WriteLine($"IPResponse.Geo.Country: {ipResponse.Geo.Country}"); |
| 179 | +Console.WriteLine($"IPResponse.AS.Asn: {ipResponse.AS.Asn}"); |
| 180 | +Console.WriteLine($"IPResponse.AS.Name: {ipResponse.AS.Name}"); |
| 181 | +``` |
| 182 | + |
| 183 | +### Plus API |
| 184 | + |
| 185 | +The library also supports the [Plus API](https://ipinfo.io/developers/data-types#plus-data), which provides enhanced data including mobile carrier info and privacy detection. Authentication with your token is required. |
| 186 | + |
| 187 | +```csharp |
| 188 | +// namespace |
| 189 | +using IPinfo; |
| 190 | +using IPinfo.Models; |
| 191 | + |
| 192 | +// initializing IPinfo client for Plus API |
| 193 | +string token = "MY_TOKEN"; |
| 194 | +IPinfoClientPlus client = new IPinfoClientPlus.Builder() |
| 195 | + .AccessToken(token) |
| 196 | + .Build(); |
| 197 | + |
| 198 | +// making API call |
| 199 | +string ip = "8.8.8.8"; |
| 200 | +IPResponsePlus ipResponse = await client.IPApi.GetDetailsAsync(ip); |
| 201 | + |
| 202 | +// accessing details from response |
| 203 | +Console.WriteLine($"IPResponse.IP: {ipResponse.IP}"); |
| 204 | +Console.WriteLine($"IPResponse.Geo.City: {ipResponse.Geo.City}"); |
| 205 | +Console.WriteLine($"IPResponse.Mobile: {ipResponse.Mobile}"); |
| 206 | +Console.WriteLine($"IPResponse.Anonymous.IsProxy: {ipResponse.Anonymous.IsProxy}"); |
| 207 | +``` |
| 208 | + |
| 209 | +### Residential Proxy API |
| 210 | + |
| 211 | +The library also supports the [Residential Proxy API](https://ipinfo.io/developers/residential-proxy-api), which allows you to check if an IP address is a residential proxy. Authentication with your token is required. |
| 212 | + |
| 213 | +```csharp |
| 214 | +// namespace |
| 215 | +using IPinfo; |
| 216 | +using IPinfo.Models; |
| 217 | + |
| 218 | +// initializing IPinfo client |
| 219 | +string token = "MY_TOKEN"; |
| 220 | +IPinfoClient client = new IPinfoClient.Builder() |
| 221 | + .AccessToken(token) |
| 222 | + .Build(); |
| 223 | + |
| 224 | +// making API call |
| 225 | +string ip = "175.107.211.204"; |
| 226 | +ResproxyResponse resproxy = await client.IPApi.GetResproxyAsync(ip); |
| 227 | + |
| 228 | +// accessing details from response |
| 229 | +Console.WriteLine($"Resproxy.IP: {resproxy.IP}"); |
| 230 | +Console.WriteLine($"Resproxy.LastSeen: {resproxy.LastSeen}"); |
| 231 | +Console.WriteLine($"Resproxy.PercentDaysSeen: {resproxy.PercentDaysSeen}"); |
| 232 | +Console.WriteLine($"Resproxy.Service: {resproxy.Service}"); |
| 233 | +``` |
| 234 | + |
156 | 235 | ### Caching |
157 | 236 |
|
158 | 237 | In-memory caching of data is provided by default. Custom implementation of the cache can also be provided by implementing the `ICache` interface. |
@@ -191,7 +270,7 @@ string ip = "127.0.0.1"; |
191 | 270 | IPResponse ipResponse = await client.IPApi.GetDetailsAsync(ip); |
192 | 271 | if (ipResponse.Bogon) |
193 | 272 | { |
194 | | - Console.WriteLine($"{ipResponse.IP} is a bogon."); |
| 273 | + Console.WriteLine($"{ipResponse.IP} is a bogon."); |
195 | 274 | } |
196 | 275 | else |
197 | 276 | { |
|
0 commit comments