Integration

Use Shifter with Ruby

Wire Shifter's residential and ISP proxies into Ruby in minutes. Compatible with Net::HTTP, HTTParty, Faraday, Mechanize, and Watir — works in plain scripts, Sinatra, and Rails.

Quick Start

Install

gem install httparty

Basic Usage

require 'httparty'

response = HTTParty.get(
  'https://ipinfo.io/json',
  http_proxyaddr: 'p.shifter.io',
  http_proxyport: 443,
  http_proxyuser: 'customer-USERNAME-country-us-sid-123ABC',
  http_proxypass: 'PASSWORD',
  timeout: 30
)

puts response.parsed_response
# {"ip" => "154.16.xxx.xxx", "city" => "New York", "country" => "US", ...}

Features

Drop-in support for Net::HTTP, HTTParty, Faraday, Mechanize, RestClient, and any HTTP client that takes a proxy URL
Per-request rotation by default, with `sid` for sticky sessions and `ttl-N` for timed pins of N seconds
Compatible with Ruby 2.7 and every Ruby 3.x release including 3.3
HTTP, HTTPS, and SOCKS5 protocols on the same gateway endpoint
Geo-targeting in 195+ countries via username parameters — no extra gem required
Drop-in for Sinatra, Rails, Hanami, and any custom Ruby framework — no SDK lock-in

Examples

Net::HTTP (zero dependencies)

The Ruby standard library is enough. Net::HTTP.start accepts proxy host, port, user, and password — no gems required. Best for tiny scripts and Lambda-style functions.

require 'net/http'
require 'uri'
require 'json'

PROXY_HOST = 'p.shifter.io'
PROXY_PORT = 443
PROXY_USER = 'customer-USERNAME-country-uk-sid-456DEF'
PROXY_PASS = 'PASSWORD'

uri = URI('https://example.co.uk/products')

http = Net::HTTP.new(
  uri.host,
  uri.port,
  PROXY_HOST,
  PROXY_PORT,
  PROXY_USER,
  PROXY_PASS
)
http.use_ssl = true
http.read_timeout = 30

req = Net::HTTP::Get.new(uri.request_uri)
req['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36'

response = http.request(req)
puts "Status: #{response.code}, length: #{response.body.length}"

Faraday with Sticky Session

Faraday is Ruby's most flexible HTTP client — middleware-based, swap adapters at will. Add a `sid` to the proxy username to pin one residential IP for the whole conversation.

require 'faraday'
require 'securerandom'

sid = SecureRandom.hex(4)

conn = Faraday.new(
  url: 'https://example.de',
  proxy: "customer-USERNAME-country-de-city-berlin-sid-#{sid}-ttl-300:PASSWORD@p.shifter.io:443",
  request: { timeout: 30 },
  headers: { 'User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36' }
)

login     = conn.post('/login', { email: 'user@example.com', password: 'secret' }.to_json,
                      'Content-Type' => 'application/json')
dashboard = conn.get('/dashboard')
orders    = conn.get('/orders')

puts [login.status, dashboard.status, orders.status].inspect

Mechanize (form-aware crawling)

Mechanize automates form submission and link following. Configure the proxy on the agent and every page it walks goes through Shifter.

require 'mechanize'

agent = Mechanize.new
agent.set_proxy('p.shifter.io', 443,
                'customer-USERNAME-country-us-city-newyork-sid-789GHI',
                'PASSWORD')
agent.user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
agent.read_timeout = 30

page = agent.get('https://example.com/login')

form = page.form('login')
form.email = 'user@example.com'
form.password = 'secret'
dashboard = form.submit

dashboard.links_with(href: %r{/orders/\d+}).each do |link|
  order = link.click
  puts order.search('h1').text.strip
end

Rails (production HTTP service)

Wrap Shifter behind a tiny Rails service so every controller / job uses the same proxy configuration. Rotate per-request or pin per user.

# app/services/shifter_client.rb
require 'faraday'
require 'faraday/retry'

class ShifterClient
  PROXY_HOST = 'p.shifter.io:443'

  def initialize(country: 'us', sid: nil)
    sid_part  = sid ? "-sid-#{sid}" : ''
    proxy_url = "customer-USERNAME-country-#{country}#{sid_part}:PASSWORD@#{PROXY_HOST}"

    @conn = Faraday.new(proxy: proxy_url, request: { timeout: 30 }) do |f|
      f.request :retry, max: 3, interval: 1.0, backoff_factor: 2
      f.response :json
      f.adapter Faraday.default_adapter
    end
  end

  def get(url)
    @conn.get(url)
  end
end

# In a controller or job:
class ProductsController < ApplicationController
  def index
    client = ShifterClient.new(country: 'uk', sid: current_user.id)
    @products = client.get('https://example.co.uk/products.json').body
  end
end
FAQ

Frequently asked FAQ questions

Common questions about using Shifter with Ruby.

Pass proxy host, port, user, and password as the 3rd–6th arguments to Net::HTTP.new. Set use_ssl = true for HTTPS targets. The Ruby standard library is enough — no extra gems required.

Get started

Start Using Shifter with Ruby

Add Shifter's 205M+ residential and ISP proxies to your Ruby and Rails stack in under 5 minutes. Works with Net::HTTP, HTTParty, Faraday, and Mechanize.

Try Shifter for FreeSet up in minutes. Cancel anytime.