Article Structure

News articles are delivered with the following data structure based on the official API:
{
  "_id": "67850d7b0123456789abcdef",
  "title": "Tesla Stock Surges After Q4 Earnings Beat",
  "koTitle": "테슬라 4분기 실적 발표 후 주가 급등",
  "url": "https://www.byul.ai/news/tesla-earnings-q4-2024",
  "date": "2024-01-15T10:30:00.000Z",
  "source": "byul.ai",
  "timestamp": 1705401000,
  "importanceScore": 8,
  "category": "earnings",
  "symbols": ["TSLA"],
  "sentiment": "positive"
}

Field Descriptions

Core Fields:
  • _id - Unique article identifier
  • title - Article headline (primary, usually English)
  • koTitle - Korean title (optional)
  • url - Link to original article
  • date - Article date (ISO 8601 format)
Metadata:
  • source - News source name (always “byul.ai”)
  • timestamp - Unix timestamp
  • symbols - Related stock symbols array (optional)
Classification:
  • importanceScore - Market importance (0-10 integer, higher = more important)
  • category - News category
  • sentiment - Sentiment analysis result (“positive”, “negative”, “neutral”) (optional)

Receiving Data

Listen for incoming news articles:
socket.on('news:data', (response) => {
  const { data } = response;
  const { news } = data;
  
  news.forEach(article => {
    console.log(`${article.title}`);
    console.log(`Importance: ${article.importanceScore}/10`);
    console.log(`Symbols: ${article.symbols?.join(', ') || 'General'}`);
    console.log(`Sentiment: ${article.sentiment || 'N/A'}`);
    console.log(`Source: ${article.source}`);
  });
});

WebSocket Response Format

The complete WebSocket response structure:
{
  "type": "news",
  "data": {
    "news": [
      {
        "_id": "67850d7b0123456789abcde1",
        "title": "Breaking: Fed Issues Emergency Statement",
        "koTitle": "속보: 연준 긴급성명 발표",
        "url": "https://www.byul.ai/news/fed-emergency-statement",
        "date": "2024-01-15T14:30:00.000Z",
        "source": "byul.ai",
        "timestamp": 1705415400,
        "importanceScore": 10,
        "category": "fed",
        "symbols": [],
        "sentiment": "neutral"
      }
    ],
    "hasMore": false,
    "nextCursor": null,
    "total": 1
  },
  "timestamp": "2024-01-15T14:30:15Z",
  "isRealTimeUpdate": true
}

Data Validation

Always validate incoming data structure:
function validateArticle(article) {
  return (
    article._id &&
    article.title &&
    typeof article.importanceScore === 'number' &&
    Number.isInteger(article.importanceScore) &&
    article.importanceScore >= 0 && article.importanceScore <= 10 &&
    article.date &&
    (!article.sentiment || ['positive', 'negative', 'neutral'].includes(article.sentiment))
  );
}

socket.on('news:data', (response) => {
  const { data } = response;
  const { news } = data;
  const validArticles = news.filter(validateArticle);
  console.log(`Processing ${validArticles.length} valid articles`);
  
  validArticles.forEach(article => {
    processArticle(article);
  });
});

Language Support

Articles include multi-language titles:
  • title - Primary title (usually English)
  • koTitle - Korean version (optional)
Use the appropriate title field based on your application’s language requirements.