newsfilter.io - Stock Market News API

newsfilter.io - Stock Market News API

  • Home

›Query API

Getting Started

  • Introduction
  • News Sources
  • Companies & Exchanges

Query API

  • Intro
  • API Endpoint
  • Authentication
  • Request & Response Formats
  • Example: Python
  • Example: cURL
  • Example: Node.js
  • Tutorials

Stream API

  • Intro
  • API Endpoint
  • Authentication
  • Message Format
  • Example: Python
  • Example: Node.js

Content Render API

  • Overview

Integrations

  • Discord

Python Example

# Package used to execute HTTP POST request to the API
import json
import urllib.request

# API endpoint
API_KEY = 'YOUR_API_KEY'
API_ENDPOINT = "https://api.newsfilter.io/public/actions?token={}".format(API_KEY)

# Define the filter parameters
queryString = "symbols:NFLX AND publishedAt:[2020-02-01 TO 2020-05-20]"

payload = {
    "type": "filterArticles",
    "queryString": queryString,
    "from": 0,
    "size": 200
}

# Format your payload to JSON bytes
jsondata = json.dumps(payload)
jsondataasbytes = jsondata.encode('utf-8')

# Instantiate the request
req = urllib.request.Request(API_ENDPOINT)

# Set the correct HTTP header: Content-Type = application/json
req.add_header('Content-Type', 'application/json; charset=utf-8')
# Set the correct length of your request
req.add_header('Content-Length', len(jsondataasbytes))

# Send the request to the API
response = urllib.request.urlopen(req, jsondataasbytes)

# Read the response
res_body = response.read()
# Transform the response into JSON
articles = json.loads(res_body.decode("utf-8"))

print(articles)
← Request & Response FormatsExample: cURL →
newsfilter.io - Stock Market News API
Docs
Getting StartedQuery APIStream API
Contact
support@newsfilter.io
Social
Follow @newsfilterio
Follow Us on Stocktwits
Copyright © 2021 newsfilter.io