{"id":15639,"date":"2021-05-18T00:54:32","date_gmt":"2021-05-17T16:54:32","guid":{"rendered":"https:\/\/www.tejwin.com\/?post_type=insight&#038;p=15639"},"modified":"2023-08-04T10:49:40","modified_gmt":"2023-08-04T02:49:40","slug":"tej-api-document","status":"publish","type":"insight","link":"https:\/\/www.tejwin.com\/en\/insight\/tej-api-document\/","title":{"rendered":"TEJ API Document"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"620\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/\/image-229-1024x620.png\" alt=\"\" class=\"wp-image-15640\" srcset=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/image-229-1024x620.png 1024w, https:\/\/www.tejwin.com\/wp-content\/uploads\/image-229-300x182.png 300w, https:\/\/www.tejwin.com\/wp-content\/uploads\/image-229-150x91.png 150w, https:\/\/www.tejwin.com\/wp-content\/uploads\/image-229-768x465.png 768w, https:\/\/www.tejwin.com\/wp-content\/uploads\/image-229.png 1400w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Using the document to have a deeper understanding of TEJ API.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"f4ca\">After previous financial data applications we have introduced to you, we have received some messages about how to use the API properly. Therefore, to make users use our TEJ API more comfortably,&nbsp;<strong>we will spend one to two weeks to make a clear description of our Document before we continue to introduce more applications.<\/strong>&nbsp;If you feel that this week\u2019s topic is easier for you, you could go back and review the previous articles!<\/p>\n<\/blockquote>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_81 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69f2ac2604cbc\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69f2ac2604cbc\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.tejwin.com\/en\/insight\/tej-api-document\/#Highlights_of_this_article\" >Highlights of this article<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.tejwin.com\/en\/insight\/tej-api-document\/#Links_related_to_this_article\" >Links related to this article<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.tejwin.com\/en\/insight\/tej-api-document\/#API_KEY_ApplyBuy\" >API KEY Apply\/Buy<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.tejwin.com\/en\/insight\/tej-api-document\/#Parameters_IntroductionApplication\" >Parameters Introduction\/Application<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.tejwin.com\/en\/insight\/tej-api-document\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.tejwin.com\/en\/insight\/tej-api-document\/#Links_related_to_this_article_again\" >Links related to this article again!<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"01ba\"><span class=\"ez-toc-section\" id=\"Highlights_of_this_article\"><\/span><strong>Highlights of this article <\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>TEJ API KEY Apply\/Buy<\/strong><\/li>\n\n\n\n<li><strong>Parameters Introduction<\/strong><\/li>\n\n\n\n<li><strong>Data Collection<\/strong><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"be45\"><span class=\"ez-toc-section\" id=\"Links_related_to_this_article\"><\/span><strong>Links related to this article<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>1\ufe0f\u20e3 API Official Website:&nbsp;<\/strong><a href=\"https:\/\/api.tej.com.tw\/\" rel=\"noreferrer noopener\" target=\"_blank\"><strong>TEJ API Official Website<\/strong><\/a><\/li>\n\n\n\n<li><strong>2\ufe0f\u20e3 The Product Package:&nbsp;<\/strong><a href=\"https:\/\/eshop.tej.com.tw\/E-Shop\/Edata_caseIntro\/1\" rel=\"noreferrer noopener\" target=\"_blank\"><strong>TEJ E SHOP<\/strong><\/a><\/li>\n\n\n\n<li><strong>3\ufe0f\u20e3 Source Code:&nbsp;<\/strong><a href=\"https:\/\/github.com\/tejtw\/TEJAPI_Python_Medium_Rookies\" rel=\"noreferrer noopener\" target=\"_blank\"><strong>TEJ GITHUB<\/strong><\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"de04\"><span class=\"ez-toc-section\" id=\"API_KEY_ApplyBuy\"><\/span><strong>API KEY Apply\/Buy<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"a50f\">Before using our TEJ API, if you don\u2019t have an API KEY, you can get it through the trial application in the link or directly buy the product package in the E-Shop, as the picture below:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter caption-align-center\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1_1LxvvWnnFKM0wzHUpSO7gSA.png\" alt=\"\"\/><figcaption class=\"wp-element-caption\"><strong>Process of the trial API KEY application<\/strong><\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image caption-align-center\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1_13U4bjUvzMv8AU4xeozc-1Q.png\" alt=\"\"\/><figcaption class=\"wp-element-caption\"><strong>Webpage of TEJ E-Shop<\/strong><\/figcaption><\/figure>\n\n\n\n<p id=\"021f\">After having the API KEY, we can use our TEJ huge database to collect the data!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"43ce\"><span class=\"ez-toc-section\" id=\"Parameters_IntroductionApplication\"><\/span><strong>Parameters Introduction\/Application<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"e46f\">We could use this function to&nbsp;<strong>know the permission and the information of this API KEY.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tejapi.ApiConfig.info()<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter caption-align-center\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1p22nG7hNhtWVs9-8Jozi6Q.png\" alt=\"\"\/><figcaption class=\"wp-element-caption\"><strong>KEY Information<\/strong><\/figcaption><\/figure>\n\n\n\n<p id=\"e196\">The other function is to use the time field to determine whether to display the time zone. In order to keep the result clean, you can choose not to display the time zone. The difference we can see from the picture below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tejapi.ApiConfig.ignoretz = True<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter caption-align-center\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1rAref695-Pe2SeaKfpec2Q.png\" alt=\"\"\/><figcaption class=\"wp-element-caption\"><strong>Time zone ignore\uff1aYes\uff08Left\uff09\/ No\uff08Right\uff09<\/strong><\/figcaption><\/figure>\n\n\n\n<p id=\"ee60\">After understanding these parameters and setting them up, you can collect the data. Next, I will mainly introduce the trading data as our example.<\/p>\n\n\n\n<p id=\"f736\"><strong>1\ufe0f\u20e3. Finding the code name of the database.<\/strong><\/p>\n\n\n\n<p id=\"a0e0\">You can search the code through<strong>&nbsp;TEJ API official website&gt; database list in the upper right corner&gt; query by region&gt; Taiwan Database<\/strong>&nbsp;to find the database we want to use (TWN\/APRCD). The database web interface is as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter caption-align-center\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/167e81j4CJtDZK3XjsI2llw.png\" alt=\"\"\/><figcaption class=\"wp-element-caption\"><strong>Database Webpage<\/strong><\/figcaption><\/figure>\n\n\n\n<p id=\"b15a\"><strong>2\ufe0f\u20e3. Data Collection<\/strong><\/p>\n\n\n\n<p id=\"b49f\">We can get the data through TEJ API data<strong>&nbsp;by only one line of code<\/strong>&nbsp;with different parameters according to user needs, for example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tejapi.get('TWN\/APRCD',coid='Y9999')<\/code><\/pre>\n\n\n\n<p>This line of code is to get the&nbsp;<strong>OHLC data of Taiwan stock market Y9999 and other related trading data from our database.<\/strong>&nbsp;If we want to increase the filter field or time, we can use the parameters shown below&nbsp;<strong>to represent the selection of the specific field and the time range.&nbsp;<\/strong>The corresponding parameters are described in the following figure:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tejapi.get('TWN\/APRCD',opts={'columns':&#91;'mdate','open_d']})\ntejapi.get('TWN\/APRCD',coid='Y9999', \n     mdate={'gt':'2018-01-01','lt':'2018-02-01'})<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1EPi8bEmFEd3fZUhvrPxkkQ.png\" alt=\"\"\/><figcaption class=\"wp-element-caption\"><strong>Parameters\u2019 Description<\/strong><\/figcaption><\/figure>\n\n\n\n<p id=\"fec2\">Therefore, if we want our data to only display the OHLC and the data from 2019 to 2021, the code and data will be presented as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tejapi.get('TWN\/APRCD',coid='Y9999', \n           opts={'columns':&#91;'mdate','open_d', 'high_d', 'low_d', 'close_d']}, \n           mdate={'gt':'2019-01-01'})<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1Z_QiP4OWR3fCiO-VzTeXfw.png\" alt=\"\"\/><figcaption class=\"wp-element-caption\"><strong>OHLC data<\/strong><\/figcaption><\/figure>\n\n\n\n<p id=\"7518\"><strong>3\ufe0f\u20e3. Table Information<\/strong><\/p>\n\n\n\n<p id=\"0d8f\">If you don\u2019t know what information of table contains before using it, you can use this function to query the database information.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tejapi.table_info('TWN\/APRCD')<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/189o9tBI-fdF4yeGzLGoECg.png\" alt=\"\"\/><figcaption class=\"wp-element-caption\"><strong>Table\u2019s information<\/strong><\/figcaption><\/figure>\n\n\n\n<p id=\"c0b5\"><strong>4\ufe0f\u20e3. Table Search<\/strong><\/p>\n\n\n\n<p id=\"34bf\">Last, among all the TEJ databases, if you only know some keywords, then you can use this function to search for databases containing \u201cspecific keywords\u201d in all databases.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tejapi.search_table(\"\u672a\u8abf\u6574\u80a1\u50f9(\u65e5)\")<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter caption-align-center\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1_1A43FuCBFG9BxDrJRPIe8Bg.jpg\" alt=\"\"\/><figcaption class=\"wp-element-caption\"><strong>Table Search<\/strong><\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"c077\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"78e3\">The content today is for everyone to have a deeper knowledge and understanding of our TEJ API. It is easier to understand, but through the codes, we can understand that<strong>&nbsp;these built-in functions could help users to get the data they want from the TEJ\u2019s huge database more conveniently.<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"7c72\"><span class=\"ez-toc-section\" id=\"Links_related_to_this_article_again\"><\/span>Links related to this article again!<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>1\ufe0f\u20e3 API Official Website:&nbsp;<\/strong><a href=\"https:\/\/api.tej.com.tw\/\" rel=\"noreferrer noopener\" target=\"_blank\"><strong>TEJ API Official Website<\/strong><\/a><\/li>\n\n\n\n<li><strong>2\ufe0f\u20e3 The Product Package:&nbsp;<\/strong><a href=\"https:\/\/eshop.tej.com.tw\/E-Shop\/Edata_caseIntro\/1\" rel=\"noreferrer noopener\" target=\"_blank\"><strong>TEJ E-SHOP<\/strong><\/a><\/li>\n\n\n\n<li><strong>3\ufe0f\u20e3 Source Code:&nbsp;<\/strong><a href=\"https:\/\/github.com\/tejtw\/TEJAPI_Python_Medium_Rookies\" rel=\"noreferrer noopener\" target=\"_blank\"><strong>TEJ GITHUB<\/strong><\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Using the document to have a deeper understanding of TEJ API. After previous financial data applications we have introduced to you, we have received some messages about how to use the API properly. Therefore, to make users use our TEJ API more comfortably,&nbsp;we will spend one to two weeks to make a clear description of [&hellip;]<\/p>\n","protected":false},"featured_media":15640,"template":"","tags":[2904,2371,3006],"insight-category":[690,50],"class_list":["post-15639","insight","type-insight","status-publish","has-post-thumbnail","hentry","tag-beginners-guide","tag-python","tag-tejapi-beginners-guide","insight-category-data-analysis","insight-category-fintech"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight\/15639","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight"}],"about":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/types\/insight"}],"version-history":[{"count":0,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight\/15639\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/media\/15640"}],"wp:attachment":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/media?parent=15639"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/tags?post=15639"},{"taxonomy":"insight-category","embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight-category?post=15639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}