Python Eikon Data API 503 error

Hi, I'm having some trouble with using Eikon Data API, I've just followed https://developers.refinitiv.com/en/article-catalog/article/eikon-data-api-python-troubleshooting-refinitiv to find where is the problem, but still cannot resolve yet.

Basically, I want to try the following python command

import eikon as ek
ek.set_log_level(1)
ek.set_app_key("key")
print(ek.__version__)
data = ek.get_timeseries('AAPL.O', # the RIC for Apple, Inc.
fields='*', # all fields
start_date='2023-01-01', # start date
end_date='2023-07-01') # end date

But I'm having this log at the `ek.set_app_key("key")` line

[2023-08-03 10:41:22,642;s] - [INFO] - [log] - Send GET request to http://127.0.0.1:9000/api/status to detect API Proxy...

[2023-08-03 10:41:22,642;s] - [DEBUG] - [log] - Request to http://127.0.0.1:9000/api/status

headers = {'x-tr-applicationid': 'key'}

params = None

[2023-08-03 10:41:22,648;s] - [Level 1] - [log] - Send request with headers [(b'Host', b'127.0.0.1:9000'), (b'Accept-Encoding', b'gzip, deflate'), (b'Connection', b'keep-alive'), (b'User-Agent', b'python-httpx/0.24.1'), (b'Accept', b'application/json'), (b'x-tr-applicationid', key')] and cookies None

[2023-08-03 10:41:22,650;s] - [Level 1] - [log] - HTTP request response 503:

<html><head>

Funny thing is if I try the following code, it works

import requests

requests.get("http://127.0.0.1:9000/api/status")

with 200 response


Can you help me use Eikon DATA API?


my python eikon package version is 1.1.17 and running REFINITIV WORKSPACE version is DESKTOP 1.22.303 (or running REFINITIV EIKON version is Desktop 4.0.62(4.0.62015)


Best Answer

  • Jirapongse
    Jirapongse admin
    Answer ✓

    @minkyu.han

    It may relate to the proxy (squid).1691055370996.png

    You may try to set the NO_PROXY environment variable, as mentioned in this discussion.

    import os
    os.environ['NO_PROXY'] = 'localhost'
    os.environ['NO_PROXY'] = '127.0.0.1'

Answers

  • @minkyu.han

    Thank you for reaching out to us.

    Please share the full HTML content retrieved in the response.

    1691050200970.png

    We may see something in this HTML.

  • <html><head>

    <meta type="copyright" content="Copyright (C) 1996-2016 The Squid Software Foundation and contributors">

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <title>ERROR: The requested URL could not be retrieved</title>

    <style type="text/css"><!--

    /*

    * Copyright (C) 1996-2016 The Squid Software Foundation and contributors

    *

    * Squid software is distributed under GPLv2+ license and includes

    * contributions from numerous individuals and organizations.

    * Please see the COPYING and CONTRIBUTORS files for details.

    */


    /*

    Stylesheet for Squid Error pages

    Adapted from design by Free CSS Templates

    http://www.freecsstemplates.org

    Released for free under a Creative Commons Attribution 2.5 License

    */


    /* Page basics */

    * {

    font-family: verdana, sans-serif;

    }


    html body {

    margin: 0;

    padding: 0;

    background: #efefef;

    font-size: 12px;

    color: #1e1e1e;

    }


    /* Page displayed title area */

    #titles {

    margin-left: 15px;

    padding: 10px;

    padding-left: 100px;

    background: url('/squid-internal-static/icons/SN.png') no-repeat left;

    }


    /* initial title */

    #titles h1 {

    color: #000000;

    }

    #titles h2 {

    color: #000000;

    }


    /* special event: FTP success page titles */

    #titles ftpsuccess {

    background-color:#00ff00;

    width:100%;

    }


    /* Page displayed body content area */

    #content {

    padding: 10px;

    background: #ffffff;

    }


    /* General text */

    p {

    }


    /* error brief description */

    #error p {

    }


    /* some data which may have caused the problem */

    #data {

    }


    /* the error message received from the system or other software */

    #sysmsg {

    }


    pre {

    font-family:sans-serif;

    }


    /* special event: FTP / Gopher directory listing */

    #dirmsg {

    font-family: courier;

    color: black;

    font-size: 10pt;

    }

    #dirlisting {

    margin-left: 2%;

    margin-right: 2%;

    }

    #dirlisting tr.entry td.icon,td.filename,td.size,td.date {

    border-bottom: groove;

    }

    #dirlisting td.size {

    width: 50px;

    text-align: right;

    padding-right: 5px;

    }


    /* horizontal lines */

    hr {

    margin: 0;

    }


    /* page displayed footer area */

    #footer {

    font-size: 9px;

    padding-left: 10px;

    }



    body

    :lang(fa) { direction: rtl; font-size: 100%; font-family: Tahoma, Roya, sans-serif; float: right; }

    :lang(he) { direction: rtl; }

    --></style>

    </head><body id="ERR_CONNECT_FAIL">

    <div id="titles">

    <h1>ERROR</h1>

    <h2>The requested URL could not be retrieved</h2>

    </div>

    <hr>


    <div id="content">

    <p>The following error was encountered while trying to retrieve the URL: <a href="http://127.0.0.1:9000/api/status">http://127.0.0.1:9000/api/status&lt;/a></p>


    <blockquote id="error">

    <p><b>Connection to 127.0.0.1 failed.</b></p>

    </blockquote>


    <p id="sysmsg">The system returned: <i>(111) Connection refused</i></p>


    <p>The remote host or network may be down. Please try the request again.</p>


    <p>Your cache administrator is <a href="mailto:COMPANY_MAIL?subject=CacheErrorInfo%20-%20ERR_CONNECT_FAIL&amp;body=CacheHost%3A%20AEOFFVMPROXY01%0D%0AErrPage%3A%20ERR_CONNECT_FAIL%0D%0AErr%3A%20(111)%20Connection%20refused%0D%0ATimeStamp%3A%20Thu,%2003%20Aug%202023%2006%3A41%3A22%20GMT%0D%0A%0D%0AClientIP%3A%2010.97.120.4%0D%0AServerIP%3A%20127.0.0.1%0D%0A%0D%0AHTTP%20Request%3A%0D%0AGET%20%2Fapi%2Fstatus%20HTTP%2F1.1%0AAccept-Encoding%3A%20gzip,%20deflate%0D%0AConnection%3A%20keep-alive%0D%0AUser-Agent%3A%20python-httpx%2F0.24.1%0D%0AAccept%3A%20application%2Fjson%0D%0Ax-tr-applicationid%3A%20f261cd8230cf4bf69684d93bd18571d6f8dac89d%0D%0AHost%3A%20127.0.0.1%3A9000%0D%0A%0D%0A%0D%0A">COMPANY_MAIL</a>.</p>


    <br>

    </div>


    <hr>

    <div id="footer">

    <p>Generated Thu, 03 Aug 2023 06:41:22 GMT by COMPANY_MACINHE (squid/5.7-20221209-r9d0b81efb)</p>

    <!-- ERR_CONNECT_FAIL -->

    </div>

    </body></html>


    I'm working behind our company firewall and using company-wise proxy server also. Should we allow some connection to use it? If so, can I get some ip or any information we need to allow connection?


    BTW, then how the following works?



    import requests requests.get("http://127.0.0.1:9000/api/status")

    with 200 response


  • <html><head>

    <meta type="copyright" content="Copyright (C) 1996-2016 The Squid Software Foundation and contributors">

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <title>ERROR: The requested URL could not be retrieved</title>

    <style type="text/css"><!--

    /*

    * Copyright (C) 1996-2016 The Squid Software Foundation and contributors

    *

    * Squid software is distributed under GPLv2+ license and includes

    * contributions from numerous individuals and organizations.

    * Please see the COPYING and CONTRIBUTORS files for details.

    */


    /*

    Stylesheet for Squid Error pages

    Adapted from design by Free CSS Templates

    http://www.freecsstemplates.org

    Released for free under a Creative Commons Attribution 2.5 License

    */


    /* Page basics */

    * {

    font-family: verdana, sans-serif;

    }


    html body {

    margin: 0;

    padding: 0;

    background: #efefef;

    font-size: 12px;

    color: #1e1e1e;

    }


    /* Page displayed title area */

    #titles {

    margin-left: 15px;

    padding: 10px;

    padding-left: 100px;

    background: url('/squid-internal-static/icons/SN.png') no-repeat left;

    }


    /* initial title */

    #titles h1 {

    color: #000000;

    }

    #titles h2 {

    color: #000000;

    }


    /* special event: FTP success page titles */

    #titles ftpsuccess {

    background-color:#00ff00;

    width:100%;

    }


    /* Page displayed body content area */

    #content {

    padding: 10px;

    background: #ffffff;

    }


    /* General text */

    p {

    }


    /* error brief description */

    #error p {

    }


    /* some data which may have caused the problem */

    #data {

    }


    /* the error message received from the system or other software */

    #sysmsg {

    }


    pre {

    font-family:sans-serif;

    }


    /* special event: FTP / Gopher directory listing */

    #dirmsg {

    font-family: courier;

    color: black;

    font-size: 10pt;

    }

    #dirlisting {

    margin-left: 2%;

    margin-right: 2%;

    }

    #dirlisting tr.entry td.icon,td.filename,td.size,td.date {

    border-bottom: groove;

    }

    #dirlisting td.size {

    width: 50px;

    text-align: right;

    padding-right: 5px;

    }


    /* horizontal lines */

    hr {

    margin: 0;

    }


    /* page displayed footer area */

    #footer {

    font-size: 9px;

    padding-left: 10px;

    }



    body

    :lang(fa) { direction: rtl; font-size: 100%; font-family: Tahoma, Roya, sans-serif; float: right; }

    :lang(he) { direction: rtl; }

    --></style>

    </head><body id="ERR_CONNECT_FAIL">

    <div id="titles">

    <h1>ERROR</h1>

    <h2>The requested URL could not be retrieved</h2>

    </div>

    <hr>


    <div id="content">

    <p>The following error was encountered while trying to retrieve the URL: <a href="http://127.0.0.1:9000/api/status">http://127.0.0.1:9000/api/status&lt;/a></p>


    <blockquote id="error">

    <p><b>Connection to 127.0.0.1 failed.</b></p>

    </blockquote>


    <p id="sysmsg">The system returned: <i>(111) Connection refused</i></p>


    <p>The remote host or network may be down. Please try the request again.</p>


    <p>Your cache administrator is <a href="mailto:COMPANY_MAIL?subject=CacheErrorInfo%20-%20ERR_CONNECT_FAIL&amp;body=CacheHost%3A%20AEOFFVMPROXY01%0D%0AErrPage%3A%20ERR_CONNECT_FAIL%0D%0AErr%3A%20(111)%20Connection%20refused%0D%0ATimeStamp%3A%20Thu,%2003%20Aug%202023%2006%3A41%3A22%20GMT%0D%0A%0D%0AClientIP%3A%2010.97.120.4%0D%0AServerIP%3A%20127.0.0.1%0D%0A%0D%0AHTTP%20Request%3A%0D%0AGET%20%2Fapi%2Fstatus%20HTTP%2F1.1%0AAccept-Encoding%3A%20gzip,%20deflate%0D%0AConnection%3A%20keep-alive%0D%0AUser-Agent%3A%20python-httpx%2F0.24.1%0D%0AAccept%3A%20application%2Fjson%0D%0Ax-tr-applicationid%3A%20f261cd8230cf4bf69684d93bd18571d6f8dac89d%0D%0AHost%3A%20127.0.0.1%3A9000%0D%0A%0D%0A%0D%0A">COMPANY_MAIL</a>.</p>


    <br>

    </div>


    <hr>

    <div id="footer">

    <p>Generated Thu, 03 Aug 2023 06:41:22 GMT by COMPANY_MACINHE (squid/5.7-20221209-r9d0b81efb)</p>

    <!-- ERR_CONNECT_FAIL -->

    </div>

    </body></html>


    I'm working behind our company firewall and using company-wise proxy server also. Should we allow some connection to use it? If so, can I get some ip or any information we need to allow connection?


    BTW, then how the following works?



    import requests requests.get("http://127.0.0.1:9000/api/status")

    with 200 response


  • </head><body id="ERR_CONNECT_FAIL">

    <div id="titles">

    <h1>ERROR</h1>

    <h2>The requested URL could not be retrieved</h2>

    </div>

    <hr>


    <div id="content">

    <p>The following error was encountered while trying to retrieve the URL: <a href="http://127.0.0.1:9000/api/status">http://127.0.0.1:9000/api/status&lt;/a></p>


    <blockquote id="error">

    <p><b>Connection to 127.0.0.1 failed.</b></p>

    </blockquote>


    <p id="sysmsg">The system returned: <i>(111) Connection refused</i></p>


    <p>The remote host or network may be down. Please try the request again.</p>


    <p>Your cache administrator is <a href="mailto:COMPANY_MAIL?subject=CacheErrorInfo%20-%20ERR_CONNECT_FAIL&amp;body=CacheHost%3A%20AEOFFVMPROXY01%0D%0AErrPage%3A%20ERR_CONNECT_FAIL%0D%0AErr%3A%20(111)%20Connection%20refused%0D%0ATimeStamp%3A%20Thu,%2003%20Aug%202023%2006%3A41%3A22%20GMT%0D%0A%0D%0AClientIP%3A%2010.97.120.4%0D%0AServerIP%3A%20127.0.0.1%0D%0A%0D%0AHTTP%20Request%3A%0D%0AGET%20%2Fapi%2Fstatus%20HTTP%2F1.1%0AAccept-Encoding%3A%20gzip,%20deflate%0D%0AConnection%3A%20keep-alive%0D%0AUser-Agent%3A%20python-httpx%2F0.24.1%0D%0AAccept%3A%20application%2Fjson%0D%0Ax-tr-applicationid%3A%20f261cd8230cf4bf69684d93bd18571d6f8dac89d%0D%0AHost%3A%20127.0.0.1%3A9000%0D%0A%0D%0A%0D%0A">COMPANY_MAIL</a>.</p>


    <br>

    </div>


    <hr>

    <div id="footer">

    <p>Generated Thu, 03 Aug 2023 06:41:22 GMT by COMPANY_MACHINE (squid/5.7-20221209-r9d0b81efb)</p>

    <!-- ERR_CONNECT_FAIL -->

    </div>

    </body></html>


    I'm behind the company firewall and using company-wise proxy server together. Should my company allow some connection? If so, any ip or information which we should allow?


    Thanks

  • Thanks! It's working with that modification!
  • <html><head>

    <meta type="copyright" content="Copyright (C) 1996-2016 The Squid Software Foundation and contributors">

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <title>ERROR: The requested URL could not be retrieved</title>

    <style type="text/css"><!--

    /*

    * Copyright (C) 1996-2016 The Squid Software Foundation and contributors

    *

    * Squid software is distributed under GPLv2+ license and includes

    * contributions from numerous individuals and organizations.

    * Please see the COPYING and CONTRIBUTORS files for details.

    */


    /*

    Stylesheet for Squid Error pages

    Adapted from design by Free CSS Templates

    http://www.freecsstemplates.org

    Released for free under a Creative Commons Attribution 2.5 License

    */


    /* Page basics */

    * {

    font-family: verdana, sans-serif;

    }


    html body {

    margin: 0;

    padding: 0;

    background: #efefef;

    font-size: 12px;

    color: #1e1e1e;

    }


    /* Page displayed title area */

    #titles {

    margin-left: 15px;

    padding: 10px;

    padding-left: 100px;

    background: url('/squid-internal-static/icons/SN.png') no-repeat left;

    }


    /* initial title */

    #titles h1 {

    color: #000000;

    }

    #titles h2 {

    color: #000000;

    }


    /* special event: FTP success page titles */

    #titles ftpsuccess {

    background-color:#00ff00;

    width:100%;

    }


    /* Page displayed body content area */

    #content {

    padding: 10px;

    background: #ffffff;

    }


    /* General text */

    p {

    }


    /* error brief description */

    #error p {

    }


    /* some data which may have caused the problem */

    #data {

    }


    /* the error message received from the system or other software */

    #sysmsg {

    }


    pre {

    font-family:sans-serif;

    }


    /* special event: FTP / Gopher directory listing */

    #dirmsg {

    font-family: courier;

    color: black;

    font-size: 10pt;

    }

    #dirlisting {

    margin-left: 2%;

    margin-right: 2%;

    }

    #dirlisting tr.entry td.icon,td.filename,td.size,td.date {

    border-bottom: groove;

    }

    #dirlisting td.size {

    width: 50px;

    text-align: right;

    padding-right: 5px;

    }


    /* horizontal lines */

    hr {

    margin: 0;

    }


    /* page displayed footer area */

    #footer {

    font-size: 9px;

    padding-left: 10px;

    }



    body

    :lang(fa) { direction: rtl; font-size: 100%; font-family: Tahoma, Roya, sans-serif; float: right; }

    :lang(he) { direction: rtl; }

    --></style>

    </head><body id="ERR_CONNECT_FAIL">

    <div id="titles">

    <h1>ERROR</h1>

    <h2>The requested URL could not be retrieved</h2>

    </div>

    <hr>


    <div id="content">

    <p>The following error was encountered while trying to retrieve the URL: <a href="http://127.0.0.1:9000/api/status">http://127.0.0.1:9000/api/status&lt;/a></p>


    <blockquote id="error">

    <p><b>Connection to 127.0.0.1 failed.</b></p>

    </blockquote>


    <p id="sysmsg">The system returned: <i>(111) Connection refused</i></p>


    <p>The remote host or network may be down. Please try the request again.</p>


    <p>Your cache administrator is <a href="mailto:COMPANY_MAIL?subject=CacheErrorInfo%20-%20ERR_CONNECT_FAIL&amp;body=CacheHost%3A%20AEOFFVMPROXY01%0D%0AErrPage%3A%20ERR_CONNECT_FAIL%0D%0AErr%3A%20(111)%20Connection%20refused%0D%0ATimeStamp%3A%20Thu,%2003%20Aug%202023%2006%3A41%3A22%20GMT%0D%0A%0D%0AClientIP%3A%2010.97.120.4%0D%0AServerIP%3A%20127.0.0.1%0D%0A%0D%0AHTTP%20Request%3A%0D%0AGET%20%2Fapi%2Fstatus%20HTTP%2F1.1%0AAccept-Encoding%3A%20gzip,%20deflate%0D%0AConnection%3A%20keep-alive%0D%0AUser-Agent%3A%20python-httpx%2F0.24.1%0D%0AAccept%3A%20application%2Fjson%0D%0Ax-tr-applicationid%3A%20f261cd8230cf4bf69684d93bd18571d6f8dac89d%0D%0AHost%3A%20127.0.0.1%3A9000%0D%0A%0D%0A%0D%0A">COMPANY_MAIL</a>.</p>


    <br>

    </div>


    <hr>

    <div id="footer">

    <p>Generated Thu, 03 Aug 2023 06:41:22 GMT by COMPANY_MACINHE (squid/5.7-20221209-r9d0b81efb)</p>

    <!-- ERR_CONNECT_FAIL -->

    </div>

    </body></html>


    I'm working behind our company firewall and using company-wise proxy server also. Should we allow some connection to use it? If so, can I get some ip or any information we need to allow connection?


    BTW, then how the following works?



    import requests requests.get("http://127.0.0.1:9000/api/status")

    with 200 response