News API

News API access is available with data API keys, or separately from $129/mo.

Please see the subscription page in the webapp to get a key.

News objects contain the following fields:

{
    id: 55, // unique identifier
    time: 1704085200000, // timestamp the news was published
    effectiveTime: 1704085200000, // timestamp the news happened
    headline: "Hello world",
    source: "Velo",
    priority: 2, // 1 = top priority only, 2 = everything else
    coins: ['BTC'], // list of relevant coins
    summary: "# Hello world", // may include markdown
    link: "https://velodata.app" // source link
}

The WebSocket may also send edit events which will have all fields above plus edit: true , or delete events which will have only the following {id: id, deleted: true}.


Python

Quick Start
import asyncio
from velodata import lib as velo

# new velo client
client = velo.client('api_key')

# get past stories
print(client.news.get_news())

# stream new stories
async def stream():
    async for message in client.news.stream_news():
        if(message in ('connected', 'heartbeat', 'closed')):
            print(message)
        else:
            print(json.loads(message))
        
asyncio.run(stream())
Get news

news.get_news(begin)

  • begin (optional, defaults to 0): millisecond timestamp to only fetch news after

Returns list of news objects (dicts)

Stream news

news.stream_news()

Returns generator, generator returns 'connected', 'heartbeat', 'closed', or news object (dict)

Close stream

news.close_stream()

Closes open websocket and exits generator


NodeJS

Quick Start
const velo = require('velo-node')

async function doWork() {

  // get past stories
  const stories = await client.news.stories()
  console.log(stories)

  // stream new stories
  const socket = client.news.stream()
  
  socket.on('open', () => console.log('connected'))
  socket.on('close', () => console.log('closed'))
  socket.on('error', (err) => { 
    console.log('error', err) 
    socket.close()
  })

  socket.on('message', (data) => {
    const json = JSON.parse(data.toString())
    if (json.heartbeat) {
      console.log('heartbeat')
      return
    }
    console.log(json)
  })
}

const client = new velo.Client('api_key')

doWork()
Get news

news.stories({begin})

  • begin (optional, defaults to 0): millisecond timestamp to only fetch news after

Returns list of news Objects

Stream news

news.stream()

Returns WebSocket, WebSocket sends 'connected', 'heartbeat', 'closed', or news Object


HTTP

Quick Start

$ curl -v --user "api:api_key" "https://api.velodata.app/api/n/news?begin=0"

Get news

/news

  • begin (optional, defaults to 0): millisecond timestamp to only fetch news after

Returns JSON

Last updated