Skip to content

Commit 2cbdd84

Browse files
authored
Merge pull request #18 from ipinfo/silvano/eng-616-update-readme-documentation-for-ipinforails
Add documentation for Core and Plus bundles and resproxy
2 parents 20e6ae1 + a6b6784 commit 2cbdd84

File tree

1 file changed

+58
-19
lines changed

1 file changed

+58
-19
lines changed

README.md

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,30 @@ The library also supports the Lite API, see the [Lite API section](#lite-api) fo
2121

2222
1. Option 1) Add this line to your application's Gemfile:
2323

24-
```ruby
25-
gem 'ipinfo-rails'
26-
```
24+
```ruby
25+
gem 'ipinfo-rails'
26+
```
2727

28-
Then execute:
28+
Then execute:
2929

30-
```bash
31-
$ bundle install
32-
```
30+
```bash
31+
$ bundle install
32+
```
3333

34-
Option 2) Install it yourself by running the following command:
34+
Option 2) Install it yourself by running the following command:
3535

36-
```bash
37-
$ gem install ipinfo-rails
38-
```
36+
```bash
37+
$ gem install ipinfo-rails
38+
```
3939

4040
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.
4141

42-
```ruby
43-
require 'ipinfo-rails'
44-
config.middleware.use(IPinfoMiddleware, {token: "<your_token>"})
45-
```
42+
```ruby
43+
require 'ipinfo-rails'
44+
config.middleware.use(IPinfoMiddleware, {token: "<your_token>"})
45+
```
4646

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.
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.
4848

4949
1. Restart your development server.
5050

@@ -120,7 +120,7 @@ request.env['ipinfo'].all ==
120120

121121
## Configuration
122122

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.
124124

125125
```ruby
126126
require 'ipinfo-rails/ip_selector/xforwarded_ip_selector'
@@ -231,10 +231,10 @@ config.middleware.use(IPinfoMiddleware, {:countries => <path_to_settings_file>})
231231

232232
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.
233233

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:
235235

236236
- Accepts one request.
237-
- Returns *True to filter out, False to allow lookup*
237+
- Returns _True to filter out, False to allow lookup_
238238

239239
To use your own filter rules:
240240

@@ -259,6 +259,45 @@ require 'ipinfo-rails'
259259
config.middleware.use(IPinfoLiteMiddleware, {token: "<your_token>"})
260260
```
261261

262+
## Core API
263+
264+
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.
265+
266+
```ruby
267+
require 'ipinfo-rails'
268+
config.middleware.use(IPinfoCoreMiddleware, {token: "<your_token>"})
269+
```
270+
271+
## Plus API
272+
273+
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.
274+
275+
```ruby
276+
require 'ipinfo-rails'
277+
config.middleware.use(IPinfoPlusMiddleware, {token: "<your_token>"})
278+
```
279+
280+
## Residential Proxy API
281+
282+
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.
283+
284+
```ruby
285+
require 'ipinfo-rails'
286+
config.middleware.use(IPinfoResproxyMiddleware, {token: "<your_token>"})
287+
```
288+
289+
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+
262301
## Other Libraries
263302

264303
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

Comments
 (0)