Skip to content

Commit 3ec1e2d

Browse files
jarrodekgitbook-bot
authored andcommitted
GitBook: [master] one page modified
1 parent 47c2b3a commit 3ec1e2d

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

restful-apis-getting-started.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,41 @@ An API or Application Programming Interface, is a way of how one system talk to
1212

1313
**RE**presentational **S**tate **T**ransfer is one of architectures of an API. The REST API is all about a **resource** \(some data stored somehow on the server\(s\)\) and the way how this resource is being transferred to/from the client and what operations are permitted on a resource.
1414

15-
In RESTful APIs you have endpoints that provides an access to the resource. An **endpoint** is an [URI](https://en.wikipedia.org/wiki/Uniform_Resource_Identifier) under which a data may or may not exist. An operation that can be performed on an endpoint is the **method**, also sometimes called the verb. There is a lit of well defined methods and each of them has different semantic meaning.
15+
In RESTful APIs there are endpoints that provides an access to a resource. An **endpoint** is an [URI](https://en.wikipedia.org/wiki/Uniform_Resource_Identifier) under which a data may or may not exist. An operation that can be performed on an endpoint is the **method**, also sometimes called the verb. There is a list of well defined methods and each of them has different semantic meaning.
1616

1717
{% hint style="info" %}
1818
A method is not defined by REST API but rather by underlying HTTP protocol. APIs just use those methods to provide a way to get or modify the data on the server.
1919
{% endhint %}
2020

2121
**POST** method semantically means that this operation creates a new entity \(new data\).
2222

23-
**GET** method means requesting current state of the data. Get request can be about a list of resources \(like getting a list of Instagram posts\) or about getting a single resource \(requesting for a single Instagram post\).
23+
**GET** method means requesting current state of the data. GET request can be about requesting a list of resources \(like getting a list of Instagram posts\) or about requesting a single resource \(requesting for a single Instagram post\).
2424

25-
**PUT** operation semantically means updating the whole resource from the request message payload.
25+
**PUT** operation semantically means updating the whole resource with the data that are transmitted in the request message payload.
2626

27-
**PATCH**, similar to PUT, but it means to update only this part of the resource that is defined in the request payload. Other properties are unchanged.
27+
**PATCH** is similar to PUT but it means to update only this part of the resource that is defined in the request payload. Other properties are unchanged.
2828

2929
**DELETE** method removes the data from the system.
3030

31-
There are more defined methods you can use with your API. You can read about it on [MDN pages](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods).
31+
There are more well defined methods that you can use with your API. Read more about it on [MDN pages](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods).
3232

3333
## HTTP Request
3434

3535
Each API methods can be invoked by making a HTTP \(in most cases\) connection to a server and by sending specially prepared message that every HTTP server understands.
3636

3737
The core Advanced REST Client role is to provide an UI for you to provide only relevant data to communicate with the server and it takes care of generating valid HTTP message. It also reads the response from the server and presents it in a meaningful way to you so you don't waste your time decoding HTTP messages.
3838

39-
An HTTP message is consistent of 3 parts: start line, headers, and the message. Depending on the method data can be different in each part.
39+
An HTTP message is consistent of 3 parts: start line, headers, and the message. The value of each part may vary depending on the request method.
4040

41-
The **start line** describes the requests. It contains method name, the path you are accessing \(the endpoint\) and the protocol version.
41+
The **start line** describes the **requests**. It contains method name, the path to access the resource \(the endpoint\) and the protocol version.
4242

4343
```http
4444
GET /endpoint HTTP/1.1
4545
```
4646

47-
Optional **headers** part of the messages contains a list of meta information that describes the request or the client. There is a list of predefined request headers that every HTTP server understands. It is also possible to use custom headers but only some servers will understand it.
47+
Optional **headers** part of the message contains a list of meta information that describes the request or the client. There is a list of predefined request headers that every HTTP server understands. It is also possible to use custom headers but only some servers will understand it.
4848

49-
Each line in the headers part of the message represent a single header. A header starts with a name, then the headers separator - a colon - and after that the value of the header.
49+
Each line in the headers part of the message represent a single header. A header starts with a name, then the value separator - a colon - and after that the value of the header.
5050

5151
An example headers part:
5252

@@ -58,15 +58,19 @@ accept: */*
5858
content-length: 110459
5959
```
6060

61-
Each of the headers has a meaning and the server use the values to properly process your request.You can read more about request headers on [MDN request headers reference](https://developer.mozilla.org/en-US/docs/Glossary/Request_header) page.
61+
{% hint style="info" %}
62+
Header names are case insensitive per HTTP specification. Clients have no obligation to transform headers into specific form. Headers in the example above are valid even though only some of them starts with capital letter.
63+
{% endhint %}
64+
65+
Each of the headers has a meaning and the server use the values to properly process the request. Read more about request headers on [MDN request headers reference](https://developer.mozilla.org/en-US/docs/Glossary/Request_header) page.
6266

6367
Optional **payload** or **body** part is the resource or data being transferred to the server. The body part must be separated from the previous part with an empty line. The body can be anything: an image, a text, some other binary data, or combination of them.
6468

65-
{% hint style="warning" %}
66-
Even though technically in some situations it is possible to add a body part to GET and HEAD messages but most popular clients \(including all HTTP clients in the web\) disallow setting the body for this two methods. HTTP specification does not specify body for those requests and there's no default behavior.
69+
{% hint style="danger" %}
70+
Technically in some situations it is possible to add a body part to GET and HEAD messages but most popular clients \(including all HTTP clients in the web\) disallow setting the body for this two methods. HTTP specification does not specify body for those requests and there's no default behavior.
6771
{% endhint %}
6872

69-
Full example HTTP message
73+
Full example of a HTTP message
7074

7175
```http
7276
POST /post HTTP/1.1
@@ -89,7 +93,7 @@ The start line consists of HTTP version, status code, and optional status messag
8993
HTTP/1.1 200 OK
9094
```
9195

92-
Status code can be one of pre-defined by HTTP transport specification codes. And so:
96+
Status code is one of pre-defined by HTTP transport specification codes. And so:
9397

9498
* codes of group 100 \(1xx\) are used when a communication protocol is being negotiated; only HTTP client and server cares about this group
9599
* codes of group 200 \(2xx\) indicates a success of the request
@@ -101,12 +105,12 @@ Read more about response status code, with the full list of predefined codes, on
101105

102106
The most common status codes are:
103107

104-
* **200** - Successful request. If the request method is GET it means that the message part contains requested data,
108+
* **200** - Successful request. If the request method is GET it means that the message part contains requested data
105109
* **201** - Created - When a request method was POST it indicates that the data entity has been created
106110
* **301** - The resource has been moved permanently to another location \(endpoint\)
107111
* **307** - The resource has been moved temporarily to another location \(endpoint\)
108-
* **401** - Unauthorized access to the resource. It usually that authorization data are missing, invalid, or expired.
109-
* **404** - Resource not found for given URI
112+
* **401** - Unauthorized access to the resource. It usually means that authorization data are missing, invalid, or expired.
113+
* **404** - Resource not found under given URI
110114
* **500** - A server encountered a problem which resulted in exception; the request processing was aborted
111115
* **503** - The server is not yet ready to accept connections.
112116

0 commit comments

Comments
 (0)