Skip to content

Commit ec16381

Browse files
authored
Merge pull request #71 from ipinfo/silvano/eng-609-update-readme-documentation-for-ipinforust
Add documentation for Core and Plus bundles and resproxy
2 parents 92cb5df + 4873f67 commit ec16381

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,97 @@ async fn main() {
146146
}
147147
```
148148

149+
### Core API
150+
151+
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.
152+
153+
```rust
154+
use ipinfo::{IpInfoCore, IpInfoCoreConfig};
155+
156+
#[tokio::main]
157+
async fn main() {
158+
let config = IpInfoCoreConfig {
159+
token: Some("<token>".to_string()),
160+
..Default::default()
161+
};
162+
163+
let mut ipinfo = IpInfoCore::new(config)
164+
.expect("should construct");
165+
166+
let res = ipinfo.lookup("8.8.8.8").await;
167+
match res {
168+
Ok(r) => {
169+
println!("IP: {}", r.ip);
170+
println!("City: {:?}", r.geo.city);
171+
println!("Country: {:?}", r.geo.country);
172+
println!("ASN: {:?}", r.as_info.asn);
173+
println!("AS Name: {:?}", r.as_info.name);
174+
},
175+
Err(e) => println!("error occurred: {}", &e.to_string()),
176+
}
177+
}
178+
```
179+
180+
### Plus API
181+
182+
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.
183+
184+
```rust
185+
use ipinfo::{IpInfoPlus, IpInfoPlusConfig};
186+
187+
#[tokio::main]
188+
async fn main() {
189+
let config = IpInfoPlusConfig {
190+
token: Some("<token>".to_string()),
191+
..Default::default()
192+
};
193+
194+
let mut ipinfo = IpInfoPlus::new(config)
195+
.expect("should construct");
196+
197+
let res = ipinfo.lookup("8.8.8.8").await;
198+
match res {
199+
Ok(r) => {
200+
println!("IP: {}", r.ip);
201+
println!("City: {:?}", r.geo.city);
202+
println!("Mobile: {:?}", r.mobile);
203+
println!("Anonymous: {:?}", r.anonymous);
204+
},
205+
Err(e) => println!("error occurred: {}", &e.to_string()),
206+
}
207+
}
208+
```
209+
210+
### Residential Proxy API
211+
212+
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.
213+
214+
```rust
215+
use ipinfo::{IpInfo, IpInfoConfig};
216+
217+
#[tokio::main]
218+
async fn main() {
219+
let config = IpInfoConfig {
220+
token: Some("<token>".to_string()),
221+
..Default::default()
222+
};
223+
224+
let mut ipinfo = IpInfo::new(config)
225+
.expect("should construct");
226+
227+
let res = ipinfo.lookup_resproxy("175.107.211.204").await;
228+
match res {
229+
Ok(r) => {
230+
println!("IP: {}", r.ip);
231+
println!("Last Seen: {}", r.last_seen);
232+
println!("Percent Days Seen: {}", r.percent_days_seen);
233+
println!("Service: {}", r.service);
234+
},
235+
Err(e) => println!("error occurred: {}", &e.to_string()),
236+
}
237+
}
238+
```
239+
149240
## Other Libraries
150241

151242
There are official IPinfo client libraries available for many languages including

0 commit comments

Comments
 (0)