> For the complete documentation index, see [llms.txt](https://jen-hsuan-hsieh.gitbook.io/asp-net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jen-hsuan-hsieh.gitbook.io/asp-net/chapter3rest-api-design-development-and-management/31evolution-of-restful-services/312introduction-to-restful-api.md).

# 3.1.2.Introduction to RESTful API

* Resource
  * Objects, things, entities e.g. 車子的規格, 主人, 價格等狀態, 萬物皆可為資源
  * 由URL來指定, **URL即是資源**
* Representation state
  * 因為資源無法透過網路傳輸, 利用網路傳輸的是訊息資源
  * 用戶發出了一個GET請求時, 服務器會去蒐集資源的狀態 (representation state)

    ![](https://163116165-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4M0G7tIs4o9F9vSrao%2F-M4M0IVB0ax0vs2ocz_r%2F-M4M0WS0fbo8wDLUsIV0%2F1.jpg?generation=1586302964305170\&alt=media)
* Representation State Transfer
  * 當服務器為了一個資源發送了一個HTTP請求, 服務器會發送一個文檔做響應
  * e.g. 當有顧客詢價時, 送出query, server所回覆的response便稱為Representation State Transfer
* Representation of resource
  * 一個資源可以有多重表述 (representation): 服務器可以用XML, JSON或是SQL語句, 都是合法的表述
  * 依照使用者的需求, 存在DB中的resource可以轉換成不同的Data format後呈現
  * RESTful API可以回傳任意格式的response
    * e.g. [wallmart open API](https://developer.walmartlabs.com/io-docs)
* REST API (high level)
  * 如何才被稱作REST API?
    * 是一種Architecture style
    * [Set of principles](https://jenhsuan.gitbooks.io/asp-net/content/chapter3rest-api-design-development-and-management/32rest-api-architectural-constraints.html)
  * 不是一種規格, 也不是一種標準
    * HTTP只是一個選擇, 但沒有規定一定要使用
