So now let's go ahead
and learn about Django Rest framework.
So once we know what exactly an API is, we will now go ahead
and make use of the Django Rest framework to make APIs in our Django app.
So the very first question is why exactly would you need an API?
So why can't you just simply go ahead and build a simple website
that offers data to your clients?
And why exactly would you need an API?
Make money selling data?
So if you have a look at multiple websites which actually offer a API,
so the API might be to provide stock data,
the API might be to provide weather data or any kind of other information.
You always will notice that these websites actually have a business model in place,
which allows them to sell this data
to third parties and gain some revenue out of it.
So with APIs, you can actually go ahead and you can sell the data which you have.
So for example, let's say for some reason you have collected some data
which is present on your website and that data is used by your website.
But let's say if the data is not confidential,
and if you actually want to go ahead and release that data to the public,
you can actually go ahead and make an API to share that data with public,
either for free, or you can charge a certain amount of fee for each
API request.
So this is the first reason why people actually make APIs.
The next thing is if you want to develop a mobile app.
So let's say if you actually want to study, start up,
and if you want to be present on the web as well
as on the mobile phones as well in terms of apps.
So whenever you go ahead and make a website, you will actually have
the website connected to a backend, which is the database server.
And that database server is actually going to host
all of your data, which will be used by your web app.
So the connection between database and the web app is quite okay.
But what if you actually
also want to share the same database with your phone as well?
So let's say if you also want to make an Android app,
then you can actually go ahead write an API
which actually connects your mobile app with your backend database so that
the same data is available on your web app as well as your smartphone app.
So this is another reason why you would need the API for your website.
And the
third reason is let other developers integrate your content on their site.
So by making use of an API, you can actually allow other developers
to integrate your site content onto their site.
And by using API, you can not just allow them to integrate content,
but you can actually integrate an entire functionality of your site
into some other people's site or the third party site.
So the common example of this is payment gateway.
So let's say for example, if you are building an e-commerce website,
you don't have to actually go ahead and write in the payment gateway from scratch.
Instead, you can just go ahead and use the PayPal API or the stripe API.
And using that API, you can actually integrate payment gateway into your site.
That is, you are taking the entire functionality
of handling payments from people or from stripe,
and you're actually integrating that into your existing website.
So this was only possible because sites like PayPal or stripe
actually provide you with an API, which you can integrate in your site.
So if you want to build a similar functionality for your site,
you will actually need to go ahead and make your own API.
So now let's learn a few things about Django.
Rest framework.
So it's actually a powerful web toolkit for building
web APIs, especially for Django apps.
So as I earlier mentioned, the Django Rest framework can only be used
for building web APIs for Django applications.
So if you have any Django application, you don't need to actually
go ahead and start building the APIs from scratch.
Instead, you can use the Django Rest framework,
and it will be a whole lot easier to create APIs using these.
Django. This framework.
Now here are the requirements for using Django Rest framework.
You will obviously need a Django application.
So Django Rest framework only works when you are making Django apps.
So that's quite obvious from the name of the framework itself
and the Python version, which Django
Rest framework currently supports is Python 3.5 and above.
So you should be either using 3.5, 3.6 or 3.7.
Either one of them should work just fine.
And the Django version,
which Django Rest framework currently supports is
Django version 1.11 and above.
So you can use 1.11, 2.2, 2.1 or 2.2.
So now let's go ahead and install Django Rest framework
in the next lecture.