Pengembangan Teknologi Web (Api Dalam Platform Web)
Pengembangan Teknologi Web (Api Dalam Platform Web)
Nama:
Ardian Permana Putera 1461600119
Berikut merupakan contoh cara request api pada Google Distance Matrix Api :
https://maps.googleapis.com/maps/api/distancematrix/json?units=i
mperial&origins=Washington,DC&destinations=New+York+City,NY&key=
YOUR_API_KEY
NB : penggunaan Api pada Google Maps Distance Matrix API harus disertai Api
key yang di dapat dari google agar bisa menggunakannya
Berikut merupakan contoh respon api pada Google Distance Matrix Api :
{
"destination_addresses" : [ "New York, NY, USA" ],
"origin_addresses" : [ "Washington, DC, USA" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "225 mi",
"value" : 361715
},
"duration" : {
"text" : "3 hours 49 mins",
"value" : 13725
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
2. Google Maps Elevation API
Google Maps Elevation API menyediakan data elevasi untuk semua lokasi di
permukaan bumi, termasuk lokasi kedalaman di dasar laut (yang akan
mengembalikan nilai negatif).
Berikut merupakan contoh cara request api pada Google Maps Elevation API:
https://maps.googleapis.com/maps/api/elevation/json?locations=39.
7391536,-104.9847034&key= YOUR_API_KEY
NB : penggunaan Api pada Google Maps Elevation API harus disertai Api key yang
di dapat dari google agar bisa menggunakannya
Berikut merupakan contoh respon api pada Google Maps Elevation API:
{
"results" : [
{
"elevation" : 1608.637939453125,
"location" : {
"lat" : 39.73915360,
"lng" : -104.98470340
},
"resolution" : 4.771975994110107
}
],
"status" : "OK"
}
Berikut merupakan contoh cara request api pada Google Maps Elevation API:
https://maps.googleapis.com/maps/api/directions/json?origin=Disn
eyland&destination=Universal+Studios+Hollywood4&key= YOUR_API_KEY
NB : penggunaan Api pada Google Maps Directions API harus disertai Api key
yang di dapat dari google agar bisa menggunakannya
Berikut merupakan contoh respon api pada Google Maps Directions API:
{
"geocoded_waypoints" : [
{
"geocoder_status" : "OK",
"place_id" : "ChIJRVY_etDX3IARGYLVpoq7f68",
"types" : [
"bus_station",
"transit_station",
"point_of_interest",
"establishment"
]
},
{
"geocoder_status" : "OK",
"partial_match" : true,
"place_id" : "ChIJp2Mn4E2-woARQS2FILlxUzk",
"types" : [ "route" ]
}
],
"routes" : [
{
"bounds" : {
"northeast" : {
"lat" : 34.1330949,
"lng" : -117.9143879
},
"southwest" : {
"lat" : 33.8068768,
"lng" : -118.3527671
}
},
"copyrights" : "Map data ©2016 Google",
"legs" : [
{
"distance" : {
"text" : "35.9 mi",
"value" : 57824
},
"duration" : {
"text" : "51 mins",
"value" : 3062
},
"end_address" : "Universal Studios Blvd, Los
Angeles, CA 90068, USA",
"end_location" : {
"lat" : 34.1330949,
"lng" : -118.3524442
},
"start_address" : "Disneyland (Harbor Blvd.), S
Harbor Blvd, Anaheim, CA 92802, USA",
"start_location" : {
"lat" : 33.8098177,
"lng" : -117.9154353
},
Berikut merupakan contoh cara request api pada Google Maps Geocoding API:
https://maps.googleapis.com/maps/api/geocode/json?address=1600+Am
phitheatre+Parkway,+Mountain+View,+CA&key= YOUR_API_KEY
NB : penggunaan Api pada Google Maps Geocoding API harus disertai Api key
yang di dapat dari google agar bisa menggunakannya
Berikut merupakan contoh respon api pada Google Maps Geocoding API:
{
"results" : [
{
"address_components" : [
{
"long_name" : "1600",
"short_name" : "1600",
"types" : [ "street_number" ]
},
{
"long_name" : "Amphitheatre Pkwy",
"short_name" : "Amphitheatre Pkwy",
"types" : [ "route" ]
},
{
"long_name" : "Mountain View",
"short_name" : "Mountain View",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Santa Clara County",
"short_name" : "Santa Clara County",
"types" : [ "administrative_area_level_2",
"political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
},
{
"long_name" : "94043",
"short_name" : "94043",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "1600 Amphitheatre Parkway,
Mountain View, CA 94043, USA",
"geometry" : {
"location" : {
"lat" : 37.4224764,
"lng" : -122.0842499
},
"location_type" : "ROOFTOP",
"viewport" : {
"northeast" : {
"lat" : 37.4238253802915,
"lng" : -122.0829009197085
},
"southwest" : {
"lat" : 37.4211274197085,
"lng" : -122.0855988802915
}
}
},
"place_id" : "ChIJ2eUgeAK6j4ARbn5u_wAGqWA",
"types" : [ "street_address" ]
}
],
"status" : "OK"
}
5. Google Maps Geolocation API
Google Maps Geolocation API mengembalikan radius akurasi dan lokasi
berdasarkan informasi tentang menara BTS dan simpul WiFi yang bisa dideteksi
oleh ponsel klien. Dokumen ini menjelaskan protokol yang digunakan untuk
mengirimkan data ini ke server dan mengembalikan respons kepada klien.
Berikut merupakan contoh cara request api pada Google Maps Geolocation:
https://www.googleapis.com/geolocation/v1/geolocate?key= YOUR_API
_KEY
NB : penggunaan Api pada Google Maps Geocoding API harus disertai Api key
yang di dapat dari google agar bisa menggunakannya
{
"homeMobileCountryCode": 310,
"homeMobileNetworkCode": 410,
"radioType": "gsm",
"carrier": "Vodafone",
"considerIp": "true",
"cellTowers": [
// See the Cell Tower Objects section below.
],
"wifiAccessPoints": [
// See the WiFi Access Point Objects section below.
]
}
Berikut merupakan contoh cara request api pada Google Maps Roads API:
https://roads.googleapis.com/v1/nearestRoads?points=60.170880,24.
942795|60.170879,24.942796|60.170877,24.942796&key= YOUR_API_KEY
NB : penggunaan Api pada Google Maps Roads API harus disertai Api key yang
di dapat dari google agar bisa menggunakannya
Berikut merupakan contoh respon api pada Google Maps Roads API:
{
"snappedPoints": [
{
"location": {
"latitude": 60.170877918672588,
"longitude": 24.942699821922421
},
"originalIndex": 0,
"placeId": "ChIJNX9BrM0LkkYRIM-cQg265e8"
},
{
"location": {
"latitude": 60.170876898776406,
"longitude": 24.942699912064771
},
"originalIndex": 1,
"placeId": "ChIJNX9BrM0LkkYRIM-cQg265e8"
},
{
"location": {
"latitude": 60.170874902634374,
"longitude": 24.942700088491474
},
"originalIndex": 2,
"placeId": "ChIJNX9BrM0LkkYRIM-cQg265e8"
}
]
}
7. Google Maps Time Zone API
Google Maps Time Zone API menyediakan data perbedaan waktu untuk semua
lokasi di permukaan bumi. Anda meminta informasi zona waktu untuk pasangan
garis lintang/bujur tertentu dan tanggalnya. API mengembalikan nama zona waktu,
perbedaan waktu dari UTC, dan perbedaan waktu di musim panas.
Berikut merupakan contoh cara request api pada Google Maps Time Zone API :
https://maps.googleapis.com/maps/api/timezone/json?location=38.90
8133,-77.047119×tamp=1458000000&key= YOUR_API_KEY
NB : penggunaan Api pada Google Maps Time Zone API harus disertai Api key
yang di dapat dari google agar bisa menggunakannya
Berikut merupakan contoh respon api pada Google Maps Time Zone API:
{
"dstOffset" : 3600,
"rawOffset" : -18000,
"status" : "OK",
"timeZoneId" : "America/New_York",
"timeZoneName" : "Eastern Daylight Time"
}
Berikut merupakan contoh cara request api pada Google Places API Web Service:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?locatio
n=-
33.8670,151.1957&radius=500&types=food&name=cruise&key=YOUR_API_KEY
{
"debug_log" : {
"line" : []
},
"html_attributions" : [],
"logging_info" : {
"experiment_id" : [],
"query_geographic_location" : "AU"
},
"results" : [
{
"geometry" : {
"location" : {
"lat" : -33.86879,
"lng" : 151.194217
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
"id" : "21a0b251c9b8392186142c798263e289fe45b4aa",
"name" : "Rhythmboat Cruises",
"opening_hours" : {
"open_now" : false,
"weekday_text" : []
},
"photos" : [
{
"height" : 426,
"html_attributions" : [
"\u003ca
href=\"https://www.google.com/maps/views/profile/104066891898402903288\"\u003eRhythmbo
at Cruises\u003c/a\u003e"
],
"photo_reference" : "CmRdAAAA-YL_I ...photo_reference truncated in this example",
"width" : 640
}
],
"place_id" : "ChIJyWEHuEmuEmsRm9hTkapTCrk",
"reference" : "CnRmAAAAvQl ...reference truncated in this example",
"scope" : "GOOGLE",
"types" : [ "restaurant", "food", "point_of_interest", "establishment" ],
"vicinity" : "Pyrmont Bay Wharf (Near Australia Maritime Museum), Pyrmont, NSW 2009"
},
{
"geometry" : {
"location" : {
"lat" : -33.867591,
"lng" : 151.201196
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
{
"geometry" : {
"location" : {
"lat" : -33.867591,
"lng" : 151.201196
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
"id" : "a97f9fb468bcd26b68a23072a55af82d4b325e0d",
"name" : "Australian Cruise Group",
"opening_hours" : {
"open_now" : false,
"weekday_text" : []
},
"photos" : [
{
"height" : 1331,
"html_attributions" : [
"\u003ca
href=\"https://www.google.com/maps/views/profile/110751364053842618118\"\u003eAustralian
Cruise Group\u003c/a\u003e"
],
"photo_reference" : "CmRdAAAAtEo ...photo_reference truncated in this example",
"width" : 2000
}
],
"place_id" : "ChIJrTLr-GyuEmsRBfy61i59si0",
"reference" : "CnRqAAAAFbuk ...reference truncated in this example",
"scope" : "GOOGLE",
"types" : [
"restaurant",
"travel_agency",
"food",
"point_of_interest",
"establishment"
],
"vicinity" : "32 The Promenade, King Street Wharf 5, Sydney"
},
{
"geometry" : {
"location" : {
"lat" : -33.870943,
"lng" : 151.190311
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/bar-71.png",
"id" : "e644f7f34cf875b9919c6548f1b721947362850a",
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/bar-71.png",
"id" : "e644f7f34cf875b9919c6548f1b721947362850a",
"name" : "Lunch Cruise with Jazz on Sydney Harbour",
"opening_hours" : {
"open_now" : false,
"weekday_text" : []
},
"photos" : [
{
"height" : 292,
"html_attributions" : [
"\u003ca
href=\"https://www.google.com/maps/views/profile/105423912060796272053\"\u003eFrom a
Google User\u003c/a\u003e"
],
"photo_reference" : "CmRdAAAAR4bq ...photo_reference truncated in this example",
"width" : 438
}
],
"place_id" : "ChIJLfySpTOuEmsRPCRKrzl8ZEY",
"reference" : "CoQBewAAAFd2 ...reference truncated in this example",
"scope" : "GOOGLE",
"types" : [ "bar", "restaurant", "food", "point_of_interest", "establishment" ],
"vicinity" : "37 Bank St, Pyrmont"
}
],
"status" : "OK"
}
Berikut merupakan contoh cara request api pada Google Cloud Translation API :
curl -s -X POST -H "Content-Type: application/json" \
-H "Authorization: Bearer "$(gcloud auth print-access-token) \
--data "{
'q': 'The Great Pyramid of Giza (also known as the Pyramid of Khufu or the
Pyramid of Cheops) is the oldest and largest of the three pyramids in
the Giza pyramid complex.',
'source': 'en',
'target': 'es',
'format': 'text'
}" "https://translation.googleapis.com/language/translate/v2"
Berikut merupakan contoh respon api pada Google Cloud Translation API:
{ "data": {
"translations": [ {
} ] }}
Status: 200 OK
{
"login": "octocat", "id": 1,
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User", "site_admin": false, "name": "monalisa octocat",
"company": "GitHub", "blog": "https://github.com/blog", "location": "San
Francisco", "email": "octocat@github.com", "hireable": false,
"bio": "There once was...", "public_repos": 2, "public_gists": 1,
"followers": 20, "following": 0,
"created_at": "2008-01-14T04:33:35Z",
"updated_at": "2008-01-14T04:33:35Z",
"total_private_repos": 100, "owned_private_repos": 100,
"private_gists": 81, "disk_usage": 10000,
"collaborators": 8, "two_factor_authentication": true,
"plan": {
"name": "Medium",
"space": 400,
"private_repos": 20,
"collaborators": 0
}, "node_id": "MDQ6VXNlcjU4MzIzMQ==" }
11. Google Shortener ( Shortener Url Api )
Google Shortener Url API adalah layanan dari Google yang dapat
memperpendek/meringkas url yang panjang menjadi url pendek dan mudah di
ingat/dibagikan.
Berikut merupakan contoh cara request api pada Google Shortener Url API :
curl https://www.googleapis.com/urlshortener/v1/url \
-H 'Content-Type: application/json' \
-d '{"longUrl": "http://www.google.com/"}'
Berikut Responnya :
"kind": "urlshortener#url",
"id": "http://goo.gl/fbsS",
"longUrl": "http://www.google.com/"
curl 'https://www.googleapis.com/urlshortener/v1/url?shortUrl=http://goo.gl/fbsS'
Berikut Responnya :
{ "kind": "urlshortener#url",
"id": "http://goo.gl/fbsS",
"longUrl": "http://www.google.com/",
"status": "OK"}
13. Google Book ( Book Search Api )
Google Book Search API adalah layanan Api dari Google yang dapat
mengembalikan detail buku dari parameter judul yang diikirm.
Berikut merupakan contoh cara request api pada Google Book Search API :
GET https://www.googleapis.com/books/v1/volumes?q=flowers+inauthor:keyes&key=yourAPIK
ey
Berikut Responnya :
200 OK
{
"kind": "books#volumes",
"items": [ {
"selfLink": "https://www.googleapis.com/books/v1/volumes/_ojXNuzgHRcC",
"selfLink": "https://www.googleapis.com/books/v1/volumes/RJxWIQOvoZUC",
], ... }, {
"selfLink": "https://www.googleapis.com/books/v1/volumes/zaRoX10_UsMC",
"totalItems": 3
}
14. Blogger (Retrieving blog with blog id Api )
Api ini digunakan untuk mendapatakan detail informasi blog dengan mengirimkan
id blog sebagai parameternya.
Berikut merupakan contoh cara request apinya :
GET https://www.googleapis.com/blogger/v3/blogs/2399953?key=YOUR-API-KEY
ey
Berikut Responnya :
"url": "http://buzz.blogger.com/",
"selfLink": "https://www.googleapis.com/blogger/v3/blogs/2399953",
"posts": {
},
"pages": {
},
"locale": {
https://www.googleapis.com/blogger/v3/blogs/byurl?url=http://code.blogger.com/
ey
Berikut Responnya :
"published": "2007-02-09T10:13:10-08:00",
"updated": "2012-04-15T19:38:01-07:00",
"url": "http://code.blogger.com/",
"selfLink": "https://www.googleapis.com/blogger/v3/blogs/3213900",
"posts": {
},
"pages": {
},
"locale": {
GET
https://www.googleapis.com/blogger/v3/blogs/2399953/posts/7706273476706534553?key=YO
UR-API-KEY
ey
Berikut Responnya :
"url": "http://buzz.blogger.com/2011/08/latest-updates-august-1st.html",
"selfLink":
"https://www.googleapis.com/blogger/v3/blogs/2399953/posts/7706273476706534553",
"author": {
"url": "http://www.blogger.com/profile/01430672582309320414",
"replies": {
}}
17. Blogger (Adding a post Api )
Api ini digunakan untuk mengirimkan sebuah postingan ke blog.
Berikut merupakan contoh cara request apinya :
POST https://www.googleapis.com/blogger/v3/blogs/8070105920543249955/posts/
Content-Type: application/json
Berikut Responnya :
"id": "8070105920543249955" },
"url": "http://brettmorgan-test2.blogspot.com/2012/05/new-post.html",
"selfLink":
"https://www.googleapis.com/blogger/v3/blogs/8070105920543249955/posts/68191003298967980
58",
"url": "http://www.blogger.com/profile/16258312240222542576",
DELETE
https://www.googleapis.com/blogger/v3/blogs/8070105920543249955/posts/68191003298967980
58
HTTP 200 OK
Berikut Responnya :
"data": [
"created_time": "2017-12-08T01:08:57+0000",
"id": "820882001277849_1805191182846921"
},
"created_time": "2017-12-07T20:06:14+0000",
"id": "820882001277849_1804966026202770"
},
"created_time": "2017-12-07T01:29:12+0000",
"message": "Plz play the old commercial’s with the polar bears.
Would be nice to see them this holiday",
"id": "820882001277849_1804168469615859"
}
21. domainsdb.info api (Check Status of registered domain)
Api ini digunakan untuk mendapatkan mengecek status dan detail dari domain
yang teresgritasi dengan mengirimkan nama domainnya sebagai parameternya.
Berikut merupakan contoh cara request apinya :
GET https://api.domainsdb.info/search?query=ganool.movie&tld=all
Berikut Responnya :
{
"total": 1,
"time": 12,
"domains": [
{
"hasWhois": 0,
"country": null,
"NS": "lars.ns.cloudflare.com,sharon.ns.cloudflare.com",
"domain": "ganool.movie",
"expiry_date": null,
"create_date": null,
"update_date": "2018-01-11T07:10:22.286Z",
"isDead": false
}
]
}
Daftar Pustaka
https://developers.google.com/maps/documentation/?hl=id
https://cloud.google.com/translate/docs/quickstart
https://developers.google.com/url-shortener/v1/getting_started
https://developers.google.com/books/docs/v1/using
https://developers.facebook.com/docs/graph-api/using-graph-api/
https://any-api.com/
https://developers.google.com/blogger/docs/3.0/using