Currently, we are making an app that collects and saves English news and Wikipedia English pages according to the keywords searched by the user. There were few articles in Japanese, so I will explain it in this article. I'm currently studying programming, and this is my first time posting an article on Qiita, so if you make a mistake, please let me know.
With reference to this article, I visited each page and selected an API that seems to be easy to use. I also searched for the API of Japanese newspapers, but couldn't find it. However, in the News API introduced at the end, you can specify the country and you can get articles in Japanese. https://en.wikipedia.org/wiki/List_of_news_media_APIs
・ The New York Times https://developer.nytimes.com/
・ Financial Times https://developer.ft.com/portal
・ The Guardian https://open-platform.theguardian.com/
・ News API https://newsapi.org/
I also wanted to get Wikipedia information apart from the news. I'm using Ruby, so I used this gem. Please note that this gem has the drawback that you cannot get the Wikipedia page unless you enter the article title in English correctly.
https://github.com/kenpratt/wikipedia-client
As you can see from the Wikipedia link I shared at the beginning, it is one of the most complete API functions in the world news sites.
You can get your API key right away by following the Get started steps below.
https://developer.nytimes.com/get-started
There are many API functions, but for reference, I will explain how to search for articles. To Example call https://api.nytimes.com/svc/search/v2/articlesearch.json?q=election&api-key=yourkey As you can see, it's a very orthodox way to use the API. Since q = {query}, you can get your favorite article information by entering this in the user. A json file will be returned, so you can get the first paragraph of each article by repeating ["lead_paragraph"] with each, for example.
https://developer.nytimes.com/docs/articlesearch-product/1/overview
A British newspaper that is strong in economic information. It is also famous for being acquired by the Nikkei newspaper in 2015.
This is a rather tricky way to get an API key by emailing the company after creating an account for the developer, but when I get the key, the company immediately returns an email and nothing The procedure was completed without any problems.
https://developer.ft.com/portal/docs-start-obtain-an-api-key
What's interesting here is the notifications feature, which allows you to get information from the date and time specified by the user to the latest article.
https://developer.ft.com/portal/docs-start-push-notifications-with-pull-requests
This is also a famous British newspaper. The Guardian has a wide network, so I read it occasionally when checking overseas political trends. You can easily get the API key by filling out the form below.
https://bonobo.capi.gutools.co.uk/register/developer
The company's API documentation is easy to read and solid, but it's not very user-friendly because you can't get the content of the article, such as getting paragraphs like the New York Times. https://open-platform.theguardian.com/documentation/
The News API collects information from more than 30,000 news sites around the world, and you can search for article information with many options such as language and keywords. There are many introductory articles in Japanese about this, and if you have added a news information gathering function to the app, you probably already know it.
https://blog.api.rakuten.net/api-tutorial-news-api-jp/
It seems to be very famous and well-received in the news API. It seems to be very easy to use, so if you want to raise the drawback, for example, the New York Times is not included in the target ...
https://towardsdatascience.com/scraping-web-articles-using-newsapi-in-python-a0e97fbab8ed
This article also compares the two APIs.
A brief summary of API usage for overseas news sites. Currently, I am doing my best to get text information, but in the future I would like to implement a function that displays stock price information etc. in real time in a graph using the API of a news site that is more economically strong such as Bloomberg. I think. If you have any questions or suggestions, we would appreciate it if you could comment.
Recommended Posts