I am using Django (1.3) and I need to prepare an API for communication with programs wtirtten in C#. So we choose XML as input and output format, since C# is quite good with XML.
Beyond that, I have concerns about APIs that work well with django, would be enough to help me in my needs. I have done some research about APIs like tasty-pie and django-piston. My concerns are:
-
I will keep my user records not on
User, but some other model. As far as i know, apis above support self defined authentication and authorization. But cold not find more if keepingUserout all is possible? -
On documents, all examples are simply based on selecting a record or creating a new one on a defined model. But in my case, I need to check the data through different models, (thus, input data can not be derived from a single model). Similarly, output also will created with data from different models. With simpler words, my input and output is not bounded to a simple model, I need to process (some part of the input data) and create a custom output data in XML format.
On that two basic questions, I wonder if APIs like Django-piston or tasty-pie is suitable for me, or what i really need is an application which can read and produce XML requests/reponses and works well with django
What I need is a django application which:
- Can produce XML formatted responses (to communicate with a remote C# program)
- Can process XML requests (that come from a remote c# program) or simple url requests (like django views, but produce XML output.)
- Do not use django authentication but custom authentication through a self defined
Usermodel
django-piston and tastypie both allow you to define custom data “formats” that you describe. piston (and possibly tastypie) also provide convenience methods and structures that let you easily model your models as api endpoints. Tying in to your models is not a requirement though. You essentially build up a dictionary, returning that, and letting the formatters do their work in converting the dict to a json or xml response.
I’m confident that either library will suit your needs. I’d like to suggest that you use JSON though, as it is very widely used for APIs, reduces overheard, and is easier to read with the naked eye. C# handles JSON just fine.