RESTFUL API BEST PRACTICES By Malwina Nowakowska STX NEXT - - PowerPoint PPT Presentation

restful api
SMART_READER_LITE
LIVE PREVIEW

RESTFUL API BEST PRACTICES By Malwina Nowakowska STX NEXT - - PowerPoint PPT Presentation

RESTFUL API BEST PRACTICES By Malwina Nowakowska STX NEXT talented developers | flexible teams | agile experts Malwina Nowakowska Developer STX Next Love Python API API API API API API API API Special demo event RESTful API


slide-1
SLIDE 1

STX NEXT

talented developers | flexible teams | agile experts

RESTFUL API

BEST PRACTICES By Malwina Nowakowska

slide-2
SLIDE 2

Malwina Nowakowska

Developer STX Next Love Python

slide-3
SLIDE 3
slide-4
SLIDE 4
slide-5
SLIDE 5

API API API API API API API API

slide-6
SLIDE 6
slide-7
SLIDE 7
slide-8
SLIDE 8
slide-9
SLIDE 9
slide-10
SLIDE 10
slide-11
SLIDE 11
slide-12
SLIDE 12
slide-13
SLIDE 13
slide-14
SLIDE 14

Special demo event

slide-15
SLIDE 15
slide-16
SLIDE 16
slide-17
SLIDE 17
slide-18
SLIDE 18

RESTful API

slide-19
SLIDE 19

„Representational State Transfer (REST) is a

style of software architecture for distributed hypermedia systems such as the World Wide Web”

slide-20
SLIDE 20

Architectural constraints

Client-Server Stateless Cacheable Uniform Interface Layered System Code on Demand (optional)

slide-21
SLIDE 21

Client-Server

slide-22
SLIDE 22

Stateless

slide-23
SLIDE 23

Cacheable

slide-24
SLIDE 24

Uniform Interface

1) Identifying the resource 2) Resource representation 3) Self-descriptive messages 4) Hypermedia as the engine of application state

slide-25
SLIDE 25

Layered System

slide-26
SLIDE 26

Code on Demand (optional)

slide-27
SLIDE 27

Architectural properties

Performance Scalability Simplicity of interfaces Modifiability of components to meet changing needs (even while the application is running) Visibility of communication between components by service agents Portability of components by moving program code with the data Reliability is the resistance to failure at the system level in the presence of failures within components, connectors, or data

slide-28
SLIDE 28

RESTful APIs

Web service APIs that adhere to the REST architectural constraints are called RESTful APIs

slide-29
SLIDE 29

Richardson REST Maturity Model

slide-30
SLIDE 30

Resources

slide-31
SLIDE 31

/tickets /events /users /baskets /event_venues

slide-32
SLIDE 32

/tickets /events /users /baskets /event_venues

Nouns

slide-33
SLIDE 33

/tickets /events /users /baskets /event_venues

Nouns

Plural

slide-34
SLIDE 34

/tickets /events /users /baskets /event_venues

Nouns

Case convention

Plural

slide-35
SLIDE 35

Create POST Read GET Update PUT/PATCH Delete DELETE

slide-36
SLIDE 36

Create POST Read GET Update PUT/PATCH Delete DELETE

slide-37
SLIDE 37

GET /events - Read a list of events GET /events/12 - Read a specific event POST /events - Create a new event PUT/PATCH /events/12 - Update event #12 DELETE /events/12 - Delete event #12

slide-38
SLIDE 38

GET /events/12/prices - Read a list of event’s prices GET /events/12/prices/5 - Read a specific event’s price POST /events/12/prices - Create a new event’s price PUT/PATCH /events/12/prices/5 - Update event’s price DELETE /events/12/prices/5 - Delete event’s price

slide-39
SLIDE 39

Related resource representations

slide-40
SLIDE 40
slide-41
SLIDE 41
slide-42
SLIDE 42

Filtering

GET /events?state=active&category=music,comedy

slide-43
SLIDE 43

Sorting

GET /events?sort=-date,name

slide-44
SLIDE 44

Searching

GET /events?q=Madonna

slide-45
SLIDE 45

Limiting response

GET /events?fields=(id,title,date,artist.name)

slide-46
SLIDE 46

Actions

GET /search POST /order/1234/sum

slide-47
SLIDE 47

Versioning

https://my-site.com/api/v1 Accept: application/vnd.my-site.v3+json

slide-48
SLIDE 48

Pagination

Range: events=0-30 /events?page=1 /events?page=1&per_page=50 limit=10&offset=30

slide-49
SLIDE 49

Accept-Ranges: events 50 Content-Range: 0-10/1234

  • ffset – limit / count

resource max

Link: <https://api.github.com/user/repos?page=3&per_page=100>; rel="next", <https://api.github.com/user/repos?page=50&per_page=100>; rel="last"

slide-50
SLIDE 50

Content-Type: application/json Accept: application/xml; application/json

slide-51
SLIDE 51

Pretty print

slide-52
SLIDE 52
slide-53
SLIDE 53

HATEOAS

slide-54
SLIDE 54

Documentation

slide-55
SLIDE 55
slide-56
SLIDE 56

Best practices

slide-57
SLIDE 57
slide-58
SLIDE 58

Thank you!