You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Refinitiv-Eikon Python API调用时持续返回404错误求助

问题:调用Refinitiv Eikon Python API获取新闻标题时返回404错误(Cannot POST /api/v1/data)

环境背景

  • 使用Eikon财富管理版本
  • 执行官方示例代码调用ek.get_news_headlines获取LHAG.DE的新闻标题失败
  • 此前可用的代理方式已失效

错误日志

2023-09-01 14:53:21,970 P[107992] [MainThread 98960] Error code 404 | Client Error: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /api/v1/data</pre>
</body>
</html>

2023-09-01 14:53:21,972 P[107992] [MainThread 98960] HTTP request failed: EikonError-Client Error: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /api/v1/data</pre>
</body>
</html>

Traceback (most recent call last):
  File "C:\Users\...\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\eikon\json_requests.py", line 127, in send_json_request
    _raise_for_status(response)
  File "C:\Users\...\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\eikon\json_requests.py", line 271, in _raise_for_status
    raise EikonError(response.status_code, error_msg)
eikon.eikonError.EikonError: Error code 404 | Client Error: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /api/v1/data</pre>
</body>
</html>


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\niekm\Dropbox\Personal\Coding\python\Django\stockManager\stockmanager\test.py", line 18, in <module>
    df, err = ek.get_news_headlines('R:LHAG.DE', date_from='2019-03-06T09:00:00', date_to='2019-03-06T18:00:00')#ek.get_data(instruments=[symbol], fields=fields)
  File "C:\Users\niekm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\eikon\news_request.py", line 121, in get_news_headlines
    result = eikon.json_requests.send_json_request(News_Headlines_UDF_endpoint, payload, debug=debug)
  File "C:\Users\niekm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\eikon\json_requests.py", line 134, in send_json_request
    raise EikonError(eikon_err.code, eikon_err.message)
eikon.eikonError.EikonError: Error code 404 | Client Error: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /api/v1/data</pre>
</body>
</html>

测试代码

import eikon as ek

ek.set_app_key("XXX")

# Make API request
df, err = ek.get_news_headlines('R:LHAG.DE', date_from='2019-03-06T09:00:00', date_to='2019-03-06T18:00:00')

if err: print("Error:", err)
else: print("Data:", df)

预期结果

返回LHAG.DE的新闻标题,但请求失败。


解决方案
  • 确认API端点适配性
    Eikon财富管理版本的API端点与标准版存在差异,/api/v1/data并非该版本的有效新闻接口端点。需查阅财富管理版专属API文档,确认新闻标题接口的正确调用路径。

  • 检查App Key权限
    验证你的App Key已被授权访问新闻类API,且关联的Eikon账户拥有财富管理版的对应数据权限。可通过Refinitiv开发者后台查看App Key的权限配置。

  • 更新Eikon Python库
    旧版本库可能未适配财富管理版的API变更,执行命令更新至最新版:

    pip install --upgrade eikon
    
  • 调整网络与代理设置
    确认当前网络可正常访问Refinitiv服务器,若需新代理,在代码中添加配置:

    ek.set_proxy(proxy_host="你的代理地址", proxy_port=代理端口)
    
  • 校验Instrument格式
    检查R:LHAG.DE是否符合财富管理版的Instrument编码规范,部分版本可能要求不同的前缀或格式。


内容的提问来源于stack exchange,提问作者Niek H.M

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 18:44:51