Consuming A Restful Api With Django
I'm building a Django application that needs to interact with a 3rd party RESTful API, making various GETs, PUTs, etc to that resource. What I'm looking for is a good way to repre
Solution 1:
The requests
library makes it easy to write a REST API consumer. There is also a Python library called slumber
, which is built on top of requests
, for the explicit purpose of consuming REST APIs. How well that will work for you likely depends on how RESTful the API really is.
Solution 2:
Make the REST calls using the builtin urllib (a bit clunky but functional) and wrap the interface into a class, with a method for each remote call. Your class can then translate to and from native python types. That is what I'd do anyway!
Post a Comment for "Consuming A Restful Api With Django"