TEJ API Document

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, we will spend one to two weeks to make a clear description of our Document before we continue to introduce more applications. If you feel that this week’s topic is easier for you, you could go back and review the previous articles!

Highlights of this article

  • TEJ API KEY Apply/Buy
  • Parameters Introduction
  • Data Collection

Links related to this article

API KEY Apply/Buy

Before using our TEJ API, if you don’t 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:

Process of the trial API KEY application
Webpage of TEJ E-Shop

After having the API KEY, we can use our TEJ huge database to collect the data!

Parameters Introduction/Application

We could use this function to know the permission and the information of this API KEY.

tejapi.ApiConfig.info()
KEY Information

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:

tejapi.ApiConfig.ignoretz = True
Time zone ignore:Yes(Left)/ No(Right)

After understanding these parameters and setting them up, you can collect the data. Next, I will mainly introduce the trading data as our example.

1️⃣. Finding the code name of the database.

You can search the code through TEJ API official website> database list in the upper right corner> query by region> Taiwan Database to find the database we want to use (TWN/APRCD). The database web interface is as follows:

Database Webpage

2️⃣. Data Collection

We can get the data through TEJ API data by only one line of code with different parameters according to user needs, for example:

tejapi.get('TWN/APRCD',coid='Y9999')

This line of code is to get the OHLC data of Taiwan stock market Y9999 and other related trading data from our database. If we want to increase the filter field or time, we can use the parameters shown below to represent the selection of the specific field and the time range. The corresponding parameters are described in the following figure:

tejapi.get('TWN/APRCD',opts={'columns':['mdate','open_d']})
tejapi.get('TWN/APRCD',coid='Y9999', 
     mdate={'gt':'2018-01-01','lt':'2018-02-01'})
Parameters’ Description

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:

tejapi.get('TWN/APRCD',coid='Y9999', 
           opts={'columns':['mdate','open_d', 'high_d', 'low_d', 'close_d']}, 
           mdate={'gt':'2019-01-01'})
OHLC data

3️⃣. Table Information

If you don’t know what information of table contains before using it, you can use this function to query the database information.

tejapi.table_info('TWN/APRCD')
Table’s information

4️⃣. Table Search

Last, among all the TEJ databases, if you only know some keywords, then you can use this function to search for databases containing “specific keywords” in all databases.

tejapi.search_table("未調整股價(日)")
Table Search

Conclusion

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 these built-in functions could help users to get the data they want from the TEJ’s huge database more conveniently.

Links related to this article again!

Back
Procesing