Language Setup Guide

Python setup

Requirements

To use the UpRock API with Python, you need Python 3.8 or higher and pip (Python’s package installer).

Create a Virtual Environment

Creating a virtual environment isolates your project dependencies from other Python projects.

# Create virtual environment
python3 -m venv venv

# Activate virtual environment
source venv/bin/activate
# Create virtual environment
python3 -m venv venv

# Activate virtual environment
venv\Scripts\activate

Install Required Dependencies

pip install requests python-dotenv

Dependencies installed:

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

Configure Environment Variables

Ensure you have set up your environment variables as described in the get your API keys 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 test_setup.py file and run the code below to verify your setup:

from dotenv import load_dotenv
import os
import requests

# Load environment variables from .env file
load_dotenv()

# Get configuration
api_key = os.getenv('UPROCK_API_KEY')
base_url = os.getenv('UPROCK_BASE_URL', 'https://edge.uprock.com')

# Validate API key is set
if not api_key:
    print("Error: UPROCK_API_KEY not set")
    exit(1)

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

# Display result
if response.status_code == 200:
    print("✓ Setup verified - Ready to use UpRock Crawl API")
else:
    print(f"✗ Setup failed with status code: {response.status_code}")

Run the verification script:

python test_setup.py

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.

Import Errors

If you encounter import errors, ensure your virtual environment is activated:

source venv/bin/activate
venv\Scripts\activate

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