> This page is for TWS API.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://ibkrcampus.com/docs/llms.txt.

# Historical News

## Introduction

With the appropriate API news subscription, historical news headlines can be requested from the API using the function `EClient.reqHistoricalNews`. The resulting headlines are returned to `EWrapper.historicalNews`.

---

## Request Historical News

`EClient.reqHistoricalNews(requestId, conId, providerCodes, startDateTime, endDateTime, totalResults, historicalNewsOptions)`

Requests historical news headlines.

**`requestId`** `int`

Request identifier used to track data.

---

**`conId`** `int`

Contract id of ticker. See Contract Details for how to retrieve conId.

---

**`providerCodes`** `string`

A '+'-separated list of provider codes.

---

**`startDateTime`** `string`

Marks the (exclusive) start of the date range. The format is yyyy-MM-dd HH:mm:ss. You can set either startDateTime or endDateTime. If both are set, endDateTime is ignored.

---

**`endDateTime`** `string`

Marks the (inclusive) end of the date range. The format is yyyy-MM-dd HH:mm:ss. You can set either startDateTime or endDateTime. If both are set, endDateTime is ignored.

---

**`totalResults`** `int`

The maximum number of headlines to fetch (1 – 300).

---

**`historicalNewsOptions`** `Null`

Reserved for internal use. Should be defined as null.

---

\


#### Python

```python
self.reqHistoricalNews(reqId, 8314, "BRFG", "", "", 10, [])
```

#### Java

```java
client.reqHistoricalNews(reqId, 8314, "BZ+FLY", "", "", 10, null);
```

#### C++

```cpp
TagValueList* list = new TagValueList();
list->push_back((TagValueSPtr)new TagValue("manual", "1"));
m_pClient->reqHistoricalNews(reqId, 8314, "BZ+FLY", "", "", 5, TagValueListSPtr(list));
```

#### C\#

```csharp
client.reqHistoricalNews(reqId, 8314, "BZ+FLY", "", "", 10, null);
```

#### VB.NET

```vbnet
client.reqHistoricalNews(reqId, 8314, "BZ+FLY", "", "", 10, Nothing)
```

---

## Receive Historical News

`EWrapper.historicalNews(requestId, time, providerCode, articleId, headline)`

Returns news headlines for requested contracts.

**`requestId`** `int`

Request identifier used to track data.

---

**`time`** `int`

Epoch time of the article's published time.

---

**`providerCode`** `string`

News provider code based on requested data.

---

**`articleId`** `string`

Identifier used to track the particular article.

---

**`headline`** `string`

Headline of the provided news article.

---

\


#### Python

```python
def historicalNews(self, requestId: int, time: int, providerCode: str, articleId: str, headline: str):
  print("historicalNews. RequestId:", requestId, "Time:", time, "ProviderCode:", providerCode, "ArticleId:", articleId, "Headline:", headline)
```

#### Java

```java
@Override
public void historicalNews(int requestId, long time, String providerCode, String articleId, String headline) {
	System.out.println( EWrapperMsgGenerator.historicalNews( requestId, time, providerCode, articleId, headline));
}
```

#### C++

```cpp
void TestCppClient::historicalNews(int requestId, time_t time, const std::string& providerCode, const std::string& articleId, const std::string& headline) {
    printf("historicalNews. RequestId: %d, Time: %s, ProviderCode: %s, ArticleId: %s, Headline: %s\n", requestId, ctime(&(time /= 1000)), providerCode.c_str(), articleId.c_str(), headline.c_str());
}
```

#### C\#

```csharp
public void historicalNews(int requestId, long time, string providerCode, string articleId, string headline)
{
	Console.WriteLine("historicalNews. RequestId: {0}, Time Stamp: {1}, Provider Code: {2}, Article Id: {3}, headline: {4}, extraData: {5}", requestId, Util.LongMaxString(time), providerCode, articleId, headline);
}
```

#### VB.NET

```vbnet
Public Sub historicalNews(requestId As Integer, time As Long, providerCode As String, articleId As String, headline As String) Implements IBApi.EWrapper.tickNews
	Console.WriteLine("Tick News. Ticker Id: " & tickerId & ", Time: " & Util.LongMaxString(time) & ", Provider Code: " & providerCode & ", Article Id: " & articleId & ", Headline: " & headline)
End Sub
```

### EWrapper.historicalNewsEnd

`EWrapper.historicalNewsEnd(requestId, hasMore)`

Returns news headlines end marker.

**`requestId`** `int`

Request identifier used to track data.

---

**`hasMore`** `bool`

Returns whether there is more data (true) or not (false).

---

#### Python

```python
def historicalDataEnd(self, reqId: int, hasMore: bool):
    print("historicalDataEnd. ReqId:", reqId, "Has More:", hasMore)
```

#### Java

```java
@Override
public void historicalDataEnd(int reqId, bool hasMore) {
    System.out.println("historicalDataEnd. Req Id: " + EWrapperMsgGenerator.historicalDataEnd(reqId, hasMore));
}
```

#### C++

```cpp
void TestCppClient::historicalDataEnd( int reqId, bool hasMore) {
    printf( "historicalDataEnd. Req Id: %d\n", reqId);
}
```

#### C\#

```csharp
public virtual void historicalDataEnd(int reqId, bool hasMore)
{
    Console.WriteLine("historicalDataEnd. Req Id: "+reqId+"\n");
}
```

#### VB.NET

```vbnet
Public Sub historicalDataEnd(reqId As Integer, hasMore as Boolean) Implements IBApi.EWrapper.historicalDataEnd
    Console.WriteLine("historicalDataEnd - ReqId [" & reqId & "]")
End Sub
```