You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+58-19Lines changed: 58 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,30 +21,30 @@ The library also supports the Lite API, see the [Lite API section](#lite-api) fo
21
21
22
22
1. Option 1) Add this line to your application's Gemfile:
23
23
24
-
```ruby
25
-
gem 'ipinfo-rails'
26
-
```
24
+
```ruby
25
+
gem 'ipinfo-rails'
26
+
```
27
27
28
-
Thenexecute:
28
+
Then execute:
29
29
30
-
```bash
31
-
$ bundle install
32
-
```
30
+
```bash
31
+
$ bundle install
32
+
```
33
33
34
-
Option2) Install it yourself by running the following command:
34
+
Option 2) Install it yourself by running the following command:
35
35
36
-
```bash
37
-
$ gem install ipinfo-rails
38
-
```
36
+
```bash
37
+
$ gem install ipinfo-rails
38
+
```
39
39
40
40
1. Open your `config/environment.rb` file or your preferred file in the `config/environment` directory. Add the following code to your chosen configuration file.
Note:if editing `config/environment.rb`, this needs to come before `Rails.application.initialize!`and with `Rails.application.` prepended to `config`, otherwise you'll get runtime errors.
47
+
Note: if editing `config/environment.rb`, this needs to come before `Rails.application.initialize!` and with `Rails.application.` prepended to `config`, otherwise you'll get runtime errors.
48
48
49
49
1. Restart your development server.
50
50
@@ -120,7 +120,7 @@ request.env['ipinfo'].all ==
120
120
121
121
## Configuration
122
122
123
-
In addition to the steps listed in the Installation section, it is possible to configure the library with more detail. The following arguments are allowed and are described in detail below.
123
+
In addition to the steps listed in the Installation section, it is possible to configure the library with more detail. The following arguments are allowed and are described in detail below.
By default, `ipinfo-rails` filters out requests that have `bot` or `spider` in the user-agent. Instead of looking up IP address data for these requests, the `request.env['ipinfo']` attribute is set to `nil`. This is to prevent you from unnecessarily using up requests on non-user traffic.
233
233
234
-
To set your own filtering rules, *thereby replacing the default filter*, you can set `:filter` to your own, custom callable function which satisfies the following rules:
234
+
To set your own filtering rules, _thereby replacing the default filter_, you can set `:filter` to your own, custom callable function which satisfies the following rules:
235
235
236
236
- Accepts one request.
237
-
- Returns *True to filter out, False to allow lookup*
237
+
- Returns _True to filter out, False to allow lookup_
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.
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.
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.
The residential proxy details will be available through `request.env['ipinfo_resproxy']`:
290
+
291
+
```ruby
292
+
resproxy = request.env['ipinfo_resproxy']
293
+
if resproxy
294
+
resproxy.ip # 175.107.211.204
295
+
resproxy.last_seen # 2025-01-20
296
+
resproxy.percent_days_seen # 0.85
297
+
resproxy.service # Bright Data
298
+
end
299
+
```
300
+
262
301
## Other Libraries
263
302
264
303
There are official IPinfo client libraries available for many languages including PHP, Go, Java, Ruby, and many popular frameworks such as Django, Rails, and Laravel. There are also many third-party libraries and integrations available for our API.
0 commit comments