← Back to Home

Stream JSON

/stream/:n
Streams n JSON objects as newline-delimited JSON.

Parameters

n path
Number of JSON objects to stream

Examples

curl
curl https://tcpdata.com/stream/5
JavaScript (fetch)
fetch('https://tcpdata.com/stream/5')
  .then(res => res.text())
  .then(data => {
    data.split('\n').forEach(line => {
      if (line) console.log(JSON.parse(line));
    });
  });
Python (requests)
import requests
import json

response = requests.get('https://tcpdata.com/stream/5', stream=True)
for line in response.iter_lines():
    if line:
        print(json.loads(line))