INF TEK
Semester 4
REST Client
KAI, AIR ASIA, BCA, DLL
HTTP Method
• GET
• Mengambil data
• POST
• Menambah data
• PUT
• Update data
• DELETE
• Menghapus data
RESTFul API
HTTP
End point
Method
REST
REST
https://sample.com/api/photos
https://api.sample.com/photos
Public API
Public API / Open API
• Sebuah API (REST API) yang dapat diakses secara public, yang di
dalamnya tersedia aturan untuk developer agar dapat mengakses
data.
https://console.cloud.google.com/projectselector2/apis/dashboard?supportedpurview=project
• https://any-api.com
• https://github.com/toddmotto/public-apis
• https://github.com/farizdotid
• https://kawalcorona.com/api/
Free???
• Otentikasi (Auth)
• Tanpa otentikasi
• Key / Token
JSON
JAVASCRIPT OBJECT NOTATION
JSON
JSON
JSON
JSON
• JSON, singkatan dari JavaScript Object Notation, adalah suatu format
ringkas pertukaran data komputer. Formatnya berbasis teks dan
terbaca-manusia serta digunakan untuk merepresentasikan struktur
data sederhana dan larik asosiatif. Wikipedia
Digital Communications
•{
"employee": { "name":"John", "age":30, "city":"New York"
Object
}
}
JSON Sintax rule
• Data is in name/value pairs
• Data is separated by commas
"name": "ringga"
• Curly braces hold objects
"name": "ringga", "age": 34
• Square brackets hold arrays
{ "name": "ringga", "age": 34 }
[
{ "name": "ringga", "age": 34 },
{ "name": "joko", "age": 30 }
]
• Console.log(data.nama)
Browser
JavaScript
Browser
JS Machine
JS Code JavaScript
Engine Code
JS engine
spidermonkey
2009
• Node create by Ryan Dahl
+ C++
V8 Access memory
File system
I/O
Network
etc
Node is not a Node is not a
Programming language! Framework!
Non-Blocking
Asynchronous
Karakteristik Node.Js
• Asynchronous
• Non-Blocking
• Single Thread but highly scalable
• Cross platform
• Open source
• NPM (Node Package Manager)
Node.js vs PHP
PHP Node.js
1994 2009
composer NPM
Node.JS for
• Dynamic single page app
• Realtime app
• API
• Streaming app
• MERN , MEAN, MEVN
• MongoDb
• Express
• React, Angular, Vue
• Node
• Single thread
• Non-blocking
• Asyncrounus
Web Server
req
req
server
Web Server
server
Web Server
req1
req2
req3
req4
server
Web Server
Multi thread
Tomcat
server
Multi thread
Web Server
Tomcat
server
Non-Blocking
Node.JS
server
Asyncronous
Response2
Node.JS
server
Node APP
• Build twice as fast with fewer people
• 33% fewer line of code
• 40% fewer file
• 2x number request/sec
• decrease 35% response time