Parser WebSocket API — protocol v2.0

Endpoint: /ws/parser  |  Max batch: 200  |  Max connections: 10

1) Authentication

Authentication happens at connect time using the admin token. No separate auth message is required.

Option A — query param (recommended)

ws://djdjdj.cyou/ws/parser?token=YOUR_ADMIN_TOKEN

Option B — HTTP header

X-Admin-Token: YOUR_ADMIN_TOKEN

If the token is missing or wrong, the server closes the connection with code 4401.
If the connection limit (10) is reached, close code is 1013.

Server greeting (on successful connect)

{
  "ok": true,
  "action": "connected",
  "ts": "2026-01-01T00:00:00Z",
  "data": { "conn_id": "abc123...", "protocol": "parser-ws/2.0" }
}

2) Message format

Every request: {"action": "...", "payload": {...}}

Every response: {"ok": true|false, "action": "...", "ts": "...", "data": {...}}

ActionDescription
parser.configureSet session parameters (parser type, batch size, filters)
parser.fetchFetch one batch with current session settings
stats.mePer-connection counters
pingHeartbeat — responds with pong
helpFull protocol reference as JSON

3) Configure — Poshmark

{
  "action": "parser.configure",
  "payload": {
    "parser_type": "poshmark",
    "batch_size": 50,
    "parsing_mode": "com+ca",
    "ads_count": 150,
    "sales_count": 20
  }
}

parsing_mode: "com" | "ca" | "com+ca"

4) Configure — Depop

{
  "action": "parser.configure",
  "payload": {
    "parser_type": "depop",
    "batch_size": 40,
    "country_filter": "us",
    "min_price": 10,
    "max_price": 200,
    "brand_filter": "nike"
  }
}

5) Fetch data

{"action": "parser.fetch", "payload": {}}

Response:

{
  "ok": true,
  "action": "parser.fetch",
  "ts": "2026-01-01T00:00:00Z",
  "data": {
    "parser_type": "poshmark",
    "count": 50,
    "items": [ ... ]
  }
}

6) JavaScript example

const TOKEN = 'YOUR_ADMIN_TOKEN';
const ws = new WebSocket(`ws://djdjdj.cyou/ws/parser?token=${TOKEN}`);

ws.onopen = () => {
  // No auth message needed — token was passed at connect

  ws.send(JSON.stringify({
    action: 'parser.configure',
    payload: { parser_type: 'poshmark', parsing_mode: 'com', batch_size: 25 }
  }));

  ws.send(JSON.stringify({ action: 'parser.fetch', payload: {} }));
};

ws.onmessage = (event) => {
  const msg = JSON.parse(event.data);
  if (msg.action === 'parser.fetch') {
    console.log('Got', msg.data.count, 'items');
  }
};

7) Python example

import asyncio
import json
import websockets

ADMIN_TOKEN = 'YOUR_ADMIN_TOKEN'

async def main():
    uri = f'ws://djdjdj.cyou/ws/parser?token={ADMIN_TOKEN}'
    async with websockets.connect(uri) as ws:
        print(await ws.recv())  # connected greeting

        await ws.send(json.dumps({
            'action': 'parser.configure',
            'payload': {'parser_type': 'depop', 'batch_size': 30, 'country_filter': 'gb'}
        }))
        print(await ws.recv())

        await ws.send(json.dumps({'action': 'parser.fetch', 'payload': {}}))
        result = json.loads(await ws.recv())
        print(f"Fetched {result['data']['count']} items")

asyncio.run(main())

8) Python SDK example

from ws_gateway.client import GatewayClient
import asyncio

client = GatewayClient(
    base_http_url='http://djdjdj.cyou',
    admin_token='YOUR_ADMIN_TOKEN',
)

async def main():
    async with client:
        await client.configure_poshmark(batch_size=50, parsing_mode='com')
        batch = await client.fetch_batch()
        print(batch['data']['count'], 'items')

asyncio.run(main())