.NET API 說明文件

2019-10-14 更新

.NET

以下文件將說明如何使用Tejkyc.NET API來存取企業商務資料平台。

安裝方式

請使用安裝 Tejkyc.NET

支援平台

  • .NET Core 2.0
  • .NET Framework 4.6.1 or above
  • Xamarin.iOS
  • Xamarin.Android
  • Universal Windows Platform
PM> Install-Package Tejkyc.NET

請參考nuget.org上的套件 Tejkyc.NET資訊。

請使用安裝 Tejkyc.NET4

支援平台

  • .NET Framework 4.0 or above
PM> Install-Package Tejkyc.NET4

請參考nuget.org上的套件 Tejkyc.NET4資訊。

認證方式

安裝完成後,需要在您的程式前面加上參考
using Tejkyc;
Imports Tejkyc
初始化物件並填入您的 APIKEY
var client = new TejKycClient("<YOURAPIKEY>");
Dim client As TejKycClient = New TejKycClient("<YOURAPIKEY>")

使用方式

以公司基本資料 TWN/MOEA_COMPANY為例,可直接使用 Tejkyc方法取得,回傳類別為 System.Data.Datatable範例如下

//非同步取得資料(nuget)
var result = await client.GetAsync("TWN/MOEA_COMPANY");

//或採同步(nuget)
var result = await client.GetAsync("TWN/MOEA_COMPANY").Result;

//.net framework4僅採同步
var result = client.Get("TWN/MOEA_COMPANY");
//非同步取得資料
Dim result As DataTable = Await client.GetAsync("TWN/MOEA_COMPANY")

//或採同步
Dim result As DataTable = client.GetAsync("TWN/MOEA_COMPANY").Result

//.net framework4僅採同步
Dim result As DataTable = client.Get("TWN/MOEA_COMPANY")
提示:

若沒有提供篩選條件,會取出所有資料,建議使用下段介紹的篩選方式,加入適當的篩選條件。

資料篩選

如果需要針對欄位篩選,例如僅須取得大西洋飲料股份有限公司(35012903),請直接增加欄位篩選條件comp_ban='35012903'
var rowFilter = "comp_ban=35012903";
//nuget
var result = await client.GetAsync("TWN/MOEA_COMPANY",rowFilter);

//.net framework4
var result = client.Get("TWN/MOEA_COMPANY",rowFilter);
Dim rowFilter = "comp_ban=35012903"
//nuget
Dim result As DataTable = Await client.GetAsync("TWN/MOEA_COMPANY",rowFilter)

//.net framework4
Dim result As DataTable = client.Get("TWN/MOEA_COMPANY",rowFilter)
或是同時取得兩個公司資料35012903及23740225,請利用序列條件 comp_ban=35012903,23740225
var rowFilter = "comp_ban=35012903,23740225"; //nuget var result = await client.GetAsync("TWN/MOEA_COMPANY",rowFilter); //.net framework4 var result = client.Get("TWN/MOEA_COMPANY",rowFilter);
Dim rowFilter = "comp_ban=35012903,23740225"
//nuget
Dim result As DataTable = Await client.GetAsync("TWN/MOEA_COMPANY",rowFilter)

//.net framework4
Dim result As DataTable = client.Get("TWN/MOEA_COMPANY",rowFilter)
單次取得資料限制最多10,000筆,您可以增加 paginate:true,程式將自動分次取得資料
var rowFilter = "comp_ban=23740225";
//nuget
var result = await client.GetAsync("TWN/MOEA_COMPANY",rowFilter, paginate:true);

//.net framework4
var result = client.Get("TWN/MOEA_COMPANY",rowFilter, paginate:true);
Dim rowFilter = "comp_ban=23740225"
//nuget
Dim result As DataTable = Await client.GetAsync("TWN/MOEA_COMPANY",rowFilter,paginate:=True)

//.net framework4
Dim result As DataTable = client.Get("TWN/MOEA_COMPANY",rowFilter,paginate:=True)
提示:

系統限制單次取得最大筆數為10000筆,可使用 paginate:true 參數分次取得資料,但總筆數最多為1,000,000筆。請斟酌使用篩選條件,降低筆數。

您可以針對多個欄位做篩選 ,條件式用&隔開

var rowFilter = "comp_status=核准設立&equity_status=僑外資";
//nuget
var result = await client.GetAsync("TWN/MOEA_COMPANY",rowFilter, paginate:true)

//.net framework4
var result = client.Get("TWN/MOEA_COMPANY",rowFilter, paginate:true);
Dim rowFilter = "comp_status=核准設立&equity_status=僑外資"
//nuget
Dim result As DataTable = Await client.GetAsync("TWN/MOEA_COMPANY",rowFilter,paginate:=True)

//.net framework4
Dim result As DataTable = client.Get("TWN/MOEA_COMPANY",rowFilter,paginate:=True)

欄位篩選

若僅需要取得單一欄位,請利用columnFilterCriteria條件,例如僅須取得公司名稱欄位(comp_name)
var rowFilter = "comp_ban=23740225";
var columnFilter = "comp_name";
//nuget
var result = await client.GetAsync("TWN/MOEA_COMPANY",rowFilter,columnFilter, paginate:true);

//.net framework4
var result = client.Get("TWN/MOEA_COMPANY",rowFilter,columnFilter, paginate:true);
Dim rowFilter = "comp_status=核准設立&equity_status=僑外資"
Dim columnFilter = "comp_name"
//nuget
Dim result As DataTable = Await client.GetAsync("TWN/MOEA_COMPANY",rowFilter,columnFilter,paginate:=True)

//.net framework4
Dim result As DataTable = client.Get("TWN/MOEA_COMPANY",rowFilter,columnFilter,paginate:=True)

或是多個欄位,使用逗號,隔開,例如 comp_ban,comp_name

var rowFilter = "comp_ban=23740225";
var columnFilter = "comp_ban,comp_name";
//nuget
var result = await client.GetAsync("TWN/MOEA_COMPANY",rowFilter,columnFilter, paginate:true);

//.net framework4
var result = client.Get("TWN/MOEA_COMPANY",rowFilter,columnFilter, paginate:true);
Dim rowFilter = "comp_status=核准設立&equity_status=僑外資"
Dim columnFilter = "comp_ban,comp_name"
//nuget
Dim result As DataTable = Await client.GetAsync("TWN/MOEA_COMPANY",rowFilter,columnFilter,paginate:=True)

//.net framework4
Dim result As DataTable = client.Get("TWN/MOEA_COMPANY",rowFilter,columnFilter,paginate:=True)

資料篩選運算

您可以針對資料欄位範圍篩選,例如設立日大於2018-01-01的資料
var rowFilter = "set_date>2018-01-01";
//nuget
var result = await client.GetAsync("TWN/MOEA_COMPANY",rowFilter, paginate:true);

//.net framework4
var result = client.Get("TWN/MOEA_COMPANY",rowFilter, paginate:true);
Dim rowFilter = "set_date>2018-01-01"
//nuget
Dim result As DataTable = Await client.GetAsync("TWN/MOEA_COMPANY",rowFilter,paginate:=True)

//.net framework4
Dim result As DataTable = client.Get("TWN/MOEA_COMPANY",rowFilter,paginate:=True)
您可以針對資料欄位範圍篩選,例如設立日大於2018-01-01且小於2019-01-01的資料
var rowFilter = "set_date>2018-01-01&set_date<2019-01-01";
//nuget
var result = await client.GetAsync("TWN/MOEA_COMPANY",rowFilter, paginate:true);

//.net framework4
var result = client.Get("TWN/MOEA_COMPANY",rowFilter, paginate:true);
Dim rowFilter = "set_date>2018-01-01&set_date<2019-01-01"
//nuget
Dim result As DataTable = Await client.GetAsync("TWN/MOEA_COMPANY",rowFilter,paginate:=True)

//.net framework4
Dim result As DataTable = client.Get("TWN/MOEA_COMPANY",rowFilter,paginate:=True)
篩選運算
詳細說明
使用範例
=
指定欄位等於指定的文字或數值
comp_ban=23740225
>
指定欄位大於指定的數值
set_date>2018-01-01
<
指定欄位小於指定的數值
set_date<2018-01-01
>=
指定欄位大於或等於指定的數值
set_date>=2018-01-01
<=
指定欄位小於或等於指定的數值
set_date<=2018-01-01
!=
指定欄位不等於指定的數值
set_date!=2018-01-01

其他查詢參數

參數
是否必要
詳細說明
使用範例
perPage
指定每次取得的資料數量(上限為10,000),總筆數不得超過1,000,000筆
perPage:100
sortOrder
指定排序的欄位及排序方式,採用 [欄位名稱].[排序方式]表示,排序方式有正向排序(asc)及反向排序(desc),預設為正向排序。
sortOrder:"set_date.desc"