API Documentation

Access real-time press releases from major wire services via REST API or WebSocket. Get the news before everyone else.

🚀 Getting Started
Everything you need to know to start using the RTPR API

Base URL

https://api.rtpr.io

Authentication

Include your API key in the request header:

X-API-Key: YOUR_API_KEY

Rate Limits

60 requests per minute

GET/articles
Retrieve recent press releases from all tickers

Query Parameters

limitoptional

Number of articles to return (default: 20, max: 100)

Response

{
  "count": 20,
  "articles": [
    {
      "ticker": "AAPL",
      "title": "Apple Announces Q4 Results",
      "author": "Business Wire",
      "created": "Mon, 28 Jul 2025 16:30:00 -0400",
      "article_body": "Apple Inc. announced financial results for its fiscal fourth quarter ended September 30, 2025. The company posted quarterly revenue of $89.5 billion, up 6% year over year..."
    }
  ]
}

Code Examples

Try it yourself
Get recent press releases
JavaScript
const response = await fetch('https://api.rtpr.io/articles?limit=10', {
  headers: {
    'X-API-Key': 'YOUR_API_KEY'
  }
});

const data = await response.json();
console.log('Found ' + data.count + ' articles');

data.articles.forEach(article => {
  console.log(article.ticker + ': ' + article.title);
});

💡 JavaScript Notes:

  • • Works in Node.js and modern browsers
  • • Uses native fetch API (no external dependencies)
  • • Async/await for clean promise handling
GET/article
Get today's press releases for a specific ticker

Query Parameters

tickerrequired

Stock ticker symbol (e.g., AAPL, TSLA, MSFT)

Response

{
  "ticker": "AAPL",
  "date": "Mon, 28 Jul 2025",
  "count": 3,
  "articles": [
    {
      "ticker": "AAPL",
      "title": "Apple Announces Q4 Results",
      "author": "Business Wire",
      "created": "Mon, 28 Jul 2025 16:30:00 -0400",
      "article_body": "Apple Inc. announced financial results for its fiscal fourth quarter ended September 30, 2025. The company posted quarterly revenue of $89.5 billion, up 6% year over year..."
    }
  ]
}

Code Examples

Try it yourself
Get today's articles for AAPL
JavaScript
const ticker = 'AAPL';
const response = await fetch('https://api.rtpr.io/article?ticker=' + ticker, {
  headers: {
    'X-API-Key': 'YOUR_API_KEY'
  }
});

const data = await response.json();

if (data.count > 0) {
  console.log('Found ' + data.count + ' articles for ' + data.ticker + ' today');
  
  data.articles.forEach(article => {
    console.log('📰 ' + article.title);
    console.log('🕒 ' + article.created);
    console.log('✍️ ' + article.author);
    console.log('---');
  });
} else {
  console.log('No articles found for ' + ticker + ' today');
}

💡 JavaScript Notes:

  • • Works in Node.js and modern browsers
  • • Uses native fetch API (no external dependencies)
  • • Async/await for clean promise handling
Real-Time

WebSocket API

Get press releases pushed to you instantly via WebSocket. Sub-500ms latency from wire release to your application.

⚡ WebSocket Connection
Connect to our real-time news stream for instant updates

WebSocket URL

wss://ws.rtpr.io

Authentication

Pass your API key as a query parameter when connecting:

wss://ws.rtpr.io?apiKey=YOUR_API_KEY

Connection Limits

1 concurrent WebSocket connection per API key

💡 Why WebSocket?

  • Sub-500ms latency — Articles delivered as they hit the wire
  • No polling — Server pushes articles to you instantly
  • Ticker subscriptions — Only receive articles for tickers you care about
  • Efficient — Single persistent connection, no repeated API calls
🎯 Subscribing to Tickers
Choose which tickers you want to receive articles for — no need to filter client-side

How it works: After connecting, send a subscribe message with your desired tickers. You'll only receive articles that match your subscription. You can update your subscription anytime without reconnecting.

subscribeSubscribe to TickersClient → Server

Send this message to specify which tickers you want to receive

// Subscribe to specific tickers
{
  "action": "subscribe",
  "tickers": ["AAPL", "TSLA", "NVDA", "MSFT"]
}

// Subscribe to ALL tickers (firehose mode)
{
  "action": "subscribe",
  "tickers": ["*"]
}
subscribedSubscription ConfirmedServer → Client

Server confirms your subscription

{
  "type": "subscribed",
  "tickers": ["AAPL", "TSLA", "NVDA", "MSFT"],
  "message": "Subscribed to 4 tickers",
  "timestamp": "2025-07-28T16:30:00.000Z"
}
unsubscribeUnsubscribe from TickersClient → Server

Remove specific tickers from your subscription

// Unsubscribe from specific tickers
{
  "action": "unsubscribe",
  "tickers": ["TSLA"]
}

// Unsubscribe from all (pause feed)
{
  "action": "unsubscribe",
  "tickers": ["*"]
}

Common Subscription Patterns

Watch a Watchlist

{"action": "subscribe", "tickers": ["AAPL", "GOOGL", "MSFT", "AMZN"]}

All News (Firehose)

{"action": "subscribe", "tickers": ["*"]}

Add a Ticker

{"action": "subscribe", "tickers": ["NVDA"]} // adds to existing

Pause Feed

{"action": "unsubscribe", "tickers": ["*"]}
📨 Message Types
Messages you'll receive over the WebSocket connection
connectedConnection Confirmed

Sent immediately after successful authentication. Send your subscription after receiving this.

{
  "type": "connected",
  "message": "Connected to RTPR real-time feed",
  "timestamp": "2025-07-28T16:30:00.000Z"
}
subscribedSubscription Confirmed

Confirms your ticker subscription was successful

{
  "type": "subscribed",
  "tickers": ["AAPL", "TSLA", "NVDA"],
  "message": "Subscribed to 3 tickers",
  "timestamp": "2025-07-28T16:30:00.000Z"
}
articleNew Article

Pushed instantly when a new press release is published

{
  "type": "article",
  "data": {
    "id": "abc123",
    "ticker": "AAPL",
    "tickers": ["AAPL", "MSFT"],
    "title": "Apple Announces Strategic Partnership",
    "author": "Business Wire",
    "created": "2025-07-28T16:30:00.000Z",
    "article_body": "Apple Inc. today announced a strategic partnership..."
  },
  "timestamp": "2025-07-28T16:30:00.123Z"
}
pingHeartbeat

Sent every 30 seconds to keep the connection alive. Respond with a pong message.

{
  "type": "ping",
  "timestamp": "2025-07-28T16:30:30.000Z"
}
errorError

Sent when an error occurs (authentication failure, rate limit, etc.)

{
  "type": "error",
  "code": "AUTH_FAILED",
  "message": "Invalid API key",
  "timestamp": "2025-07-28T16:30:00.000Z"
}
💻 WebSocket Code Examples
Connect to the real-time feed in your preferred language
// Browser JavaScript WebSocket Example
const API_KEY = 'YOUR_API_KEY';
const WATCHLIST = ['AAPL', 'TSLA', 'NVDA', 'MSFT'];

const ws = new WebSocket(`wss://ws.rtpr.io?apiKey=${API_KEY}`);

ws.onopen = () => {
  console.log('✅ Connected to RTPR real-time feed');
};

ws.onmessage = (event) => {
  const message = JSON.parse(event.data);
  
  switch (message.type) {
    case 'connected':
      console.log('🟢 ' + message.message);
      // Subscribe to your watchlist after connecting
      ws.send(JSON.stringify({
        action: 'subscribe',
        tickers: WATCHLIST
      }));
      break;
    
    case 'subscribed':
      console.log('📋 Subscribed to:', message.tickers.join(', '));
      break;
      
    case 'article':
      const article = message.data;
      console.log('📰 NEW ARTICLE:', article.ticker);
      console.log('   Title:', article.title);
      console.log('   Source:', article.author);
      console.log('   Time:', article.created);
      
      // Process the article (e.g., trigger trading logic)
      processArticle(article);
      break;
      
    case 'ping':
      // Respond to keep connection alive
      ws.send(JSON.stringify({ type: 'pong' }));
      break;
      
    case 'error':
      console.error('❌ Error:', message.message);
      break;
  }
};

ws.onerror = (error) => {
  console.error('WebSocket error:', error);
};

ws.onclose = (event) => {
  console.log('🔌 Connection closed. Reconnecting in 5s...');
  setTimeout(() => reconnect(), 5000);
};

function processArticle(article) {
  // Your trading logic here
  console.log('🍎 Processing:', article.ticker, '-', article.title);
}

// Add a new ticker to your subscription at any time
function addTicker(ticker) {
  ws.send(JSON.stringify({
    action: 'subscribe',
    tickers: [ticker]
  }));
}
🎯 Best Practices
Optimize your WebSocket integration for reliability and performance

✅ Do

  • Implement reconnection logic — Connections can drop; auto-reconnect after 5s
  • Respond to ping messages — Send pong to keep connection alive
  • Process articles asynchronously — Don't block the message handler
  • Log connection events — Track connects, disconnects, and errors
  • Handle all message types — connected, article, ping, error

❌ Don't

  • Open multiple connections — 1 connection per API key
  • Ignore ping messages — Connection will timeout after 60s
  • Block on article processing — You'll miss subsequent articles
  • Expose API key in client code — Use server-side connections for production
  • Reconnect immediately on close — Use exponential backoff
⚖️ WebSocket vs REST API
Choose the right approach for your use case
FeatureWebSocketREST API
Latency~50-500ms (real-time push)Depends on poll frequency
Best ForTrading bots, real-time alertsDashboards, historical queries
ConnectionPersistent (always connected)On-demand (request/response)
ComplexityRequires reconnection handlingSimple HTTP requests
Rate LimitsUnlimited incoming messages60 requests/minute

💡 Recommendation: Use WebSocket for real-time trading applications where every millisecond counts. Use REST API for dashboards, research tools, or when you need to query historical data.

Error Responses
Common error codes and their meanings
400Bad Request

Missing required parameters (e.g., ticker parameter for /article)

401Unauthorized

Invalid or missing API key

429Too Many Requests

Rate limit exceeded (60 requests per minute)

500Internal Server Error

Server error - please try again or contact support

Need Help?
We're here to help you succeed

📧 Email Support

Get help from our team

support@rtpr.io

📊 Dashboard

Manage your API keys and usage

rtpr.io/dashboard