文件
新聞分群-即時
Service: https://news.api.yating.tw/v2
此服務從新聞、社群內容中將文章進行分群,達成事件挖掘與摘要。你可以直接藉由 RESTful API 輸入查詢條件後,就可以到相關事件,並進行適當的排序。此功能讓你不用閱讀逐篇文章,而是更快地從事件的角度切入,讓你更快了解全貌。
一個事件會由多篇新聞所組成,並且你可以取得跟這事件相關的社群文章。
1 搜尋相關事件
一個事件由數篇文章組成,此事件中最早的文章是事件發生起點,最新的文章則終點。
Request
URL: /events
Method: GET
Header
Name
| Type
| Info
|
Authorization | String
| Bearer {key} |
Parameter
Name
| Type
| Info
|
*start | string
| 給定 start, end 時間區間,如果一個事件中的起點與終點與此區段有重疊,就會回傳。
請輸入距離今90天內的日期 (時區為 UTC+0)
E.g. 2022-09-26T13:50:55Z |
*end | string
| 給定 start, end 時間區間,如果一個事件中的起點與終點與此區段有重疊,就會回傳。請輸入距離今90天內的日期 (時區為 UTC+0)
E.g. 2022-09-26T13:50:55Z |
category | string
|
Here are all categories:
all,
world,
technology,
business,
sports,
entertainment,
health,
science,
others
collaberativeBehavior
|
query | string
| |
fields
| string
| If you need more information in response, you may pick the following fields.
title,
generativeShortSummary,
generativeLongSummary,extractiveShortSummary,
extractiveLongSummary
|
sourceLanguage | array
| Default en. Origin source language, default is en. Available values : en, zh-hant |
sort | string
| With Keywords search: updatedAt , relevance
Without Keywords search: updatedAt , newsCount , fbPosts, fbComments, fbLikes, fbShares ** updatedAt is the end of an event |
limit
| int
| Use this parameter to specify a cursor search limit (number of results per page) for your API request. Default limit value is 10, maximum allowed limit value is 50.
|
after
| string
| search next page by token (just use the value of positionKey in here) |
Response
你會取得事件陣列,其中包含多個相關事件實體。關於 event 實體中包含哪些資訊,請看 5 Event 實體說明。
Name
| Type
| Info
|
total
| number
| |
positionKey
| string
| |
events
| object[]
| 關於 event 實體中包含哪些資訊,請看 5 Event 實體說明。
|
|
2 取得單一事件詳細內容
This is to get detailed information for an event.
Request
URL: /events/{eventId}
Method: GET
Header
Name
| Type
| Info
|
Authorization
| String
| Bearer {key} |
Parameter
Name
| Type
| Info
|
*eventId | string
| |
fields
| string
| If you need more information in response, you may pick the following fields.
title,
generativeShortSummary,
generativeLongSummary,extractiveShortSummary,
extractiveLongSummary
|
Response
你會得到一個 event 實體。此外,即時事件 event id 會變動,所以:
有正確找到的回應是 200 跟 json response
event id 已改變,就會回傳 307
event id 不存在回傳 404
3 查詢事件的來源文章
來源包含新聞或社群媒體(e.g. ptt, facebook ...),回傳以 source 的 publish time 排序,越新的在前面
Request
URL: /events/{eventId}/sources
Method: GET
Header
Name
| Type
| Info
|
Authorization
| String
| Bearer {key} |
Parameter
Name
| Type
| Info
|
type
| string
| Available values : news, social (default is all)
|
limit
| int
| The numbers of items to return (default is 15)
|
after
| string
| (just use the value of positionKey in here) |
Response
Name
| Type
| Info
|
positionKey
| number
| |
sources
| object[]
| { " publishedOn ": "經濟日報", "type": "news", " publishedAt ": "2022-02-20T06:51:24", "title": "拜登將召開國安會議 重申俄隨時會進攻烏克蘭", "uri": " https://money.udn.com/money/story/replace_by_spider/6111105",
"commentCounts" : 3 } |
|
|
4 一次取得多個事件的資訊
Request
URL: /events/batch
Method: GET
Header
Name
| Type
| Info
|
Authorization
| String
| Bearer {key} |
Parameter
Name
| Type
| Info
|
*id | string
|
|
fields
| string
| If you need more information in response, you may pick the following fields.
title,
generativeShortSummary, generativeLongSummary,extractiveShortSummary, extractiveLongSummary
|
Response
關於 event 實體中包含哪些資訊,請看 5 Event 實體說明。
|
5 Event 實體說明
一個 event 實體包含以下資訊:
Name
| Type
| Info
|
eventId
| string
| |
sourceLanguage
| string
| |
title
| object
| |
sourceTotal | object
| The count of news related to this event.
|
imgUri
| string
| |
hashtags
| string[]
| |
categories
| categories[]
| 0 Politics, 1 world, 2 technology, 3 business, 4 sports, 6 entertainment, 8 health, 9 science, 10000 others
|
updatedAt | string
| datetime: string, event last update time
|
generativeShortSummary | string
| Event summary
|
string
| Event summary
| |
socialMediaPopularity | object
| It’s trending indicators for frontend services to evaluate an event. These values will be updated every 4 hours within 24 hours for each event. |
|
6 使用限制
60 requests per minutes per IP