├── .devcontainer └── devcontainer.json ├── README.md ├── docs ├── breaks.md ├── feedback.md ├── q&a.md ├── resources.md ├── screens_setup.png ├── snippets.md └── timing.md └── slides └── API_Styles_Fundamentals.pdf /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "image": "mcr.microsoft.com/devcontainers/base:ubuntu-22.04", 3 | "hostRequirements": { 4 | "cpus": 2, 5 | "memory": "8gb", 6 | "storage": "32gb" 7 | }, 8 | "customizations": { 9 | "codespaces": { 10 | "openFiles": [ 11 | "README.md", 12 | "docs/snippets.md" 13 | ] 14 | } 15 | }, 16 | "features": { 17 | "ghcr.io/devcontainers/features/docker-in-docker:2": {}, 18 | "ghcr.io/guiyomh/features/vim:0": {} 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # API Styles Fundamentals 2 | 3 | If you only have a hammer, everything begins to look like a nail, but sticking with a single API style is limiting. Nowadays, a service or microservice has several APIs, and they must all be well-defined. You’ll examine the best types of APIs for your use cases as well as the design decisions you must make for RESTful APIs, GraphQL APIs, Websockets API, gRPC API, and messaging protocols. You’ll learn how to design a variety of APIs, recognize the trade-offs among them, and understand where to use each one for the best communication among applications. 4 | 5 | Search for a live event about API Styles Fundamentals at [learning.oreilly.com](https://learning.oreilly.com/live-events/api-styles-fundamentals/0636920078591/) 6 | 7 | ## Table of Contents 8 | 9 | 1. [Slides](slides/API_Styles_Fundamentals.pdf) 10 | 1. [Snippets](docs/snippets.md) 11 | 1. [Resources](docs/resources.md) 12 | 1. [Q&A](docs/q&a.md) 13 | 1. [Feedback](docs/feedback.md) 14 | 15 | ## Metadata 16 | 17 | Published on 6th December 2022 18 | -------------------------------------------------------------------------------- /docs/breaks.md: -------------------------------------------------------------------------------- 1 | 1. Application Protocols slide no. 34 - 10 minutes 2 | 2. API Styles slide no. 52 - 5 minutes 3 | -------------------------------------------------------------------------------- /docs/feedback.md: -------------------------------------------------------------------------------- 1 | ## 4 Dec 2022 - Marcin D. 2 | 3 | Presentation: 4 | - Smile 5 | - Face camera 6 | - Don't look closer to read slides 7 | - Use gesticulation don't look away 8 | 9 | Remove: 10 | - You'll (Dupplicates) 11 | - Don't say simple 12 | 13 | Content: 14 | - 37 markup language 15 | - 39 Think about YAML 16 | - 45 Avro - be careful about changes of schema - https://docs.confluent.io/platform/current/schema-registry/index.html#sr-overview 17 | - 89 gRPC Specification ? 18 | - 90 interservice comminication - don't talk north south and west east 19 | - Remove Technical Vocabulary 20 | - Trim REST 21 | -------------------------------------------------------------------------------- /docs/q&a.md: -------------------------------------------------------------------------------- 1 | # Question and Answers 2 | 3 | ### [What is the difference between serialization and marshalling?](https://stackoverflow.com/questions/770474/what-is-the-difference-between-serialization-and-marshaling) 4 | 5 | Serialization is the process of converting object state into a byte stream in such a way that the byte stream can be converted back into a copy of the object. Marshaling is the process of transforming the memory representation of an object into a data format suitable for storage or transmission. 6 | 7 | When you serialize an object, only the member data within that object is written to the byte stream; not the code that actually implements the object. Marshaling is used when we talk about passing objects to Remote Method Invocation (RMI). In marshalling, state of an object is serialized: member data is serialized + codebase is attached. 8 | 9 | ### Is HTTP3 enforced by browser? 10 | 11 | HTTP/3 is not enforced by browsers, but it is up to the servers to support it and offer it as an option for browsers to use. When a browser requests a website, it sends an initial request using HTTP/1.1 or HTTP/2, and the server responds with the version it supports. If the server supports HTTP/3, and the browser also supports it, the connection will use HTTP/3. If the server doesn't support HTTP/3, the connection will use the highest version that both the server and the browser support. 12 | -------------------------------------------------------------------------------- /docs/resources.md: -------------------------------------------------------------------------------- 1 | 1. https://ably.com/search?q=grpc 2 | 1. https://www.infoq.com/presentations/history-api/ 3 | 1. https://www.youtube.com/watch?v=LzMp6uQbmns 4 | 1. https://www.youtube.com/watch?v=aAb7hSCtvGw 5 | 1. https://www.cloudflare.com/learning/ddos/glossary/open-systems-interconnection-model-osi/ 6 | 1. https://www.scaler.com/topics/computer-network/application-layer/ 7 | 1. https://www.geeksforgeeks.org/layers-of-osi-model/ 8 | 1. https://infosys.beckhoff.com/english.php?content=../content/1033/tf6310_tc3_tcpip/84246923.html&id= 9 | 1. https://www.imperva.com/learn/application-security/osi-model/ 10 | 1. https://cloud.google.com/blog/topics/developers-practitioners/differences-between-synchronous-web-apis-and-asynchronous-stateful-apis 11 | 1. https://en.wikipedia.org/wiki/Duplex_(telecommunications)#FULL-DUPLEX 12 | 1. https://cloud.google.com/blog/topics/developers-practitioners/differences-between-synchronous-web-apis-and-asynchronous-stateful-apis 13 | 1. https://www.soapui.org/learn/api/soap-vs-rest-api/ 14 | 1. https://en.wikipedia.org/wiki/OpenAPI_Specification 15 | 1. https://developers.google.com/protocol-buffers 16 | 1. https://en.wikipedia.org/wiki/Apache_Thrift 17 | 1. https://en.wikipedia.org/wiki/Apache_Avro 18 | 1. https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol 19 | 1. https://www.digitalocean.com/community/tutorials/http-1-1-vs-http-2-what-s-the-difference 20 | 1. https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Evolution_of_HTTP 21 | 1. https://css-tricks.com/http2-real-world-performance-test-analysis/ 22 | 1. https://medium.com/walmartglobaltech/introduction-to-http-2-d3e3b4f4d662 23 | 1. https://stackoverflow.com/questions/58498116/why-is-it-said-that-http2-is-a-binary-protocol 24 | 1. https://developer.mozilla.org/en-US/docs/Web/HTTP 25 | 1. https://freecontent.manning.com/animation-http-1-1-vs-http-2-vs-http-2-with-push/ 26 | 1. https://http3-explained.haxx.se/en/h3/h3-h2 27 | 1. https://avinetworks.com/glossary/ssl-termination/ 28 | 1. https://www.ibm.com/docs/en/aix/7.2?topic=protocols-transmission-control-protocol 29 | 1. https://ntrs.nasa.gov/api/citations/20080030196/downloads/20080030196.pdf 30 | 1. https://www.json.org/json-en.html 31 | 1. https://www.redhat.com/en/topics/api/what-is-a-rest-api 32 | 1. https://en.wikipedia.org/wiki/HATEOAS 33 | 1. https://medium.com/the-sixt-india-blog/rest-stop-calling-your-http-apis-as-restful-apis-e8336e3e799b 34 | 1. https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.91.9164&rep=rep1&type=pdf 35 | 1. https://gist.github.com/chrisnicola/1502400 36 | 1. https://www.restapitutorial.com/lessons/whatisrest.html 37 | 1. https://restfulapi.net/ 38 | 1. https://stackoverflow.com/questions/34130036/how-to-understand-restful-api-is-stateless 39 | 1. https://www.redhat.com/en/topics/cloud-native-apps/stateful-vs-stateless 40 | 1. https://www.redhat.com/en/topics/api 41 | 1. https://www.redhat.com/en/topics/api/what-are-application-programming-interfaces 42 | 1. https://restfulapi.net/what-is-an-api/ 43 | 1. https://nordicapis.com/understanding-idempotency-and-safety-in-api-design/ 44 | 1. https://krify.co/advantages-and-disadvantages-of-rest-api/ 45 | 1. https://www.geekboots.com/story/advantages-and-disadvantages-of-restapi-over-soap 46 | 1. https://en.wikipedia.org/wiki/GraphQL 47 | 1. https://phil.tech/2017/graphql-vs-rest-overview/ 48 | 1. https://honest.engineering/posts/why-use-graphql-good-and-bad-reasons 49 | 1. https://www.howtographql.com/basics/0-introduction/ 50 | 1. https://www.howtographql.com/basics/2-core-concepts/ 51 | 1. https://www.prisma.io/blog/graphql-server-basics-the-schema-ac5e2950214e 52 | 1. https://www.javatpoint.com/graphql-advantages-and-disadvantages 53 | 1. https://unetworkingab.medium.com/millions-of-active-websockets-with-node-js-7dc575746a01#:~:text=The%20theoretical%20limit%20is%2065k,and%20then%20node%20examples%2FWebSocket. 54 | 1. https://en.wikipedia.org/wiki/WebSocket 55 | 1. https://en.wikipedia.org/wiki/Network_socket#Types 56 | 1. https://hackernoon.com/pros-and-cons-of-websocket-and-eventsource 57 | 1. https://www.rfwireless-world.com/Terminology/Advantages-and-Disadvantages-of-Websockets.html 58 | 1. https://en.wikipedia.org/wiki/Remote_procedure_call#Message_passing 59 | 1. https://cloud.google.com/blog/products/api-management/understanding-grpc-openapi-and-rest-and-when-to-use-them 60 | 1. https://www.youtube.com/watch?v=P0a7PwRNLVU 61 | 1. https://cloud.google.com/blog/products/api-management/google-cloud-api-design-tips 62 | 1. https://www.freecodecamp.org/news/rest-is-the-new-soap-97ff6c09896d/ 63 | 1. https://www.simplilearn.com/kafka-vs-rabbitmq-article#:~:text=Deciding%20Between%20Kafka%20and%20RabbitMQ&text=While%20Kafka%20is%20best%20suited,for%20both%20Kafka%20and%20RabbitMQ. 64 | 1. https://www.upsolver.com/blog/kafka-versus-rabbitmq-architecture-performance-use-case 65 | 1. https://www.youtube.com/watch?v=hkXzsB8D_mo 66 | 1. https://www.youtube.com/watch?v=6RvlKYgRFYQ 67 | 1. https://sookocheff.com/post/networking/how-does-http-2-work/#:~:text=h2%20is%20an%20application%2Dlevel,IP%20connection%20for%20multiple%20requests. 68 | 1. https://stoplight.io/api-types/soap-api 69 | 1. https://dzone.com/articles/why-and-when-to-use-graphql-1 70 | 1. https://graphql.org/learn/best-practices/0 71 | 1. https://dev.to/pieter/tcp-udp-or-quic-read-this-before-you-choose-432e 72 | 1. https://www.youtube.com/watch?v=9Lany3ApvjM 73 | 1. https://www.youtube.com/watch?v=idViw4anA6E 74 | 1. https://www.youtube.com/watch?v=vv4y_uOneC0 75 | 1. https://circleci.com/blog/what-is-yaml-a-beginner-s-guide/ 76 | -------------------------------------------------------------------------------- /docs/screens_setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldynia/workshop-api-styles-fundamentals/3549d00feb0626bd921a5102861b8fb880ad758e/docs/screens_setup.png -------------------------------------------------------------------------------- /docs/snippets.md: -------------------------------------------------------------------------------- 1 | # Codespaces 2 | 3 | ```bash 4 | source /usr/share/bash-completion/completions/git 5 | ``` 6 | 7 | # REST API 8 | 9 | 1. Visit [GitHub's REST API](https://docs.github.com/en/rest/repos/repos#list-public-repositories) 10 | 1. Create `7 days` expiration PAT token called `delete_me` in [Settings > Developer settings > Personal access tokens > Fine-grained tokens](https://github.com/settings/personal-access-tokens/new) 11 | 12 | 1. Export token to environment variable 13 | 14 | ```bash 15 | export GH_PAT="github_pat_****" 16 | ``` 17 | 18 | 1. Get user data 19 | 20 | ```bash 21 | curl --request GET \ 22 | --header "Accept: application/vnd.github+json" \ 23 | --header "Authorization: Bearer $GH_PAT" \ 24 | --url "https://api.github.com/user" \ 25 | | jq '{id, login, url}' 26 | ``` 27 | 28 | 1. Get user's public repositories 29 | 30 | ```bash 31 | # First method 32 | curl --request GET \ 33 | --header "Accept: application/vnd.github+json" \ 34 | --header "Authorization: Bearer $GH_PAT" \ 35 | --url "https://api.github.com/user/repos?type=owner&sort=created&direction=desc" \ 36 | | jq '.[] | {name, full_name}' 37 | 38 | # Second method 39 | curl --request GET \ 40 | --header "Accept: application/vnd.github+json" \ 41 | --header "Authorization: Bearer $GH_PAT" \ 42 | --url "https://api.github.com/users/ldynia/repos?type=owner&sort=created&direction=desc" \ 43 | | jq '.[] | {name, full_name}' 44 | ``` 45 | 46 | # GraphQL API 47 | 48 | 1. Visit [GitHub's GraphQL API - GraphiQL](https://docs.github.com/en/graphql/overview/explorer) 49 | 50 | 1. Get user data 51 | 52 | ```graphql 53 | query { 54 | viewer { 55 | databaseId 56 | login 57 | url 58 | } 59 | } 60 | ``` 61 | 62 | 1. Get user's public repositories 63 | 64 | ```graphql 65 | query { 66 | viewer { 67 | login 68 | url 69 | repositories( 70 | first:100, 71 | isFork: false, 72 | ownerAffiliations: OWNER 73 | privacy: PUBLIC 74 | orderBy: {field: UPDATED_AT, direction: DESC} 75 | ) { 76 | edges { 77 | node { 78 | name 79 | url 80 | updatedAt 81 | } 82 | } 83 | } 84 | } 85 | } 86 | ``` 87 | 1. Get user's repositories with fragments 88 | 89 | ```graphql 90 | fragment Repos on RepositoryConnection { 91 | nodes { 92 | name 93 | url 94 | } 95 | } 96 | 97 | query ownedRepos { 98 | viewer { 99 | archived: repositories( 100 | first: 2 101 | ownerAffiliations: OWNER 102 | privacy: PUBLIC 103 | isLocked: true 104 | orderBy: { field: UPDATED_AT, direction: DESC } 105 | ) { 106 | ...Repos 107 | } 108 | 109 | forked: repositories( 110 | first: 2 111 | ownerAffiliations: OWNER 112 | privacy: PUBLIC 113 | isFork: true 114 | isLocked: false 115 | orderBy: { field: UPDATED_AT, direction: DESC } 116 | ) { 117 | ...Repos 118 | } 119 | 120 | original: repositories( 121 | first: 2 122 | ownerAffiliations: OWNER 123 | privacy: PUBLIC 124 | isFork: false 125 | isLocked: false 126 | orderBy: { field: UPDATED_AT, direction: DESC } 127 | ) { 128 | ...Repos 129 | } 130 | } 131 | } 132 | ``` 133 | 134 | # Clean Up 135 | 136 | 1. Delete `delete_me` PAT token in [Settings > Developer settings > Personal access tokens > Fine-grained tokens](https://github.com/settings/tokens?type=beta) -------------------------------------------------------------------------------- /docs/timing.md: -------------------------------------------------------------------------------- 1 | | Subject | Start | Stop | 2 | |-|-|-| 3 | | Intro | 1:20 | | 4 | | Objectives | 3:25 | | 5 | | Roadmap | 4:45 | | 6 | | Into | | | 7 | | Purpuse | | | 8 | | History | 11:50 | 17:30 | 9 | | OSI | 17:30 | 23:20| 10 | | Transmission modes | 23:20 | 26:00 | 11 | | Communication Styles | 26:00 | 28:15 | 12 | | Transport Protocols L4 | 28:15 | 40:00 | 13 | | Transfer Protocols L7 | 40:00 | 50:00 | 14 | | Encoding and Encryption | 50:00 | 55:00 | 15 | | Q&A | 55:00 | 60:00 | 16 | | SOAP | 70:00 | 76:00 | 17 | | REST | 76:00 | 88:00 | 18 | | GraphQL | 88:00 | 105:00 | 19 | | WebSockets | 105:00 | 115:00 | 20 | | gRPC | 115:00 | 121:00 | 21 | | Messeging | 115:00 | 121:00 | 22 | | Messeging | 121:00 | 129:00 | 23 | -------------------------------------------------------------------------------- /slides/API_Styles_Fundamentals.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldynia/workshop-api-styles-fundamentals/3549d00feb0626bd921a5102861b8fb880ad758e/slides/API_Styles_Fundamentals.pdf --------------------------------------------------------------------------------