├── src └── financial-news-api │ ├── __init__.py │ └── example.py ├── .gitignore ├── pyproject.toml ├── LICENSE └── README.md /src/financial-news-api/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | venv 2 | env 3 | dist 4 | build 5 | .idea 6 | .pypirc 7 | .deploy.sh -------------------------------------------------------------------------------- /src/financial-news-api/example.py: -------------------------------------------------------------------------------- 1 | def add_one(number): 2 | return number + 1 -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["hatchling"] 3 | build-backend = "hatchling.build" 4 | 5 | [project] 6 | name = "financial-news-api" 7 | version = "0.0.1" 8 | authors = [ 9 | { name="FinancialNewsApi", email="support@newsfilter.io" }, 10 | ] 11 | description = "Stock Market and Financial News API" 12 | readme = "README.md" 13 | requires-python = ">=3.7" 14 | classifiers = [ 15 | "Development Status :: 5 - Production/Stable", 16 | "Programming Language :: Python :: 3", 17 | "License :: OSI Approved :: MIT License", 18 | "Operating System :: OS Independent", 19 | ] 20 | 21 | [project.urls] 22 | "Homepage" = "https://github.com/FinancialNewsAPI/financial-news-api-python" 23 | "Bug Tracker" = "https://github.com/FinancialNewsAPI/financial-news-api-python/issues" 24 | "Documentation" = "https://developers.newsfilter.io/" -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 The Python Packaging Authority 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Stock Market & Financial News API 2 | 3 | Access stock market and financial news of all publicly traded companies listed on US stock exchanges. 4 | 5 | - More than 50 million articles accessible 6 | - All major newswires included 7 | - Real-time news stream API and historical news search API 8 | 9 | Get your free API key: https://newsfilter.io/api-plans 10 | 11 | # Installation 12 | 13 | ```bash 14 | pip install financial-news-api 15 | ``` 16 | 17 | # Search API 18 | 19 | The Search API allows you to access and search the news database with over 50 million articles. 20 | Newly published articles are added in real-time to the database. 21 | 22 | ```python 23 | import requests 24 | 25 | API_KEY = "YOUR_API_KEY" 26 | API_ENDPOINT = "https://api.newsfilter.io/search?token={}".format(API_KEY) 27 | 28 | # Define the news search parameters 29 | queryString = "symbols:NFLX AND publishedAt:[2020-02-01 TO 2020-05-20]" 30 | 31 | payload = { 32 | "queryString": queryString, 33 | "from": 0, 34 | "size": 10 35 | } 36 | 37 | # Send the search query to the Search API 38 | response = requests.post(API_ENDPOINT, json=payload) 39 | 40 | # Read the response 41 | articles = response.json() 42 | 43 | print(articles) 44 | ``` 45 | 46 | ### Example Response 47 | 48 | ```json 49 | { 50 | "articles": [ 51 | { 52 | "title": "FAANG emerges as the latest group to lead the market, Jim Cramer says", 53 | "description": "\"This market's been going through leadership groups like there's no tomorrow,\" the \"Mad Money\" host said.", 54 | "publishedAt": "2020-05-20T22:32:22+0000", 55 | "sourceUrl": "https://www.cnbc.com/2020/05/20/faang-emerges-as-the-latest-group-to-lead-the-market-jim-cramer-says.html", 56 | "source": { 57 | "name": "CNBC", 58 | "id": "cnbc" 59 | }, 60 | "symbols": [ 61 | "FB", 62 | "AAPL", 63 | "AMZN", 64 | "NFLX", 65 | "GOOGL", 66 | "TGT", 67 | "WMT", 68 | "HD", 69 | "LOW" 70 | ], 71 | "sectors": [ 72 | "Technology", 73 | "Consumer Cyclical", 74 | "Consumer Defensive" 75 | ], 76 | "industries": [ 77 | "Internet Content & Information", 78 | "Consumer Electronics", 79 | "Specialty Retail", 80 | "Media - Diversified", 81 | "Discount Stores", 82 | "Home Improvement Stores" 83 | ], 84 | "imageUrl": "https://image.cnbcfm.com/api/v1/image/103267851-IMG_0161.jpg?v=1545882603", 85 | "id": "01a030ca440ba8732461703e9a906eb7" 86 | }, 87 | { 88 | "title": "S&P 500 Clawing Toward 3,000 Milestone Finds Road Getting Harder", 89 | "description": "A rally this week has pushed the S&P 500 Index to 2,972. The 28-point road to 3,000 could be a slog.", 90 | "publishedAt": "2020-05-20T20:18:32.731Z", 91 | "sourceUrl": "https://www.bloomberg.com/news/articles/2020-05-20/s-p-500-s-next-even-number-milestone-will-be-tough-to-reach", 92 | "source": { 93 | "name": "Bloomberg", 94 | "id": "bloomberg" 95 | }, 96 | "symbols": [ 97 | "FB", 98 | "AMZN", 99 | "NFLX" 100 | ], 101 | "sectors": [ 102 | "Technology", 103 | "Consumer Cyclical" 104 | ], 105 | "industries": [ 106 | "Internet Content & Information", 107 | "Specialty Retail", 108 | "Media - Diversified" 109 | ], 110 | "imageUrl": "https://assets.bwbx.io/images/users/iqjWHBFdfxIU/iiT4fbpCD7v8/v2/-1x-1.png", 111 | "id": "a63b37b42f4c2a856535a3b7e8bb3190" 112 | } 113 | ] 114 | } 115 | ``` 116 | 117 | # Stream API 118 | 119 | Setting up a news streaming API to receive newly published articles in real-time can be done in less than 10 lines of code. 120 | 121 | First, install `socket.io` for Python: 122 | 123 | ``` 124 | pip install python-engineio==3.14.2 python-socketio[client]==4.6.0 125 | ``` 126 | 127 | > Please use the exact `python-engineio` and `python-socketio` versions above. 128 | 129 | The example below creates a `socket.io` client, connects to the Stream API server and prints new articles as they are published. 130 | 131 | ```python 132 | import socketio 133 | 134 | sio = socketio.Client() 135 | 136 | @sio.on('connect') 137 | def on_connect(): 138 | print("Connected to Newsfilter Stream API") 139 | 140 | @sio.on('articles') 141 | def on_articles(articles): 142 | print(articles) 143 | 144 | sio.connect('http://stream.newsfilter.io?apiKey=YOUR_API_KEY') 145 | sio.wait() 146 | ``` 147 | 148 | # Topics 149 | 150 | The news API supports a large range of topics, for example: 151 | - Quarterly and annual earnings reports 152 | - Insider trading reports filed with the SEC 153 | - Merger & acquisition news 154 | - IPOs and offerings 155 | - Legal proceedings and federal investigations 156 | - Changes to management 157 | 158 | # News Sources 159 | 160 | 161 | | News Provider | Source ID | 162 | |--------------------------------|------------------------------------------:| 163 | | Analyst Ratings | analystUpgrades | 164 | | Bloomberg | bloomberg | 165 | | Reuters | reuters | 166 | | CNBC | cnbc | 167 | | Wall Street Journal | wall-street-journal | 168 | | Barrons | barrons | 169 | | PR Newswire | prNewswire | 170 | | Globe Newswire | globenewswire | 171 | | BusinessWire | businesswire | 172 | | AccessWire | accesswire | 173 | | SeekingAlpha | seekingAlpha | 174 | | Zacks Equity Research | zacks | 175 | | Benzinga | benzinga | 176 | | S&P Global | sandpGlobal | 177 | | Earnings Call Transcripts | earningsCallTranscripts | 178 | | **US:** | | 179 | | ClinicalTrials.gov | clinicaltrials | 180 | | Gov. Contract Awards (SAM.gov) | usSam | 181 | | SEC Filings | sec-api | 182 | | SEC Press Releases | secPressReleases | 183 | | FCC Filings | fccFilings | 184 | | CFTC Press Releases | cftc | 185 | | Patent Database (USPTO) | uspto | 186 | | Patent Trial & Appeal Board | usptoTrialAndAppeal | 187 | | Department of Defense | usDod | 188 | | FDA Drug Approvals | usFda (`usFdaType` = `drugApproval`) | 189 | | FDA Press Releases | usFda (`usFdaType` = `pressAnnouncement`) | 190 | --------------------------------------------------------------------------------