api-gw-lite avatar
api-gw-lite

Pricing

Pay per usage

Go to Store
api-gw-lite

api-gw-lite

Developed by

Traffic Architect

Traffic Architect

Maintained by Community

This actor serves as a proxy that accepts requests with custom field names and translates them to standard HTTP requests to target APIs. It's designed to work seamlessly on the Apify platform while also supporting local testing

0.0 (0)

Pricing

Pay per usage

1

Total users

1

Monthly users

1

Last modified

15 hours ago

Simple API Gateway Actor

A lightweight, efficient API Gateway that forwards HTTP requests to target APIs with proxy support and structured results.

Overview

This Apify Actor serves as a simple HTTP client that accepts requests with intuitive field names and forwards them to target APIs. It's designed for simplicity and efficiency, focusing on core functionality without unnecessary complexity.

Key Features

  • All HTTP methods (GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD)
  • Custom headers and authentication support
  • URL query parameters handling
  • JSON request bodies for POST/PUT/PATCH
  • Apify proxy integration for IP rotation
  • Structured results in Apify Results tab
  • Error handling with graceful HTTP error responses
  • Lightweight - single file implementation

Input Configuration

Required Fields

  • destination (string): The target URL endpoint

Optional Fields

  • actionType (string): HTTP method (default: "GET")
  • requestSignals (object): HTTP headers
  • queryDetails (object): URL query parameters
  • payloadContent (object): JSON request body
  • proxySettings (object): Proxy configuration

Usage Examples

1. Simple GET Request

{
"actionType": "GET",
"destination": "https://jsonplaceholder.typicode.com/posts/1",
"requestSignals": {
"User-Agent": "ApifyActor/1.0",
"Accept": "application/json"
},
"queryDetails": {
"format": "json",
"limit": "10"
}
}

2. POST with JSON Body

{
"actionType": "POST",
"destination": "https://jsonplaceholder.typicode.com/posts",
"requestSignals": {
"Content-Type": "application/json",
"Authorization": "Bearer your-token-here"
},
"payloadContent": {
"title": "Sample Post",
"body": "This is a test post",
"userId": 1
}
}

3. API with Authentication

{
"actionType": "GET",
"destination": "https://api.github.com/user/repos",
"requestSignals": {
"Authorization": "token ghp_your_github_token_here",
"Accept": "application/vnd.github.v3+json"
},
"queryDetails": {
"type": "owner",
"sort": "updated",
"per_page": "5"
}
}

4. With Proxy Settings

{
"actionType": "GET",
"destination": "https://httpbin.org/ip",
"requestSignals": {
"Accept": "application/json"
},
"proxySettings": {
"useApifyProxy": true,
"apifyProxyGroups": ["RESIDENTIAL"]
}
}

Field Mapping

Input FieldMaps ToPurpose
actionTypeHTTP MethodGET, POST, PUT, DELETE, etc.
destinationTarget URLComplete endpoint URL
requestSignalsHTTP HeadersAuthorization, Content-Type, etc.
queryDetailsQuery ParametersURL parameters (?key=value)
payloadContentRequest BodyJSON data for POST/PUT requests
proxySettingsProxy ConfigApify proxy settings

Output Format

The actor provides two types of output:

Results Tab (Dataset)

{
"success": true,
"status_code": 200,
"content_type": "application/json",
"full_response": { "...actual API response..." }
}

Key-Value Store (OUTPUT)

Complete raw response including all headers and metadata.

File Structure

├── apify_main.py # Main Actor implementation
├── Dockerfile # Docker configuration
├── requirements.txt # Python dependencies
├── INPUT.json # Example configurations
├── README.md # This documentation
└── .actor/
├── actor.json # Actor metadata
└── input_schema.json # Input validation schema

Requirements

  • httpx - HTTP client library
  • apify - Apify SDK for Python

Error Handling

The actor gracefully handles:

  • ❌ Invalid URLs or network issues
  • ❌ Authentication failures
  • ❌ HTTP error status codes (4xx, 5xx)
  • ❌ Malformed JSON responses
  • ❌ Proxy connection issues

All errors are logged with detailed messages and returned in structured format.

Running the Actor

On Apify Platform

  1. Upload this actor to Apify
  2. Configure input using the examples in INPUT.json
  3. Run the actor
  4. View results in the "Results" tab

Local Testing

$python apify_main.py

Common Use Cases

  • API Testing - Test REST API endpoints
  • Data Collection - Fetch data from APIs
  • Webhook Forwarding - Forward requests to internal APIs
  • Authentication Testing - Test different auth methods
  • Proxy Testing - Test APIs through different IP addresses

Tips

  • Use httpbin.org endpoints for testing
  • Check the "Results" tab for formatted output
  • Enable Apify proxy for IP rotation
  • Add proper User-Agent headers for better success rates
  • Use Content-Type: application/json for JSON payloads

Simple, efficient, and reliable API Gateway for all your HTTP request needs! 🚀