Leonardo Balter - @leobalter
APIs são Interfaces de Programação de uma Aplicação que possibilitam criarmos interações externas.
No caso da Web, são interfaces para interagirmos com o navegador e em JavaScript!
Acredite, vocês já usaram APIs web, mesmo que achem que isso nunca aconteceu!
document.getElementById( 'raa' );
Ref. do DOM: https://developer.mozilla.org/en-US/docs/DOM/DOM_Reference
var b = navigator.battery,
level = Math.round(b.level * 100) + "%",
charging = (b.charging) ? "" : "not ",
chargeTime = parseInt(b.chargingTime / 60, 10),
dischargeTime = parseInt(b.dischargingTime/60,10);
b.addEventListener("levelchange", show);
b.addEventListener("chargingchange", show);
b.addEventListener("chargingtimechange", show);
b.addEventListener("dischargingtimechange", show);
Há uma lista na MDN com várias APIs disponíveis: https://developer.mozilla.org/en-US/docs/Web/API
Outra referência: MDN: Guide to Web APIsvar context = new window.AudioContext();
var request = new XMLHttpRequest();
request.open("GET", audioFileUrl, true);
request.responseType = "arraybuffer";
request.onload = function() {
var audioData = request.response;
createSoundSource(audioData);
};
request.send();
Ref.: http://www.html5rocks.com/en/tutorials/webaudio/games/var audioElement = document.querySelector('audio');
var mediaSourceNode =
context.createMediaElementSource(audioElement);
var filter = context.createBiquadFilter();
mediaSourceNode.connect(filter);
filter.connect(context.destination);
Ref.: https://github.com/kallaspriit/HTML5-JavaScript-Gamepad-Controller-Librarywindow.addEventListener('gamepadconnected', function(e) {
e.gamepad; // => Ta tudo aqui!
});
navigator.getUserMedia({ video: true, audio: false },
function(localMediaStream) {
var video = document.querySelector('video');
video.src =
window.URL.createObjectURL(localMediaStream);
video.play();
},
function(err) { throw 'ferrou'; }
});