Okay.
In this video, I will show you how to use another tool for our API development.
And that tool is Postman.
I think it's most popular API development tool available on the market.
Now it is free so you can use it as you like.
And at the beginning I think Postman was ah, just a chrome extension, but now it's a standalone application.
So what you need to do is you go to the product and you have Postman here.
And then you can download the application and it's as simple as just next, next, next, next, and
install that on your operating system.
So once you will have the postman installed on your computer.
Now Postman is opening and we have a data interface available.
So what we can do here, we can do similar things as we've done in our previous video using this interface.
So if I will come back here to the books.
You can see that is the object I saw there.
If I copy that URL now, Ctrl C and I'll go to my postman and then I will paste it here.
So basically what we are doing is we are trying to fetch that data from, from that URL and here I can
select the method I would like to use.
I will keep it to get here and then I will send.
It looks what what I have here in the in the output basically it's what I had in the previous page.
But this time this is a typical Json text format available for me.
This is also based on serializer as we had it before and we see all that information.
So let's.
Come back here and let's add more.
If we go to the models, we have title description, price we can do, publish is published and then
cover.
We can leave the cover for now.
So we'll do this published.
And also we can do.
So publish is published.
If will add it now and then I will come back to the postman and refresh it.
You can see I have all that information available for each book in our database.
So that's one object.
And here is another one.
This brackets square brackets means beginning of array and add of array.
So that's what is available through serializer.
And this is what we use as a get.
What I can also do is I already mentioned that before that Django automatically include ID in our records.
So what I can do is I can also include that ID, so I will save it.
And if will come back here and refresh it, send it again.
You can see it is a part of this output.
So this is the method that we register in our router.
We'll come back to the URLs here and we can see this is register books with a view set.
So this view set brings more than just a list of the items in the database.
It has much more things built in and I will show you what other things are available.
So if we have ID one, I know the books, we have books with ID one and then I can pass one at the end
of the URL and then slash.
So basically books will give me all the list and if I will pass as an extra parameter the ID of the
books, then I will send it.
You can see only one record is returned with the ID one.
I can also do two, which is the second book with the ID two.
So basically that's already done for us.
We don't need to set up or configure anything using Methodget.
We can have both if I will have it without that ID.
The whole list.
We can pass ID and get the certain record.
So what else is available?
We can do post.
So if I will post to the books, we can post.
Using.
Like this form here and I will pick body and then this form.
Or we can do form data.
But what we need to do, we need to pass title and let's say our book will be Twilight.
To just stay him in the same topic as we have here and picking the post here and clicking on send,
I will take this value and I will send it for this URL and this URL accept will accept the post as well.
So if I will send it, you will see it's not going to go through.
Actually it went through.
And because we set up our model to have the default value for everything.
So at the moment we have another record and then we have title return it to us.
So if I will come back from the post to get, and then I would like to see a list of our books in the
system I can go send and I can see here I have three books in the system now.
So what else is available for us?
We can do put, for example, put.
It's not going to work on books.
We need to specify for which record we will use the put method.
Let's say three.
Three is the ID of the the book we've just created here so we can see here three and put will basically
change the our record in database.
So post create a new record like we did here and the put will change it.
So we still need to pass some information so we'll pass it with the body and then I can title Let's
do Twilight Saga.
I don't know something and probably there is a lot of different Twilight saga anyway, if I have put
now and I will say a send it for a book three, which is this one, it was Twilight and then I will
send it like that.
You can see what I did is I've changed the third record with a new title.
So coming back here, I will do get for all the books.
So we'll remove that ID and you can see this is my third.
So put will update the records and you can update it more more than one field.
At the moment we only changing the title, but you can pass any.
Uh, like, let's say price, I will do price here and then we can decide it to 45 price.
And also I need to do three slash and using method put so selling this.
You can see this is our price and this is our title that we pass here.
So I will come back to get.
Books.
Sand and I can see the new record is there.
Well, there's an old record, but with new data.
So we cover already four methods, which is get all, which is the books.
Then you can get a certain record like that with ID and then you can post create new record and you
can put update new record.
Also very important one is the delete one.
So if you would like to remove the one we have created with the ID of three, you just use the delete
method on it.
So we have books slash three and then if I will send it, there is nothing back because actually that
Twilight saga we've created before has been removed to check it.
If that is the case, I can go get and try to list all the books now.
Send it.
And you can see we are having two books in our system.
So the third one has been removed with the delete method.
So that's it.
That's the main method we have on the Http.
Repeating that again, we have five main methods.
So we have get on the books which will give us the whole set of the books.
Then we have get on the specific book.
It will bring us only one record.
Then we have post for creating new record.
Put for updating the current record and delete for removing.
We have others that are not that really popular to use, so I'm not going to talk about them, but you
can read about it and if you would like to use it, you can use it.
But anyway, that's the main five and that and we will use them in our tutorial.