# 快速上手

### 前置參數設定 <a href="#qian-zhi-can-shu-she-ding" id="qian-zhi-can-shu-she-ding"></a>

為了方便描述各個API呼叫行為，以下描述API需要用到的參數。

* ***base\_url***: 您的CKAN平台網址.例如: [http://demo.ckan.org](http://demo.ckan.org/)
* ***api\_key*** : 每個CKAN帳號的擁有者，都有一組API KEY，我們稱之為金鑰。這組金鑰是用來跟CKAN平台認證用的，絕對不可外洩。在使用時，必須在HTTP請求中的header中，把金鑰放入**Authorization**或是**X-CKAN-API-Key**欄位內。

### 請求類別 <a href="#qing-qiu-lei-bie" id="qing-qiu-lei-bie"></a>

每一次對CKAN平台，要求資料或是發送資料，我們稱之為**請求**(request)，由於CKAN API是採用RESTful API的方式建構。所以**請求類別**分為以下幾種：

* GET: 用來搜尋或是取得CKAN平台上的資料。
* POST: 用來上傳檔案或是建立metadata。
* UPDATE: 用作更新資料集描述用途。
* DELETE: 刪除資料集或是資源檔。

### 請求方式範例 <a href="#qing-qiu-fang-shi-fan-li" id="qing-qiu-fang-shi-fan-li"></a>

API請求，可透過上面敘述的*base\_url*以及*api\_key*，使用對應的請求類別以及請求URL來達成目的。

您可以使用curl指令或是REST用戶端工具來進行測試。

假設您的*api\_key*為abc-123，*base\_url*為demo.ckan.org，如果您想取得該開放資料平台(意即demo.ckan.org)的標籤列表。您可以使用*curl*指令，對<http://demo.ckan.org/api/3/action/tag_list> ，下達GET請求。

```
curl --header "Authorization:abc-123" http://demo.ckan.org/api/3/action/tag_list
```

如果請求成功，CKAN平台回應的格式通常以JSON方式表示如下：

```
{"help": "http://demo.ckan.org/api/3/action/help_show?name=tag_list", "success": true, "result": [" \ub2e4\ub9ac", " \ubd84\uc11d", " \uc2dc\uc124", " \uad8c\uc5ed\ubcc4", " \uc8fc\ucc28\uc7a5", " \ucda9\uc804\uc18c", " \uacbd\uc601\uc815\ubcf4", " \uae08\uc735\uae30\uad00", " \ubd80\ubcf4\ub300\uc0c1", " \uc218\ub0a9\ud604\ud669", " \ud30c\uc0b0\uc7ac\ub2e8", " \ud30c\uc0b0\uad00\uc7ac\uc778", " \uc8fc\ubbfc\ud3b8\uc758\uc2dc\uc124", "\uacbd\uc81c", "\uad50\ub7c9", "\uae30\uc220", "\uc815\ubd80", "\u3066\u3059\u3068", "\u30c6\u30b9\u30c8", "\uc5d0\ub108\uc9c0", "\u30e9\u30fc\u30e1\u30f3", "\ubcf4\ud638\ub300\uc0c1", "\uacf5\uc601\uc8fc\ucc28\uc7a5", "\uc608\uae08\ubcf4\ud5d8\ub8cc", "\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0", "\ud30c\uc0b0\uae08\uc735\uae30\uad00", "\ubd80\ubcf4\uae08\uc735\uae30\uad00 \uacbd\uc601\uc815\ubcf4", "01", "02", "03", "100", "12", "123", "140201", "2014", "2015", "2016", "23", "311", "34", "3x1", "3X1", "45", "46352", "aa", "abastaments", "abc", "academic", "Acesso \u00e0 Internet", "acidentes", "Adaptation", "Adaptive Control"...
```

如果一個請求失敗，那麼可能會回傳如下錯誤訊息：

```
{
    "help": "Creates a package",
    "success": false,
    "error": {
        "message": "Access denied",
        "__type": "Authorization Error"
        }
 }
```


---

# 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://honghuafund.gitbook.io/ckan-api/kuai-su-shang-shou.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.
