Saturday 30 April 2016

Building an API with Django and GAE Cloud Endpoints


Introduction  

Typically when you build a Django application  and you need to expose your application's data in the form of a RESTful API you would use something like the excellent Django REST Framework or Django Tastypie However if you are hosting your site on Google App Engine there is an alternative called Google Cloud Endpoints that you should check out.
This blog explain you how to make a post request api in django application.

What is GAE cloud endpoints ?

Cloud Endpoints is a robust solution built on Google architecture that powers various Google APIs. It takes care of a lot of the hard work for you such as authentication via OAuth 2 and JSON templating and provides an explorer you can use to test your API in the browser.

An Endpoints API is a remote procedure call (RPC) service that provides remote methods accessible to external clients. Each Endpoints API consists of an RPC service class that subclasses the ProtoRPC remote.Service class, and one or more methods. When you define a method, you must also define message classes for the requests coming into that method and the responses returned by it. A message class performs a mapping function so the incoming data can be extracted and supplied to the service method properly, or supplied properly to the outgoing response.



for more details GAE cloud endpoints


Build Django Application .. !

I hope you guys are already know about the basic configuration and your application run in google app engine.

Here we are going to create a small web application , it contains only two models  Book and Publication Year , when user enter the year , api list out all the book which is published is user requested year.

don't forget to create handler (app.yaml ) in your project .

you can get the running code from my git account : django google endpoints application
clone the project in your machine and create a mysql database , and put some dummy data in to db.
and run in to google appeninge.

cheerrs ......






















No comments:

Post a Comment