什么API框架适合我的需要? [英] What API framework suits my needs?

查看:168
本文介绍了什么API框架适合我的需要?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Django(1.3),我需要prepare与在C#中wtirtten程序通信的API。所以我们选择XML作为输入和输出格式,因为C#与XML相当不错。

除此之外,我对与Django的工作,良好的API的关注,就足以帮助我在我的需求。我做了关于如美味的馅饼和的 Django的活塞。我的担忧是:


  • 我会继续我的用户记录,而不是用户,但一些其他的模式。据我所知,上述支持自定义的身份验证和授权的API。但寒不找到更多,如果保持用户所有是可能的?


  • 在文档,所有的例子仅仅是基于选择一个记录或创建一个自定义模型一个新的。但对我来说,我需要检查通过不同的模型数据,(因此,输入数据不能从一个单一的模型得出)。类似地,输出也将与来自不同模型的数据创建的。用更简单的话,我的输入和输出是无界到一个简单的模型,我需要处理(对输入数据的某部分),并以XML格式创建自定义输出数据


在这两个基本问题,我不知道是否喜欢Django的活塞或美味馅饼的API是适合我,或者我真正需要的是能够读取并产生XML请求/反应变量和Django的效果很好

我需要的是一个Django应用程序,其中:


  • 可以产生XML格式的响应(与远程C#程序通信)

  • 可以处理XML请求(即来自远程C​​#程序)或简单的URL请求(如Django的意见,但产生XML输出​​。)

  • 请不要通过定义一个自使用Django身份验证,但自定义身份验证用户模式


解决方案

Django的活塞和tastypie都允许您定义自定义数据格式,你形容。活塞(以及可能tastypie)还提供方便的方法,并且让你轻松将模型建模为API端点结构。绑到您的机型是不是虽然要求。你基本上是建立一个字典,返回这一点,让格式化做好自己的工作,在字典转换为JSON或XML响应。

我相信无论是库将满足您的需求。我想建议你使用JSON不过,因为它被广泛使用原料药,减少偷听,并且很容易用肉眼读取。 C#处理JSON就好了。

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 keeping User out 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 User model

解决方案

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.

这篇关于什么API框架适合我的需要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆