"Application Programming Interface"
IMG
|
1993 | Mosaic |
SCRIPT
|
1995 | Netscape & Sun (RIP) |
IFRAME
|
1996 | Microsoft |
OBJECT/EMBED
|
1996 | Netscape/W3C |
XMLHttpRequest
|
1999 | Microsoft/W3C |
<img src="http://otherdomain.com/service?param=x&otherparam=y">
<img src="http://counter.digits.net/?
counter={d5ba6c4f-bd07-cb84-5583-0f90772b9dff}&
template=simple">
<img src="http://otherdomain.com/service?param=x&otherparam=y">
?
param=x
&
otherparam=y
<img src="
http://maps.google.com/maps/api/staticmap?
center=48.8584,2.2945&
zoom=16&
maptype=satellite&
size=250x300&
sensor=false">
<img src="
http://maps.googleapis.com/maps/api/streetview?
size=300x250&
location=51.5030943,-0.1778232&
fov=90&
heading=370&
pitch=-20&
sensor=false">
Read more: Google Static Maps API | Google Street View Image API
<img width="550" height="250" src="
http://chart.apis.google.com/chart?
cht=p&
chs=550x250&
chd=t:10,80,10&
chco=FAFAFA,FFFF00,FAFAFA&
chl=Does%20not%20resemble%20Pac-man|Resembles%20Pac-man&
chtt=Percentage%20of%20Google%20Chart%20Which%20Resembles%20Pac-man">
Read more: Google Charts API
Docs
Note the deprecation notice!
<iframe src="http://apidomain.com/widget.html"></iframe>
<iframe width="420" height="315"
src="https://www.youtube.com/embed/epUk3T2Kfno?rel=0&autoplay=1"
frameborder="0" allowfullscreen></iframe>
<script src="http://apidomain.com/library.js"></script>
<script>
apiNamespace.apiFunction();
</script>
window.apiNamespace.apiFunction = function() {
// Do exciting API thing here
// Maybe using images or iframes, too.
}
<a href="https://www.pinterest.com/pin/create/button/">
<img src="//assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png">
</a>
<script
type="text/javascript"
async defer
src="//assets.pinterest.com/js/pinit.js"></script>
<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_shortname = 'otherfancystuff';
var disqus_developer = 1;
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
More reading: Disqus Universal Code Docs
Examples: Shiba Another cute Shiba
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://apidomain.com/method?param=bla');
xhr.onreadystatechange = function() {
if(xhr.readyState == 4 && xhr.status==200) {
var data = xhr.responseText;
}
};
xhr.send();
<script src="https://gdi-jsonp.herokuapp.com/app.php?callback=onLoadData">
</script>
<script>
function onLoadData(json) {
$('#demo').html('YO YO YO ' + json.name);
}
</script>
<?php
$callback = $_GET['callback'];
echo $callback . "({'name': 'Girl Develop It'});";
?>
Example URL: http://www.reddit.com/search.json?q=girldevelopit
function onLoad(json) {
var posts = json.data.children;
console.log(posts);
document.body.innerHTML = posts[0].data.title;
}
function fetchJSON(query) {
var script = document.createElement('script');
script.src = 'https://www.reddit.com/search.json?q='
+ query + '&jsonp=onLoad';
document.getElementsByTagName('body')[0].appendChild(script);
}
fetchJSON('girldevelopit');
function fetchPhotos(query) {
$.ajax({
url: 'https://api.flickr.com/services/rest/',
data: {api_key: 'a0de4a213ab1191732ec4db4daf586a3',
method: 'flickr.photos.search',
tags: query, per_page: '6', format: 'json'},
dataType: 'jsonp',
jsonp: 'jsoncallback',
success: function(json){
var photos = json.photos.photo;
for (var i = 0; i < photos.length; i++) {
var photo = photos[i];
var photoUrl = 'http://farm' + photo.farm + '.static.flickr.com/' + photo.server + '/' + photo.id + '_' + photo.secret + '_' + 'm.jpg';
$('#demo').append('<img src="' + photoUrl + '">');
}
}
});
}
fetchPhotos('rabbits');
See also: jQuery .ajax() | Flickr API | JSBin example
...they do it all!
See also: ProgrammableWeb.com API Directory
function synonymify(word) {
var url = 'https://api.wordnik.com/v4/word.json/' + word + '/related';
var params = {
'api_key': '98479a51ec674585e400609183c0e5d78bd7b4eba8a8810b4',
'type': 'synonym',
'partOfSpeech': 'adjective'
}
JSONP.get(url, params, null, function(json) {
var synonyms = json[0].words;
for (var i = 0; i < synonyms.length; i++) {
$('#demo').append(synonyms[i] + '
');
}
});
}
synonymify('awesome');
See also: Wordnik API | ProgrammableWeb