Skip to content

techwriterjoe/restful-api-beginner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 

Repository files navigation

Using a RESTful API for a Beginner

The Facebook Graph API allows developers to receive data, post data, or rearrange items on Facebook's web pages. The API categorizes Facebook pages into three areas:

Name Description
Nodes Nouns or objects. Often something
that can be seen visually on a page
Edges The connections or linking between
the nodes or objects
Fields Available data on the nodes

Similar to other social media RESTful APIs, data for a specific page, or even node, can be requested through a web link. For example, place the address graph.facebook.com/comcast into a web browser. A page with numerous return results should appear. Pictured below is the data received from the API call and actual Comcast Facebook page:

Graph API Comcast

Notice some of the Graph API's results and compare them to the actual page:

  • Listed on both is the number of likes, 352
  • Listed on both is the company website
  • From the API's results, Facebook has categorized Comcast as a company

##RESTful APIs Typically Have Four Actions

  1. GET: to recieve data from the source, already demonstrated with the Comcast Facebook page
  2. POST: sends completely new data
  3. PUT: updates existing data
  4. DELETE: deletes existing data on the source
  5. Stay away from the term "request" when describing any four of these actions
  6. GET is similar to the traditional "getter"
  7. POST and PUT are similar to the traditional term "setter"

Facebook's Graph API has SDKs for many CS languages. To start examing what a RESTful API call looks like, examine the JavaScript below:

var xhr = new XMLHttpRequest();
xhr.open("GET", "http://graph.facebook.com/comcast", false);
xhr.send();
console.log(xhr.status);

This article will be lengthened in the future. Hope you enjoyed the read so far.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published