{"id":2798,"date":"2021-05-18T00:54:32","date_gmt":"2021-05-18T00:54:32","guid":{"rendered":"https:\/\/www.tejwin.com\/en\/insights\/tej-api-document\/"},"modified":"2021-05-18T00:54:32","modified_gmt":"2021-05-18T00:54:32","slug":"tej-api-document","status":"publish","type":"insight","link":"https:\/\/www.tejwin.com\/en\/insights\/tej-api-document\/","title":{"rendered":"TEJ API Document"},"content":{"rendered":"<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"wp-image-15640\" height=\"620\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/image-229.png\" width=\"1024\"\/><\/figure>\n<p class=\"wp-block-paragraph\">Using the document to have a deeper understanding of TEJ API.<\/p>\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\" 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,\u00a0<strong>we will spend one to two weeks to make a clear description of our Document before we continue to introduce more applications.<\/strong>\u00a0If you feel that this week\u2019s topic is easier for you, you could go back and review the previous articles!<\/p>\n<\/blockquote>\n<h2 class=\"wp-block-heading\" id=\"01ba\"><strong>Highlights of this article <\/strong><\/h2>\n<ul class=\"wp-block-list\">\n<li><strong>TEJ API KEY Apply\/Buy<\/strong><\/li>\n<li><strong>Parameters Introduction<\/strong><\/li>\n<li><strong>Data Collection<\/strong><\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\" id=\"be45\"><strong>Links related to this article<\/strong><\/h2>\n<ul class=\"wp-block-list\">\n<li><strong>1\ufe0f\u20e3 API Official Website:\u00a0<\/strong><a href=\"https:\/\/api.tej.com.tw\/\" rel=\"noreferrer noopener\" target=\"_blank\"><strong>TEJ API Official Website<\/strong><\/a><\/li>\n<li><strong>2\ufe0f\u20e3 The Product Package:\u00a0<\/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<li><strong>3\ufe0f\u20e3 Source Code:\u00a0<\/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<h2 class=\"wp-block-heading\" id=\"de04\"><strong>API KEY Apply\/Buy<\/strong><\/h2>\n<p class=\"wp-block-paragraph\" 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<figure class=\"wp-block-image aligncenter caption-align-center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1_1LxvvWnnFKM0wzHUpSO7gSA.png\"\/><figcaption class=\"wp-element-caption\"><strong>Process of the trial API KEY application<\/strong><\/figcaption><\/figure>\n<figure class=\"wp-block-image caption-align-center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1_13U4bjUvzMv8AU4xeozc-1Q.png\"\/><figcaption class=\"wp-element-caption\"><strong>Webpage of TEJ E-Shop<\/strong><\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\" id=\"021f\">After having the API KEY, we can use our TEJ huge database to collect the data!<\/p>\n<h2 class=\"wp-block-heading\" id=\"43ce\"><strong>Parameters Introduction\/Application<\/strong><\/h2>\n<p class=\"wp-block-paragraph\" id=\"e46f\">We could use this function to\u00a0<strong>know the permission and the information of this API KEY.<\/strong><\/p>\n<pre class=\"wp-block-code\"><code>tejapi.ApiConfig.info()<\/code><\/pre>\n<figure class=\"wp-block-image aligncenter caption-align-center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1p22nG7hNhtWVs9-8Jozi6Q.png\"\/><figcaption class=\"wp-element-caption\"><strong>KEY Information<\/strong><\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\" 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<pre class=\"wp-block-code\"><code>tejapi.ApiConfig.ignoretz = True<\/code><\/pre>\n<figure class=\"wp-block-image aligncenter caption-align-center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1rAref695-Pe2SeaKfpec2Q.png\"\/><figcaption class=\"wp-element-caption\"><strong>Time zone ignore\uff1aYes\uff08Left\uff09\/ No\uff08Right\uff09<\/strong><\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\" 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<p class=\"wp-block-paragraph\" id=\"f736\"><strong>1\ufe0f\u20e3. Finding the code name of the database.<\/strong><\/p>\n<p class=\"wp-block-paragraph\" id=\"a0e0\">You can search the code through<strong>\u00a0TEJ API official website&gt; database list in the upper right corner&gt; query by region&gt; Taiwan Database<\/strong>\u00a0to find the database we want to use (TWN\/APRCD). The database web interface is as follows:<\/p>\n<figure class=\"wp-block-image aligncenter caption-align-center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/167e81j4CJtDZK3XjsI2llw.png\"\/><figcaption class=\"wp-element-caption\"><strong>Database Webpage<\/strong><\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\" id=\"b15a\"><strong>2\ufe0f\u20e3. Data Collection<\/strong><\/p>\n<p class=\"wp-block-paragraph\" id=\"b49f\">We can get the data through TEJ API data<strong>\u00a0by only one line of code<\/strong>\u00a0with different parameters according to user needs, for example:<\/p>\n<pre class=\"wp-block-code\"><code>tejapi.get('TWN\/APRCD',coid='Y9999')<\/code><\/pre>\n<p class=\"wp-block-paragraph\">This line of code is to get the\u00a0<strong>OHLC data of Taiwan stock market Y9999 and other related trading data from our database.<\/strong>\u00a0If we want to increase the filter field or time, we can use the parameters shown below\u00a0<strong>to represent the selection of the specific field and the time range.\u00a0<\/strong>The corresponding parameters are described in the following figure:<\/p>\n<pre class=\"wp-block-code\"><code>tejapi.get('TWN\/APRCD',opts={'columns':['mdate','open_d']})\ntejapi.get('TWN\/APRCD',coid='Y9999', \n     mdate={'gt':'2018-01-01','lt':'2018-02-01'})<\/code><\/pre>\n<figure class=\"wp-block-image\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1EPi8bEmFEd3fZUhvrPxkkQ.png\"\/><figcaption class=\"wp-element-caption\"><strong>Parameters\u2019 Description<\/strong><\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\" 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<pre class=\"wp-block-code\"><code>tejapi.get('TWN\/APRCD',coid='Y9999', \n           opts={'columns':['mdate','open_d', 'high_d', 'low_d', 'close_d']}, \n           mdate={'gt':'2019-01-01'})<\/code><\/pre>\n<figure class=\"wp-block-image\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1Z_QiP4OWR3fCiO-VzTeXfw.png\"\/><figcaption class=\"wp-element-caption\"><strong>OHLC data<\/strong><\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\" id=\"7518\"><strong>3\ufe0f\u20e3. Table Information<\/strong><\/p>\n<p class=\"wp-block-paragraph\" 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<pre class=\"wp-block-code\"><code>tejapi.table_info('TWN\/APRCD')<\/code><\/pre>\n<figure class=\"wp-block-image\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/189o9tBI-fdF4yeGzLGoECg.png\"\/><figcaption class=\"wp-element-caption\"><strong>Table\u2019s information<\/strong><\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\" id=\"c0b5\"><strong>4\ufe0f\u20e3. Table Search<\/strong><\/p>\n<p class=\"wp-block-paragraph\" 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<pre class=\"wp-block-code\"><code>tejapi.search_table(\"\u672a\u8abf\u6574\u80a1\u50f9(\u65e5)\")<\/code><\/pre>\n<figure class=\"wp-block-image aligncenter caption-align-center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1_1A43FuCBFG9BxDrJRPIe8Bg.jpg\"\/><figcaption class=\"wp-element-caption\"><strong>Table Search<\/strong><\/figcaption><\/figure>\n<h2 class=\"wp-block-heading\" id=\"c077\">Conclusion<\/h2>\n<p class=\"wp-block-paragraph\" 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>\u00a0these built-in functions could help users to get the data they want from the TEJ\u2019s huge database more conveniently.<\/strong><\/p>\n<h2 class=\"wp-block-heading\" id=\"7c72\">Links related to this article again!<\/h2>\n<ul class=\"wp-block-list\">\n<li><strong>1\ufe0f\u20e3 API Official Website:\u00a0<\/strong><a href=\"https:\/\/api.tej.com.tw\/\" rel=\"noreferrer noopener\" target=\"_blank\"><strong>TEJ API Official Website<\/strong><\/a><\/li>\n<li><strong>2\ufe0f\u20e3 The Product Package:\u00a0<\/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<li><strong>3\ufe0f\u20e3 Source Code:\u00a0<\/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,\u00a0we will spend one to two weeks to make a clear description of [\u2026]<\/p>\n","protected":false},"featured_media":2797,"template":"","tags":[65,70],"insight_category":[16],"class_list":["post-2798","insight","type-insight","status-publish","has-post-thumbnail","hentry","tag-python","tag-tej-api","insight_category-quant-data-science"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight\/2798","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"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/media\/2797"}],"wp:attachment":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/media?parent=2798"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/tags?post=2798"},{"taxonomy":"insight_category","embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight_category?post=2798"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}