APIs Flashcards

1
Q

API

A
  • Application Programming Interface

- ability to connect to a third-party web site like YouTube or Twitter and request content

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

API Key

A
  • lets a web dev connect with a third party API like Google Maps
  • lets a web site limit access to its API
  • lets a web site track use of its API and charge money for its use
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

JSONP

A
  • JSON with Padding
  • a way of sending data in a JavaScript file
  • a method for requesting data from another web server by bypassing a web browser’s “same origin policy”

blah.com/blah.gne?format=json

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

$(“button”).click(function () {
$(“button).removeClass(“selected”);
$(this).addClass(“selected”);

var flickerAPI = "URL"
var animal = $(this).text();
var flickerOptions = {
tags: animal,
format: "json"
};
function displayPhotos(data) {
var photoHTML = '<ul>;
$.each(data.items, function (i, photo) {
photoHTML += '<li class="blah">';
photoHTML += '<a href="'%20+%20photo.link%20+%20'" class="image">;
photoHTML +='<img></a></li>;
});

photoHTML += ‘</ul>’;
$(‘#photos’).html(photoHTML);
}

$.getJSON(flickerAPI, flickerOptions, displayPhotos);
});

A
  • adds a click event handler to all HTML button elements
  • removes the class “selected”
  • adds the class “selected” to the particular button getting clicked
  • retrieves the text inside within the ID of “button” and stores it in the variable “animal”
  • tags = searches for photos that match a particular keyword
  • format = specifies the format for the feed, for example an XML or JSON format
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

http://blah.gen?jsoncallback=?

A
  • query string getting around security limitation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

$.each(array or object, function (i, item) {});

A
  • loop
  • each = array or object, callback function
  • function = index, value of the current array
How well did you know this?
1
Not at all
2
3
4
5
Perfectly