Language Setup Guide

Ruby setup

Requirements

To use the UpRock API with Ruby, you need Ruby 2.7 or higher and Bundler (Ruby’s dependency manager).

Create a Gemfile

In your project directory, create a file named Gemfile with the following content:

Gemfile
source 'https://rubygems.org'

gem 'httparty'
gem 'dotenv'

Gems:

  • httparty - HTTP client library for making API requests
  • dotenv - Loads environment variables from .env files

Install Dependencies

Run Bundler to install the required gems:

bundle install

This will install all gems specified in your Gemfile and create a Gemfile.lock file.

Configure Environment Variables

Ensure you have set up your environment variables as described in the Prerequisites guide. Your .env file should contain:

UPROCK_API_KEY=your-api-key-here
# UPROCK_BASE_URL is optional - defaults to https://edge.uprock.com

Never commit your .env file to version control. Add it to .gitignore.

Verify Your Setup

Create a file named test_setup.rb and run it to verify your setup:

test_setup.rb
require 'dotenv/load'
require 'httparty'

# Get configuration
api_key = ENV['UPROCK_API_KEY']
base_url = ENV['UPROCK_BASE_URL'] || 'https://edge.uprock.com'

# Validate API key is set
abort("Error: UPROCK_API_KEY not set") unless api_key

# Test API connection
response = HTTParty.get(
  "#{base_url}/crawl/v1/health",
  headers: { 'Authorization' => "Bearer #{api_key}" }
)

# Display result
if response.code == 200
  puts "✓ Setup verified - Ready to use UpRock Crawl API"
else
  puts "✗ Setup failed with status code: #{response.code}"
  exit 1
end

Run the verification script:

ruby test_setup.rb

Expected Output

✓ Setup verified - Ready to use UpRock Crawl API

Common failure codes:

  • 401 - Invalid or missing API key
  • 403 - Inactive plan or insufficient permissions
  • 404 - Incorrect base URL

Troubleshooting

Below are solutions to common setup issues. If these don't resolve your problem, reach out to support@uprock.com.

API Key Not Found

Verify your .env file is in the same directory as your script and the variable name is exactly UPROCK_API_KEY.

Connection Errors

If behind a corporate proxy, configure the HTTPS_PROXY environment variable as described in the get your API keys guide.

On this page