Very first thing to mention, JSON is not an API but a data format webservices and programs use to communicate to each other.
Webservices can be of many forms but most popular are REST and SOAP. Webservices give you a way to interact with remote machines and communicate with them.
To read more about Json, visit http://www.json.org/ , http://en.wikipedia.org/wiki/Json
And to read more about Webservices, visit, http://en.wikipedia.org/wiki/Webservices
Answer from itsaboutcode on Stack OverflowVery first thing to mention, JSON is not an API but a data format webservices and programs use to communicate to each other.
Webservices can be of many forms but most popular are REST and SOAP. Webservices give you a way to interact with remote machines and communicate with them.
To read more about Json, visit http://www.json.org/ , http://en.wikipedia.org/wiki/Json
And to read more about Webservices, visit, http://en.wikipedia.org/wiki/Webservices
Though the question is a little vague, I will assume that it's about JSON:API vs REST. JSON:API is a specification for using JSON whereas REST is an architecture pattern.
The JSON: API spec is compatible with REST which means they are not mutually exclusive and can be considered complementary to each other.
At a high level:
To interface with a REST API, make HTTP requests using the standard methods (or verbs) to endpoints (specific URIs) provided by the service. Ideally thse endpoints will be documented in a way that any consumer can easily understand (such as the Open API spec). How you parse the results depends on what the results are. They could be JSON, XML, HTML or plaintext.
To interface with a JSON:API you will need to make HTTP requests using its specific MIME type ad follow the recommended schema from the specification. To parse the result you will need to use the relevant methods or packages your programming language of choice provides. In JavaScript it's JSON.parse
Videos
Basically... Are most or all REST API's just JSON data?
Im noticing that any public REST API I look at (google maps, github, etc...) is just an array of javascript objects.
So, is that true? Are REST API's always just data in JSON format?
Thanks!
REST (Representational State Transfer) is a vague architectural design pattern which was first written about in a paper by Roy Fieldings (aka the guy who created HTTP).
Most of the time (99% of the time) when somebody wants a REST API they mean they want a web API where they send a Request containing an HTTP verb and a URL which describes the location of a Resource that will be acted upon by the HTTP verb. The web server then performs the requested verb on the Resource and sends back a Response back to the user. The Response will usually (depending on the HTTP verb used) contain a Representation of the resulting Resource. Resources can be represented as HTML, JSON, XML or a number of other different mime types.
Which representation used in the response doesn't really indicate whether an API is RESTful or not; it's how well the interface's URLs are structured and how the web server's behaviors are defined using the HTTP Verbs. A properly compliant REST API should use a GET verb to only read a resource, a POST verb to modify a resource, a PUT to add/replace a resource, and a DELETE to remove a resource. A more formal definition of the expected verb behaviors are listed in the HTTP Specification.
REST is (in a nutshell) a paradigm that resources should be accessible through a URI and that HTTP-like verbs can be used to manipulate them (that is to say, HTTP was designed with REST principles in mind). This is, say, in contrast to having one URI for your app and POSTing a data payload to tell the server what you want to achieve.
With a rough analogy, a filesystem is usually RESTful. Different resources live at different addresses (directories) that are easy to access and write to, despite not being necessarily stored on disk in a fashion that reflects the path. Alternatively, most databases are not RESTful - you connect to the database and access the data through a declarative API, rather than finding the data by a location.
As far as what the resource is - HTML, JSON, a video of a waterskiing squirrel - that is a different level of abstraction than adhering to RESTful principles.