Understanding REST and
JSON
Here you will learn about the REST based API and Interpret JSON encode
data.
REST – Based API
Applications in SDN uses API to communicate between them.
Again API is an application made by an application for the use of different applications
REST-Based (RESTful) APIs
REST API includes six attributes.
■ Client/server architecture
■ Stateless operation
■ Clear statement of cacheable/un cacheable
■ Uniform interface
■ Layered
■ Code-on-demand
We will discuss one by one in further slides
Client/Server Architecture
REST API uses a client server model where the client can request any information
which server has in it.
Stateless Operation
Each API request and reply does not use any other past history considered when
processing the request.
For comparison, the TCP protocol uses a stateful approach, whereas UDP uses
stateless operation.
Cacheable (or Not)
This you might have normally heard in the web browsers when you login to a web
browser the page consists of variety of objects like logo, video, photos etc., So it is good
to keep the non changing stuffs from the website to our device to use in future, the
server marks a object as cacheable.
REST APIs require that any resource requested via an API call have a clear method by
which to mark the resource as cacheable or not.
Background: Data and Variables
Programs then process data by making comparisons, making decisions, creating new
variables, and performing mathematical formulas to analyze the data.
List and Dictionary Variables
List is a variable to store list of values and Dictionary is a variable to which can store
a meaning for a word like student and roll number details
REST APIs and HTTP
API exist between two programs so that they can communicate, when the programs are
in same system they can communicate within single operating system but what if they
are not in same system hence API has to use a protocol to exchange the values and it
uses HTTP.
Why HTTP :
It uses attributes similar to REST API
It operates in Client Server model
It uses Stateless operation.
It includes header to mark an object as cacheable or not.
I has HTTP request and reply similar to how application like to work.
Software CRUD actions and HTTP Verbs
In software we use a memorable acronym called CRUD to define 4 primary actions
performed by an application.
Data Serialization and JSON
Representing a variable with a text would be a great relief in understanding a language.
Data serialization languages give us a way to represent variables with text rather than
in the internal representation used by any particular programming language.
The Need for a Data Model with APIs
Data Serialization Languages
JSON
JavaScript Object Notation attempts to strike a balance between human and machine
readability. Armed with a few JSON rules, most humans can read JSON data, move
past simply guessing at what it means, and confidently interpret the data structures
defined by the JSON data.