Skip to content

ariadata/api-proxy

Repository files navigation

API Proxy Service

A lightweight API proxy service written in Go that supports multiple endpoints, rate limiting, and proxy rotation.

Features

  • Multiple site/endpoint support
  • API key rotation
  • Rate limiting
  • SOCKS5 and HTTP proxy support
  • Detailed logging system
  • Docker support
  • CORS enabled

Quick Start

Using Docker Compose

  1. Clone the repository
  2. Configure your settings:
    • Copy .env.example to .env
    • Copy config.json.example to config.json
  3. Run the service:
    docker-compose up -d

Manual Setup

  1. Install Go 1.22 or later
  2. Configure your settings in config.json
  3. Run the service:
    go run main.go

Configuration

Environment Variables

  • PORT: Server port (default: 3003)
  • LOG_LEVEL: Logging level (debug, info, warn, error)
  • COMPOSE_PROJECT_NAME: Docker compose project name
  • UID: User ID for Docker
  • GID: Group ID for Docker
  • DC_HTTP_PORT: Docker container HTTP port

Config.json Structure

{
  "GLOBAL_SETTINGS": {
    "DIRECT_ACCESS": false,
    "PROXIES": [
      "socks5://user:pass@host:port",
      "http://user:pass@host:port"
    ]
  },
  "SITES": {
    "site-name": {
      "domain": "https://api.example.com",
      "PROXY_TYPE": "header",
      "KEY": "X-Api-Key",
      "VALUES": [
        {"key1": 3},
        {"key2": 3}
      ]
    }
  }
}

Usage

Making Requests

The proxy service accepts requests in the following format:

http://localhost:3003/proxy/{site-name}/{endpoint}

Example:

curl http://localhost:3003/proxy/myip4/

Logs

Logs are written to both console and proxy.log file. You can view Docker container logs using:

docker-compose logs api-proxy

Development

Prerequisites

  • Go 1.22+
  • Docker and Docker Compose (for containerized deployment)

Building

# Build locally
go build -o api-proxy

# Build Docker image
docker-compose build

License

MIT License

Releases

No releases published

Packages

No packages published