API Documentation
Connect your applications with Flow-Gate's multi-protocol messaging gateway
High-Performance Gateway
Flow-Gate core is written in Go to ensure maximum throughput and microsecond-level latency. It uses NATS JetStream as the underlying message bus, providing guaranteed delivery and exactly-once processing.
Quick Start
Supported Protocols
RESTful API for simple publishing and real-time streaming.
Bi-directional channel for complex real-time apps.
Standard protocol for IoT and constrained devices.
Persistent SQS-like messaging with visibility timeouts.
Topic Structure
Topics in Flow-Gate follow a specific structure to organize messages and enforce permissions:
userid_app_topic
userid: Your unique user ID
app: Application identifier
topic: Specific topic within the application
Note: When connecting via MQTT or checking permissions, you use the full string. However, our JWT service handles the prefixing for you automatically based on your token request.
Quick Snippets
# Publish a message via HTTP
curl -X POST "https://dev.gateway.flow-gate.kingofshiba.xyz/api/v1/publish" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"topic": "notifications",
"message": "Hello World!"
}'// Connect to Flow-Gate WebSocket
const ws = new WebSocket('wss://api.flow-gate.com/ws?token=YOUR_JWT_TOKEN');
// Handle connection
ws.onopen = () => {
console.log('Connected to Flow-Gate');
// Subscribe to a topic (Short Name)
ws.send(JSON.stringify({
action: "subscribe",
topic: "notifications"
}));
};
// Handle incoming messages
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
// data: { action: "message", topic: "notifications", data: "..." }
console.log('Received:', data);
};
// Publish a message
function publishMessage(topic, message) {
ws.send(JSON.stringify({
action: "publish",
topic: topic,
message: message // Can be string or JSON
}));
} // Note: Server returns no ack for WS publish by default# Connect via MQTT using mosquitto
mosquitto_pub -h api.flow-gate.com -p 1883 \
-u "Bearer" \
-P "YOUR_JWT_TOKEN" \
-t "notifications" \
-m "Hello from MQTT!"
# Subscribe to a topic
mosquitto_sub -h api.flow-gate.com -p 1883 \
-u "Bearer" \
-P "YOUR_JWT_TOKEN" \
-t "notifications"# Send a message to a queue
curl -X POST "https://dev.gateway.flow-gate.kingofshiba.xyz/api/v1/queues/myqueue/messages" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"body": "Your message content"
}'