# Calculating the Signature and DGRK

### **Original Request Body JSON** <a href="#toc163842103" id="toc163842103"></a>

Example:

```
{
"ReqHeader": {
"txSN": "1220315140419qRRXvZ",
"txDate": "20220315T140419+0800",
"txID": "DPB0044",
"cID": "YWRtaW5Db25zb2xl",
"locale": "zh-TW"
},
"ReqBody": {
"keyword": "",
"queryStartDate": "2021/08/01",
"queryEndDate": "2022/03/15",
"typeItemNo": "",
"enFlagEncode": "JDJhJDA0JGpHRlc3dHl0WlRnbC5YbmV5SnFBdGVkaXhmY1Z1LlouVlIxRWprVy5SYkRDTmRabTd2M3oy,0",
"fbTypeEncode": "JDJhJDA0JFpWQjdYU1F5ckNsUjBOOWxic2tjamVnOFI4ck1xbU9sNy54SkZ0Z0VLWmthLkpmQmJFTWdL,1"
}
}
```

### **Minimizing Request Body JSON** <a href="#toc163842104" id="toc163842104"></a>

Example:

```
{"ReqHeader":{"txSN":"1220315140419qRRXvZ","txDate":"20220315T140419+0800","txID":"DPB0044","cID":"YWRtaW5Db25zb2xl","locale":"zh-TW"},"ReqBody":{"keyword":"","queryStartDate":"2021/08/01","queryEndDate":"2022/03/15","typeItemNo":"","enFlagEncode":"JDJhJDA0JGpHRlc3dHl0WlRnbC5YbmV5SnFBdGVkaXhmY1Z1LlouVlIxRWprVy5SYkRDTmRabTd2M3oy,0","fbTypeEncode":"JDJhJDA0JFpWQjdYU1F5ckNsUjBOOWxic2tjamVnOFI4ck1xbU9sNy54SkZ0Z0VLWmthLkpmQmJFTWdL,1"}}
```

### **Adding API Key and Secret Key** <a href="#toc163842105" id="toc163842105"></a>

Example:

```
{"ReqHeader":{"txSN":"1220315140419qRRXvZ","txDate":"20220315T140419+0800","txID":"DPB0044","cID":"YWRtaW5Db25zb2xl","locale":"zh-TW"},"ReqBody":{"keyword":"","queryStartDate":"2021/08/01","queryEndDate":"2022/03/15","typeItemNo":"","enFlagEncode":"JDJhJDA0JGpHRlc3dHl0WlRnbC5YbmV5SnFBdGVkaXhmY1Z1LlouVlIxRWprVy5SYkRDTmRabTd2M3oy,0","fbTypeEncode":"JDJhJDA0JFpWQjdYU1F5ckNsUjBOOWxic2tjamVnOFI4ck1xbU9sNy54SkZ0Z0VLWmthLkpmQmJFTWdL,1"}}YjQxNzJlMjFiMzAzM2Q5NWM2ZDYzNTVjYzhmMTRjNGQxMTA3YzllYw==YTk2MTQ2MjhhZDM1MjYwZDVkMTdjMTE2MTIyZDhkOTFhNmNiNGI3NjNmMjg1ZTgzMWI3OGQ1ZGZlNDA2OGNkYw==
```

### **Obtaining Digital Signature** <a href="#toc163842106" id="toc163842106"></a>

Insert the Secret Key into the secretKey variable of the sample program. Incorporate the aforementioned data into the message variable, output it as a byte array, apply HMAC SHA256 encryption, and then use Base64 encoding to obtain the Signature (Digital Signature).

Example signature:

```
Q22n2yrakE60W8eGduraBPddPECSdJpLFPY7ojpnKr0=
```

Example program:

<div align="left"><img src="/files/6ETzQ5YAoUZepkADE7hP" alt=""></div>

### **Obtaining DGRK** <a href="#toc163842107" id="toc163842107"></a>

Combine the API Key with a period (.), and append the Signature to obtain the DGRK.

Example:

```
YjQxNzJlMjFiMzAzM2Q5NWM2ZDYzNTVjYzhmMTRjNGQxMTA3YzllYw==.Q22n2yrakE60W8eGduraBPddPECSdJpLFPY7ojpnKr0=
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tpi.dev/api-integration-guide/using-api-key-for-authentication-and-authorization/calculating-the-signature-and-dgrk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
