# Step 1: Create a WebSocket session
curl https://tcpdata.com/ws/new
# Returns:
# {
# "id": "abc12345",
# "ws_url": "wss://tcpdata.com/ws/abc12345",
# "history_url": "https://tcpdata.com/ws/abc12345/history",
# "expires_in": "1 hour"
# }
# Step 2: Connect with wscat or any WebSocket client
wscat -c wss://tcpdata.com/ws/abc12345
# Step 3: View message history
curl https://tcpdata.com/ws/abc12345/history
// Create session
const session = await fetch('https://tcpdata.com/ws/new')
.then(r => r.json());
// Connect to WebSocket
const ws = new WebSocket(session.ws_url);
ws.onopen = () => {
ws.send('Hello!');
};
ws.onmessage = (event) => {
console.log('Received:', event.data);
};
// Later, view history
const history = await fetch(session.history_url)
.then(r => r.json());
console.log(history.messages);
import requests
import websocket
# Create session
response = requests.get('https://tcpdata.com/ws/new')
session = response.json()
# Connect and send messages
ws = websocket.WebSocket()
ws.connect(session['ws_url'])
ws.send('Hello!')
print(ws.recv())
# View history
history = requests.get(session['history_url']).json()
print(history['messages'])