Yelp GraphiQL API - GraphQL - REST - SOAP

API stands for Application Programming Interface. According to Wikipedia.org, "...Application Programming Interface (API) is a set of subroutine definitions, protocols, and tools for building application software. In general terms, it is a set of clearly defined methods of communication between various software components. A good API makes it easier to develop a computer program by providing all the building blocks, which are then put together by the programmer..." (https://en.wikipedia.org/wiki/Application_programming_interface)

History of APIs

SOAP (Simple Object Access Protocol)

SOAP (Simple Object Access Protocol) is a messaging protocol that allows programs that run on disparate operating systems (such as Windows and Linux) to communicate using Hypertext Transfer Protocol (HTTP) and its Extensible Markup Language (XML). SOAP was one of the first APIs used online with HTTP and XML. 

RESTful API

REST API is still a major player but requires one to define many routes for a query. Often times many endpoints need to be called in order to acquire the proper information.

An architectural style called REST (Representational State Transfer) advocates that web applications should use HTTP as it was originally envisioned. Lookups should use GET requests. PUT, POST, and DELETE requests should be used for creation, mutation, and deletion.

REST proponents tend to favor URLs, such as

http://webcarpenter.com/catalog/item/1729

but the REST architecture does not require these “pretty URLs”.

GraphQL

GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools.

Github GraphQL API

https://developer.github.com/

 

Yelp GraphiQL - GraphQL APIYelp 1200x630bb

https://www.yelp.com/developers/graphiql

GraphiQL is an in-browser tool for writing, validating, and testing GraphQL queries.

Auto Complete:  Ctrl-Space (or just start typing)

Type queries into this side of the screen, and you will see intelligent typeaheads aware of the current GraphQL type schema and live syntax and validation errors highlighted within the text.

 

An example GraphQL query might look like:

# GraphQL queries typically start with a "{" character. Lines that starts 
# with a # are ignored.
{
    field(arg: "value")
      subField
    }
}

Using the Yelp GraphQL queries can be tricky, but here are some helpful tips.

Search by term "burrito" and location "san francisco" Yelp GraphQL query

{
search(term:"burrito",
location:"san francisco") {
total
business {
name
reviews {
text
rating
time_created
url
}
}
}
}

Search by category "food" near a specified latitude and longitude

query {
search(latitude:37.0965, longitude: -113.5684, categories:"food", radius: 20000) {
business {
id
name
price
}
}
}

Advanced Yelp GraphiQL query with many resources

This searches by latitude and longitude for a particular category of a business. It provides a great deal of other information from Yelp.

query {
search(latitude:37.1032184, longitude: -113.5674376, categories:"food", limit: 50) {
business {
id
name
price
phone
url
coordinates {
latitude
longitude
}
location {
address1
address2
address3
city
state
zip_code
country
formatted_address
}
rating
}
}
}

More APIs

 

Visit sunny St. George, Utah, USA