All right.
Now that we have the models in place for this app, it's time to start building the API.
And when it comes to building, we really have two options.
The first is to sort of build everything out on our own.
And the second is to use something called the Django Reste framework.
It's not technically a part of the Django project, but it is by far the dominant way that people create
APIs in their projects.
So spoiler alert, we're gonna be creating it using the Django rest framework.
But I want to explore the first option a little bit.
What if you wanted to make an API all on your own?
You totally can.
But this is what you would be getting into.
Like let's say, for example, we want to have a Eurail where someone can view the top posts of the
day.
So they would have to go.
You'd have to go first.
Who are you?
URLs and make like a path for API slash top posts or something like that.
Right.
Then we would have to go and move into the view that we've connected there.
And we'd have to make a view that says, okay, when someone, you know, does a get request here,
then we're gonna go grab all the post objects.
We're going to order them.
And then, you know, those are currently Django models.
We're gonna have to decode those and turn it into Jason that we can then spit back to the user.
And really, that part wouldn't be too terrible, but it just gets worse from there.
So, for example, what happens when someone wants to create one of these?
Let's say they want to, you know, create a post using the API?
Well, we have to know what user they are.
So we have to sort of custom build the authentication here because Django has built in authentication,
but it assumes that they're using a browser.
Once we get past that, we're gonna say, you know, what things do we want them to be able to submit
because we don't want them, for example, to be able to say when it was created.
That's something we should automatically do.
And so we kind of have to, you know, customize how this is all going to come out.
We're going to have to save that information.
Derg, the user is going to be passing us, Jason.
So we take that Jason Decoded, turn it into a model, then save it into the database.
These things are all possible, but it's a lot of work.
And what's so awesome is, like I said, there's an awesome project if you search for Django Rest. framework.
Should be the top result here.
Yes, Jango rest framework dot org.
And this is an amazing project preparing to teach this course.
I really started diving into the Web site here.
And there is so much that this framework can do for you.
And the awesome thing is that it can do a ton of things.
But if you want to stay really simple, you totally can't.
And that's what this course is going to be, as I'm going to show you what I feel like are the best
parts of this framework.
But if you ever want to go deeper after this course, I really recommend going through the tutorial
that they have here.
All six steps, because this will only get you started if you really want to dive in.
If you go hit the API guide.
Oh, my goodness.
There is so much.
So, again, this is bringing back to the point.
The word API is used everywhere, for example, when working with the different functions inside of
this framework.
They refer to that as the API for this framework.
But this framework helps you build an API.
So, again, it can get kind of confusing there.
But we're building a Web framework.
This is an eight of a Web API.
And this is an API for this particular framework.
And we don't don't get too messed up with all the different uses of API out there.
OK.
So now that you've seen this project, I'm again going to show you how to get this all installed.
What I feel like is the best way to do so.
So let's go ahead and move back to our project.
And the first thing that we have to do is install the project via PIP.
So let's go ahead and go to our command line.
I'm going to do PIP install and we have to do Django Rest. framework.
All one word, Django Rest. framework.
Once that is done, we are going to move into our settings.
OK.
And inside of our installed apps, we are going to also add here.
The rest underscore framework.
And really, that's all we need to get the project implemented into our code, like we now have access
to this rest framework.
That is going to be amazing.
You'll see in the next video how we set up here.
And I just want to spend one more second to make sure you're really comfortable with the terms being
used here.
You might be saying, why is this called the jingo reste framework?
Like, what does reste have to do with an API?
So a rest API is basically an API that follows some standards.
And if you go ahead and just Google Rest API, there's some really good resources out there.
And I'll just I haven't even looked at this, but I'm just picking the top one.
You'll basically see that the rest API is sort of follow a certain standard.
And so the big one is that there's certain ways that you can interact with that.
You can use get requests, post requests, puts patches deletes.
There's technically more.
But there's this whole sort of style about how you get to particular resources.
And the big thing when it comes to rest API is that they should be the system that is providing the
API and then the system that is consuming the API, meaning getting data from the API.
They should be able to work independently of each other.
It's not like one's always waiting on the other for another thing to happen.
That's the theory called stateless, meaning that, you know, these things can work independently of
each other with lots of times that have passed or could be right back next to each other.
You'll see all of that.
So anyways, if you want to get more into it, there's those different methods that I'd just talked
about.
And as it says here, these are the crud functions, meaning that get is when you're trying to read
something from an API post is when you're trying to create something in an API.
So, for example, get would be when we are trying to list out all the, you know, posts from the Zap
It site in a post request is when we want to create a post.
I know that's maybe not the best name there.
Right.
But when we're submitting a link write creating a post, we're gonna use a post request.
If we want to update something, we're gonna use a put or a patch.
And if we want to delete something, then we use the delete method.
So anyways.
Now, you know, the thing that we're gonna be using is the Django rest framework.
Hopefully you have a better idea of what Rest. API is.
Ah.
And we now have it installed into our project, so we're gonna go ahead and create our very first API
call in the next lecture.