Be yourself; Everyone else is already taken.
— Oscar Wilde.
This is the first post on my new blog. I’m just getting this new blog going, so stay tuned for more. Subscribe below to get notified when I post new updates.
Be yourself; Everyone else is already taken.
— Oscar Wilde.
This is the first post on my new blog. I’m just getting this new blog going, so stay tuned for more. Subscribe below to get notified when I post new updates.
In the recent times, The term “REST API” is commonly and widely used word across in IT workspaces as well in IT related blogs and vlogs.
So What is REST?… Well, if you want to know what it is?.. Then this post is for U…….
REST stands for REPRESENTATIONAL STATE TRANSFER
When a RESTful API (API that satifies REST Architecture) is called, the server will transfer a representation of state of the requested resource to the client.

The respresentation of the state can be in any format JSON, XML, HTML. Most widely used is JSON (JavaScript Object Notation)
Whenever a client sends the request, the request will be sent to the server. And then the server will returns the response for the sent request as the HTTP response message.
Widely used HTTP methods
GET – This method is used to retrieve the information from the resource.
POST – This is used to create resources.
PUT – This is used to updating the capability in the resources. This can be also used to create resource (But not recommended).
DELETE – This is used to delete a resources.
PATCH – This is used to modify the capability in the resources. Only the changes alone needs to be sent in the request.
“GET” method is commonly used HTTP method to retrieve/request/get the particular information from server.
Lets see an example of a basic HTTP GET request
require “net/http”
response = Net::HTTP.get_response("api.themoviedb.org","/3/movie/popular?api_key=1f6edcf7cdec1a1942d5d87e84a1ab89")
puts (response)
Note: We are using an library “net/http” which handles all HTTP request operations
output:
#<Net::HTTPOK 200 OK readbody=true>
Points to noted:
Here the response variable will be a object.
With reponse object , other details can be extracted.
Example
response.code # returns response code
response.body # returns body of the response
response.content_type # returns content type of the reponse body
Above output will be received when the above piece of code gets executed.
Whenever a request is sent, it will be sent to the server from client as a request message, which is received by the server and returns the response via response message.
Whenever a request is initiated, the requested URL will be divided in to 3 parts
Request Line – GET /3/movie/popular?api_key=1f6edcf7cdec1a1942d5d87e84a1ab89 HTTP/1.1
In above used example, GET is the method we used and the contents after host will be sent in the header
The client uses the optional request headers (such as Accept, Accept-Language, and etc) to negotiate with the server and ask the server to deliver the preferred contents (e.g., in the language that the client preferred).
Request Header – api.themoviedb.org
In the request header host name will sent
Request Message Body – Optional
Message body is optional, Here request can be sent to get the exact information or only needed details.
The received response can be divided in to 3 parts
Status Line
Status line will contains the status of the request
HTTPOK 200 OK
Response Header
This will get the details about the response such as content type of the response and other details that is sent by the server.
require “net/http”
response = Net::HTTP.get_response("api.themoviedb.org","/3/movie/popular?api_key=1f6edcf7cdec1a1942d5d87e84a1ab89")
puts(response.content_type)
Output:
application/json
The above part of code will give the output of the reponse content type which is one of content in response header.
Response Body
This will have the information above the contents of the response such as JSON, XML, HTML.
Bubye !!! This is the end of this post. In next post, Lets discuss on POST request method.
This is an example post, originally published as part of Blogging University. Enroll in one of our ten programs, and start your blog right.
You’re going to publish a post today. Don’t worry about how your blog looks. Don’t worry if you haven’t given it a name yet, or you’re feeling overwhelmed. Just click the “New Post” button, and tell us why you’re here.
Why do this?
The post can be short or long, a personal intro to your life or a bloggy mission statement, a manifesto for the future or a simple outline of your the types of things you hope to publish.
To help you get started, here are a few questions:
You’re not locked into any of this; one of the wonderful things about blogs is how they constantly evolve as we learn, grow, and interact with one another — but it’s good to know where and why you started, and articulating your goals may just give you a few other post ideas.
Can’t think how to get started? Just write the first thing that pops into your head. Anne Lamott, author of a book on writing we love, says that you need to give yourself permission to write a “crappy first draft”. Anne makes a great point — just start writing, and worry about editing it later.
When you’re ready to publish, give your post three to five tags that describe your blog’s focus — writing, photography, fiction, parenting, food, cars, movies, sports, whatever. These tags will help others who care about your topics find you in the Reader. Make sure one of the tags is “zerotohero,” so other new bloggers can find you, too.