External Data Provider
Type:
external_data_provider• Category:flow• Tags:external,api,endpoint,webhook,trading,integration
Description
Provide data to external systems via HTTP endpoint (GET access).
This worker creates a stable HTTP endpoint that external systems (like trading platforms, mobile apps, or other services) can call to retrieve data. The endpoint URL is consistent across workflow runs, making it reliable for external integrations.
Key Features: • Stable endpoint URLs based on workflow ID • Support for both JSON and plain text responses • Custom or auto-generated provider IDs • Real-time data serving with timestamps • Perfect for MQL4/MQL5 indicators, TradingView strategies, and external APIs
Use Cases: • Trading indicators that need dynamic data from your workflows • Mobile apps fetching real-time market data • External services consuming processed analytics • Cross-platform data sharing between different systems
Parameters
| Name | Type | Description | Required | Default |
|---|---|---|---|---|
response_data | string | The response data to provide to external systems | yes | |
response_type | string | Response format: JSON (parse as JSON) or text (return as plain text) | no | "JSON" |
provider_id | string | Custom provider ID (minimum 16 digits). If not provided, a consistent ID will be generated based on workflow_id | no |
Help
External Data Provider
This worker creates HTTP endpoints that external systems can call to retrieve data from your ApudFlow workflows.
How It Works
- Setup: Configure the worker with your data and response format
- Endpoint Creation: Worker generates a stable URL like
https://api-t.apudflow.io/api/w/{workflow_id}/{provider_id} - Data Serving: External systems can GET the data anytime
- Updates: Run the worker again to update the data at the same endpoint
Parameters
- response_data: The actual data to serve (string)
- response_type: "JSON" (default) or "text"
- provider_id: Custom ID (optional, auto-generated if not provided)
Examples
Basic Text Response
response_data: "Hello from ApudFlow!"
response_type: "text"
External systems get: Hello from ApudFlow!
JSON Response with Trading Data
response_data: "{\"symbol\": \"EURUSD\", \"price\": 1.0850, \"signal\": \"BUY\"}"
response_type: "JSON"
External systems get: {"symbol": "EURUSD", "price": 1.0850, "signal": "BUY"}
Integration Examples
MQL5 (MetaTrader 5) Integration
// Include this in your MQL5 indicator/expert advisor
#include <WinINet.mqh>
// Function to fetch data from ApudFlow endpoint
string FetchApudFlowData(string endpoint_url) {
// Create HTTP session
HINTERNET hSession = InternetOpenW("MQL5_ApudFlow", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (hSession == NULL) return "";
// Open HTTP connection
HINTERNET hConnect = InternetOpenUrlW(hSession, endpoint_url, NULL, 0,
INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE, 0);
if (hConnect == NULL) {
InternetCloseHandle(hSession);
return "";
}
// Read response
char buffer[1024];
DWORD bytesRead;
string result = "";
while (InternetReadFile(hConnect, buffer, sizeof(buffer), bytesRead) && bytesRead > 0) {
result += CharArrayToString(buffer, 0, bytesRead);
}
InternetCloseHandle(hConnect);
InternetCloseHandle(hSession);
return result;
}
// Usage in your indicator
int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[],
const double &open[], const double &high[], const double &low[], const double &close[],
const long &tick_volume[], const long &volume[], const int &spread[]) {
string endpoint = "https://api-t.apudflow.io/api/w/your_workflow_id/your_provider_id";
string data = FetchApudFlowData(endpoint);
// Parse JSON response (you'll need a JSON parser library)
// Example: double price = ParsePriceFromJSON(data);
return rates_total;
}
MQL4 (MetaTrader 4) Integration
// Include this in your MQL4 indicator/expert advisor
// Function to fetch data from ApudFlow endpoint
string FetchApudFlowData(string endpoint_url) {
int h = InternetOpenUrlW(0, endpoint_url, "", 0, INTERNET_FLAG_RELOAD, 0);
if (h == 0) return "";
string result = "";
char buffer[1024];
int bytesRead = 0;
while (InternetReadFile(h, buffer, sizeof(buffer), bytesRead) && bytesRead > 0) {
result = result + CharArrayToString(buffer, 0, bytesRead);
}
InternetCloseHandle(h);
return result;
}
// Usage in your indicator
int start() {
string endpoint = "https://api-t.apudflow.io/api/w/your_workflow_id/your_provider_id";
string data = FetchApudFlowData(endpoint);
// Use the data in your trading logic
if (StringFind(data, "BUY") != -1) {
// Execute buy order
}
return 0;
}
TradingView Pine Script Integration
//@version=5
indicator("ApudFlow Data Fetcher", overlay=true)
// Function to fetch data from external API
fetchData() =>
// TradingView doesn't have direct HTTP requests in Pine Script
// Use this data in your strategy logic
// Note: You'll need to implement the HTTP call in your platform
request.security(syminfo.tickerid, "", close)
// Usage example - replace with actual HTTP call
string apudflow_data = ""
if barstate.islast
// In a real implementation, you'd make an HTTP GET request here
// apudflow_data := http_get("https://api-t.apudflow.io/api/w/your_workflow_id/your_provider_id")
apudflow_data := "{\"signal\": \"BUY\", \"strength\": 0.8}" // Mock data
// Parse the response (implement JSON parsing)
bool buy_signal = false
if str.contains(apudflow_data, "BUY")
buy_signal := true
// Use in your strategy
if buy_signal
strategy.entry("Buy", strategy.long)
// Plot signal
plotshape(buy_signal, style=shape.triangleup, location=location.belowbar,
color=color.green, size=size.small, title="Buy Signal from ApudFlow")
JavaScript/Node.js Integration
// Fetch data from ApudFlow endpoint
async function fetchApudFlowData(endpointUrl) {
try {
const response = await fetch(endpointUrl);
const data = await response.text(); // or response.json() for JSON responses
return data;
} catch (error) {
console.error('Error fetching data:', error);
return null;
}
}
// Usage
const endpoint = 'https://api-t.apudflow.io/api/w/your_workflow_id/your_provider_id';
const data = await fetchApudFlowData(endpoint);
if (data) {
console.log('Received data:', data);
// Process your data here
}
Python Integration
import requests
def fetch_apudflow_data(endpoint_url):
try:
response = requests.get(endpoint_url, timeout=10)
response.raise_for_status()
return response.text # or response.json() for JSON responses
except requests.RequestException as e:
print(f"Error fetching data: {e}")
return None
# Usage
endpoint = "https://api-t.apudflow.io/api/w/your_workflow_id/your_provider_id"
data = fetch_apudflow_data(endpoint)
if data:
print(f"Received data: {data}")
# Process your data here
Important Notes
- Endpoint URLs are stable: Same workflow + provider_id = same URL
- Rate limiting: Consider implementing rate limiting for production use
- Authentication: Add authentication headers if needed for security
- Error handling: Always implement proper error handling in your external code
- Data updates: Re-run the workflow to update data at the same endpoint
Troubleshooting
- 404 Error: Check that workflow_id and provider_id are correct
- Empty Response: Verify the worker has been run and data is stored
- Connection Timeout: Check network connectivity and endpoint URL
- CORS Issues: If calling from browsers, ensure CORS is properly configured