Hey, did everyone at Asia and I know we have studied a lot of theory, but this is all important and
now it's time that we proceed further into our application.
So how are we going to do this?
We have already our board ready and now we understand a whole lot about this diagram that we initially
created, the route we know that gate requests are there on the gate.
We will be saying slash local host, port number, whatever that is, slash API, slash Instagram.
Now here's my small tip that I would like to recommend you for the production grade application.
In the usual case, you are going to see that people actually don't write it like slash API.
They go ahead and simply say Slash, V one and slash, what is this one?
The Suivent is the version one of the API.
Eventually, as you saw in the Express, that sometimes there are drastic changes that you want to do
in the application and they go ahead and change all of this like they are moving from two to 3 to 4
and now they are moving on to five.
So any application that you are building up that should also support that.
And if you are planning to support the legacy or the old users, then obviously this is one of the great
idea that you can have.
Now this should be consistent.
So in case you are going for this, then there should be av1 everywhere.
So we'll be using something like V one for Facebook just like this and obviously the V one for the LinkedIn
as well.
So let's go ahead and change this route.
Again, this is not really compulsory, but these are all things usually come from your supervisor,
your managers or some senior developers that what routes we are going to be following and how you're
are going to be working determination of what you are going to call your methods and determination of
what you are going to call your routes usually is the job of senior developers.
They do it very well.
But again, if in case you want to know that this is all it, we are going to take care of these three
things.
Greetings, home route.
We have already taken care of that.
Now here we need to create some of the JSON data this time.
So this one API, Instagram, Facebook and LinkedIn will be doing in this video maturity hopefully and
this one will take care of the later one.
Right now these three are our goal.
Moving on.
This route is all happy and all good.
I wouldn't be touching it further.
Let's go ahead and get more root.
The process is same.
We simply say that this will be a get request and what will be root so slash API slash V one.
And then we are going to say starting with of course, Instagram.
So Instagram, that's nice.
Okay.
And then we're going to say that you send me some request, I'll get you some response.
Both are available to me thanks to Express.
And we're going to go like this now.
We're going to simply say a response.
But before we create a response, let's go ahead and create a social object.
So let's go ahead and classic JavaScript.
We call it as insta social.
This is just a ordinary variable.
It will have some of the object values and this is an object.
So this can act as a JSON.
Now after that, we're going to simply say rez dot status because we are sending somebody something.
So let's go ahead and call it as 200 and then we are going to go ahead and simply send that.
Now, should I send it directly like that?
Probably not.
Let's go ahead and look into the documentation because we want to send some JSON response.
This time.
Let's go into the API guide and we want to go for response.
And we saw that there is a JSON and I can use a restart JSON and can send the JSON object just like
this key value pair.
Awesome.
This is exactly what I want.
So I'm going to go ahead and say that this time instead of the send, I'm going to go ahead and send
you a JSON.
And in the JSON, I'm going to just add an install social.
I can go ahead and write this just like this and say this is going to be my key, this is going to be
my value, something like this, but I don't want to do this.
Instead, I would love to pass on an object.
It would be easier for me.
So what are the three things that user is requesting from me?
User requesting that you need to give me a username, so let's give it a username.
Of course.
Mine username.
There we go.
Pretty long one and then let's pass on some of the followers and probably I have, let's just say 66
followers on Instagram and then we are going to say followers and what are the structure you need to
define?
You can go ahead and define that.
Ideally, I would be creating a model and all of that.
But wait a minute, this is just getting started.
We will do that, all of it.
And probably I'm following a whole lot of people.
I follow a lot of people on Instagram, probably like 70 people or something, and we haven't talked
yet about the date.
But one thing we still can do is let's just go ahead and say date and I can say date.
Now this is not going to be looking very elegant or good, but at least we'll have something.
Okay, so this is all the data that we have.
As soon as I save this, the server is up and running.
Now another route is ready, which is slash API, slash V1, slash Instagram.
The place to test it up obviously is postman not on the web browser.
So let's go ahead and work on with that.
So we'll be saying that, hey, I want to go ahead and use this one and make sure you are not using
extra slashes.
Be very cautious.
So localhost api v one instagram get request.
Absolutely.
Fine.
Don't need to care about params authorization or anything else at all.
Let's go ahead and hit the send and there we go.
Now we are receiving a status quo 200 and we are receiving an install social and object, which is an
object.
And you can find information further down.
If you want to directly send this information, you can just cut and paste that.
I'm pretty sure you are pretty much familiar with that.
What I mean to say by that, you can actually go ahead and copy this entire response and instead of
this instance social, I can just go ahead and remove this and can pass it on like that.
When I do so and I make a request like this, it just gives me a direct object with all the values.
Depends on how you want to follow up.
This is totally up to you.
I'm going to go ahead and say that I want to have a JSON which is just install social.
Now, can I do like this just as I save this?
Can I do this?
Yes, of course you can do this.
You are totally allowed to do this and you'll get the same result.
Did I save this?
Yep.
This time we are passing on the variable.
So all this is directly going in previously?
I don't know.
Somehow my editor added an extra curly braces.
Didn't want it that okay, this is all good.
So now what we need to do further down the road is just need to copy and paste.
I know this is not too good for the experienced developer, but we are beginners here.
So now we have get on the Facebook.
So let's go ahead and say somebody request a Facebook, I'll give him my Facebook ID, which is page
somehow.
And I have no idea how many followers I have on Facebook.
It's been long that I have opened it up, probably 88.
And how many people I follow?
I have no idea.
Ten date will be day dot.
Now for LinkedIn that I know LinkedIn and I have a username of I guess just hit a shot right there.
Not sure and followers I guess I'm on to some somewhat like a 200 though.
I don't know.
Precisely.
Okay, 80 and 80.
Now let's go ahead and check out all the routes.
Probably we will be able to see that.
So Instagram, this is my all Instagram update details.
And what about my Facebook details?
There we go.
Nice.
And what about my LinkedIn details?
And yes, I'm getting that the notice here.
A couple of things that we need to now change or enhance as a feature.
This date is okay, but it's not too much usable for the user, so I need to learn that how can I modify
this date so it's much more usable for the person?
That's my goal, number one.
And also apart from this, I still need to worry about one of the things which is still missing in my
application that how am I going to do this API v for or API V one, four or five or whatever this and
it should return that immediately.
So how I'm going to do that.
So a couple of things in in my position right now.
First thing, let's go ahead and take care about this date issue in the next video.