Slide 1

Slide 1 text

GET REST. API/MY_Practices 1

Slide 2

Slide 2 text

Burak AYDIN 4pps | [email protected] Gdg Ankara @burakaydn 2

Slide 3

Slide 3 text

REST REpresentational State Transfer is a architectural style for distributed hypermedia systems. 3

Slide 4

Slide 4 text

REST ● Client-server ● Stateless state of the resource ● Cacheable ● Layered system load balancing, cache, etc. ● Uniform interface guiding principles 4

Slide 5

Slide 5 text

REST Guiding Principles ●Identification of resources URIs ●Manipulation of resources through these representations representation and it's metadata = enough information to manipulate it ●Self-descriptive messages each message = enough information to process it (MIME, cache, ...) ●Hypermedia as the engine of application state 5

Slide 6

Slide 6 text

Glory of REST (Leonard Richardson's Maturity Model) 1. “The Swamp of POX” You’re using HTTP to make RPC calls. HTTP is only really used as a tunnel. 2. Resources Rather than making every call to a service endpoint, you have multiple endpoints that are used to represent resources, and you’re talking to them. 3. HTTP verbs You interact with resources using HTTP verbs, rather than always using POST. 4. HATEOAS Hypermedia Controls. HATEOAS. You’re 100% REST compliant. 6

Slide 7

Slide 7 text

HATEOS Hypertext As The Engine Of Application State ■ Used to find your way through the API ■ Actually telling us what is allowed and what not 7

Slide 8

Slide 8 text

■ Resource addressed by URI ■ URI Templates ■ HTTP based interactions CRUD API 8

Slide 9

Slide 9 text

POST /groups.discuss. replies.edit POST /photos.delete 9

Slide 10

Slide 10 text

POST /groups.discuss. replies.edit POST /photos.delete 10

Slide 11

Slide 11 text

http://example.org/api/v1/product/123 http://example. org/api/v1/products/123? includes=comments 11

Slide 12

Slide 12 text

“ GET should not ALTER the STATE GET /subscriptions/171/cancel PUT /subscriptions/171/cancel 12

Slide 13

Slide 13 text

Authorization ■ Basic Authorization over SSL ■ OAuth ■ OAuth2 13

Slide 14

Slide 14 text

Pagination https://api.github.com/user/repos? page=2&per_page=100 ■ Link Header #rfc5988 meta: [ link:{ href:"/products/?page=3", rel:"next" } ] 14

Slide 15

Slide 15 text

HTTP Caching ■ ETag ■ Last-Modified ■ Cache-Control ■ Expires mnot.net/cache_docs/ 15

Slide 16

Slide 16 text

Postman Supercharge API workflow getpostman.com 16

Slide 17

Slide 17 text

Other titles ■ HTTP Status codes ■ Rate limiting ■ Error handling 17

Slide 18

Slide 18 text

18 Tesekkürler! Sorular? burakaydin.net.tr @burakaydn [email protected]

Slide 19

Slide 19 text

Kaynaklar ■ http://restcookbook.com/ ■ https://en.wikipedia.org/wiki/Representational_state_transfer ■ https://speakerdeck.com/robsondealmeida/r-dot-i-p-dot-rest-in-peace- a-guide-through-restful-services ■ https://speakerdeck.com/honzajavorek/rest-api-manual ■ https://developer.github.com/v3/#pagination ■ https://speakerdeck.com/josephruscio/building-restful-apis 19