Skip to content

Commit 85efb33

Browse files
authored
Merge pull request #19 from ipinfo/silvano/eng-608-update-readme-documentation-for-ipinfoswift
Add documentation for Core and Plus bundles and resproxy
2 parents 2f77c42 + a380d22 commit 85efb33

File tree

1 file changed

+52
-3
lines changed

1 file changed

+52
-3
lines changed

README.md

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The free plan is limited to 50,000 requests per month, and doesn't include some
1616

1717
### Swift Package Manager
1818

19-
The [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler.
19+
The [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler.
2020

2121
Once you have your Swift package set up, adding ipinfo as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`.
2222

@@ -89,6 +89,7 @@ IPINFO.shared.getBatch(ipAddresses: ipAddresses, withFilter: false) { status, re
8989
# Country Name Lookup
9090

9191
This library provides a system to lookup country names through ISO2 country codes.
92+
9293
```swift
9394
IPINFO.shared.getDetails(ip: "8.8.8.8") { status, response, msg in
9495
guard let response else {return}
@@ -99,7 +100,7 @@ IPINFO.shared.getDetails(ip: "8.8.8.8") { status, response, msg in
99100
print(response.country)
100101
// Print out the country name
101102
print(response.countryName)
102-
103+
103104
case .failure:
104105
print(msg)
105106
}
@@ -109,6 +110,7 @@ IPINFO.shared.getDetails(ip: "8.8.8.8") { status, response, msg in
109110
# EU Country Lookup
110111

111112
This library provides a system to lookup if a country is a member of the European Union (EU) through ISO2 country codes.
113+
112114
```swift
113115
IPINFO.shared.getDetails(ip: "8.8.8.8") { status, response, msg in
114116
guard let response else {return}
@@ -197,11 +199,58 @@ case .ip(let ip):
197199
}
198200
```
199201

202+
# Core API
203+
204+
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.
205+
206+
```swift
207+
let client = IPInfoCore(token: "YOUR TOKEN")
208+
let response = try await client.lookup(ip: "8.8.8.8")
209+
210+
print(response.ip) // 8.8.8.8
211+
print(response.geo.city) // Mountain View
212+
print(response.geo.country) // United States
213+
print(response.as.asn) // AS15169
214+
print(response.as.name) // Google LLC
215+
```
216+
217+
# Plus API
218+
219+
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.
220+
221+
```swift
222+
let client = IPInfoPlus(token: "YOUR TOKEN")
223+
let response = try await client.lookup(ip: "8.8.8.8")
224+
225+
print(response.ip) // 8.8.8.8
226+
print(response.geo.city) // Mountain View
227+
print(response.mobile) // mobile carrier info
228+
print(response.anonymous.isProxy) // false
229+
```
230+
231+
# Residential Proxy API
232+
233+
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.
234+
235+
```swift
236+
IPINFO.shared.getResproxyDetails(ip: "175.107.211.204") { status, data, msg in
237+
switch status {
238+
case .success:
239+
print(data?.ip) // 175.107.211.204
240+
print(data?.lastSeen) // 2025-01-20
241+
print(data?.percentDaysSeen) // 0.85
242+
print(data?.service) // Bright Data
243+
case .failure:
244+
print(msg)
245+
}
246+
}
247+
```
248+
200249
# Contributing
201250

202251
## Running the tests
203252

204-
Some tests require a [token](https://ipinfo.io/dashboard/token) to pass. You can add yours as an [environment variable of the scheme](https://developer.apple.com/documentation/xcode/customizing-the-build-schemes-for-a-project/#Specify-launch-arguments-and-environment-variables).
253+
Some tests require a [token](https://ipinfo.io/dashboard/token) to pass. You can add yours as an [environment variable of the scheme](https://developer.apple.com/documentation/xcode/customizing-the-build-schemes-for-a-project/#Specify-launch-arguments-and-environment-variables).
205254

206255
# Other Libraries
207256

0 commit comments

Comments
 (0)