You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We'll use [connexion](https://github.com/spec-first/connexion), a python framework which streamlines API creation.
19
+
---
35
20
36
21
## Interoperability requirements
37
22
@@ -40,7 +25,7 @@ An API ecosystem starts with communication requirements such as:
40
25
- Reliability & Security (e.g., CIA triad: Confidentiality, Integrity and Availability)
41
26
- Consistent Design & Schema Standardization
42
27
43
-
See also [Extending HTTP for fun and non-profit](https://ep2020.europython.eu/talks/9mbcXTU-extending-http-for-fun-and-non-profit/)
28
+
----
44
29
45
30
Basic standardization features to support these requirements include:
46
31
@@ -52,6 +37,9 @@ Basic standardization features to support these requirements include:
52
37
53
38
- Availability strategy based on a distributed circuit-breaker and throttling patterns;
54
39
40
+
<!-- Let's see how to manage such requirements -->
41
+
---
42
+
55
43
## REST and RPC
56
44
57
45
The historical API approach was to view any interaction like a function call.
@@ -62,42 +50,56 @@ used by:
62
50
- SOAP web services, that use XML as a data format and HTTP as a transport protocol;
63
51
- gRPC, that uses HTTP/2 as a transport protocol and Protocol Buffers as a data format.
64
52
53
+
----
54
+
65
55
The widespread of HTTP as a distributed computation protocol, and the rise of data give birth to REST.
66
56
67
57
REST, aka REpresentation State Transfer, is not a protocol,
68
58
but an architectural style which mimics the distributed characteristics of the web.
69
59
60
+
----
61
+
70
62
In REST, everything is a [resource](https://ietf.org/rfc/rfc9110.html#name-resources):
71
63
72
-
- identified by an Uniform Resource Locator URL;
73
-
- conveyed by a `representation`. A resource could be represented as `application/json` or as [`application/xml`](https://tools.ietf.org/html/rfc7303), in different languages (see `Content-Language`) and differently encoded (see `Content-Encoding`);
64
+
- identified by an **Uniform Resource Locator** (URL);
65
+
- conveyed by a **representation**.
66
+
A resource can be represented in different formats, such as `application/json` or [`application/xml`](https://tools.ietf.org/html/rfc7303),
67
+
in different languages (see `Content-Language`) and differently encoded (see `Content-Encoding`);
74
68
- whose state is transferred between an Origin Server and a User Agent (see RFC9110);
75
69
70
+
----
71
+
76
72
There are no "functions" but everything is modeled as a resource.
77
73
Moreover all the HTTP semantics ([RFC9110](https://datatracker.ietf.org/doc/html/rfc9110)) applies, including idempotent and non-idempotent methods and caching.
78
74
75
+
----
76
+
79
77
The REST architectural style **leverages the distributed nature of the web**
80
78
and the features of HTTP which are redesigned with REST in mind (see RFC911x).
81
79
82
80
**REST & Public services**: while REST is not a silver bullet, public services are usually about data:
83
-
this makes REST a good fit for public service modeling.
81
+
this makes REST a good fit for modeling public services.
84
82
85
83
Moreover a semantic approach to URIs simplifies routing and auditing
86
84
based on http status, method and path.
87
85
88
-
## REST API & HTTP Standards
86
+
---
89
87
90
-
For the rest of the course, we will give for granted
91
-
that you are familiar with the HTTP protocol.
88
+
## REST API & HTTP Standards
92
89
93
-
Just for a quick recap, here are some examples of HTTP requests and responses.
90
+
While we assume
91
+
that you are familiar with the HTTP protocol,
92
+
but just for a quick recap, here are some examples of HTTP requests and responses.
94
93
95
94
HTTP messages are composed by:
96
95
97
96
- a start line (request line or status line)
98
97
- headers (includes metadata about the representation, such as content type, content language, content encoding, etc.)
99
98
- an optional content
100
99
100
+
----
101
+
102
+
101
103
### HTTP Message Examples
102
104
103
105
A request to <http://api.example.com/datetime/v1/now>
@@ -109,6 +111,8 @@ Host: api.example.com
109
111
Accept: application/json
110
112
```
111
113
114
+
----
115
+
112
116
Response with a JSON representation of the current date and time:
113
117
114
118
```http
@@ -121,6 +125,8 @@ Content-Length: 30
121
125
}
122
126
```
123
127
128
+
----
129
+
124
130
The same resource could have more representations,
125
131
in different formats ...
126
132
@@ -137,6 +143,8 @@ Content-Type: text/plain
137
143
2024-06-01T12:00:00Z
138
144
```
139
145
146
+
----
147
+
140
148
Security features are usually implemented using HTTP functionalities
141
149
such as headers and status codes.
142
150
@@ -155,6 +163,8 @@ HTTP/1.1 401 Unauthorized
155
163
WWW-Authenticate: Bearer
156
164
```
157
165
166
+
----
167
+
158
168
TODO: http ongoing work on API description:
159
169
160
170
- Integrity: Digest, HTTP Signatures, Unencoded Digest, etc.
@@ -163,8 +173,19 @@ TODO: http ongoing work on API description:
163
173
- Security: QUERY method
164
174
- Efficiency: Resumable uploads
165
175
166
-
https://datatracker.ietf.org/wg/httpapi/about/
176
+
<https://datatracker.ietf.org/wg/httpapi/about/>
167
177
168
178
- lifecycle: Deprecation, Sunset, etc.
169
179
- catalog: RFC 9727
170
180
- YAML media type
181
+
182
+
---
183
+
184
+
## References
185
+
186
+
[See Slides]
187
+
188
+
-[Do we still need SOAP?](https://docs.google.com/presentation/d/1AqVoCmqVF4TrIw_QowEzdWh8F42wNZuHnIFyP3H2Qc0)[video](https://www.youtube.com/watch?v=9a2n8s1j5l0)
189
+
-[Extending HTTP for fun and non-profit](https://ep2020.europython.eu/talks/9mbcXTU-extending-http-for-fun-and-non-profit/)
0 commit comments