Creating an API for an ASP.NET MVC site with rate-limiting and caching

Posted by Maxim Z. on Stack Overflow See other posts from Stack Overflow or by Maxim Z.
Published on 2010-05-23T06:48:41Z Indexed on 2010/05/23 6:50 UTC
Read the original article Hit count: 282

Filed under:
|
|
|
|

Recently, I've been very interested in APIs, specifically in how to create them. For the purpose of this question, let's say that I have created an ASP.NET MVC site that has some data on it; I want to create an API for this site.

I have multiple questions about this:

  1. What type of API should I create? I know that REST and oData APIs are very popular. What are the pros and cons of each, and how do I implement them? From what I understand so far, REST APIs with ASP.NET MVC would just be actions that return JSON instead of Views, and oData APIs are documented here.
  2. How do I handle writing? Reading from both API types is quite simple. However, writing is more complex. With the REST approach, I understand that I can use HTTP POST, but how do I implement authentication? Also, with oData, how does writing work in the first place?
  3. How do I implement basic rate-limiting and caching? From my past experience with APIs, these are very important things, so that the API server isn't overloaded. What's the best way to set these two things up?
  4. Can I get some sample code? Any code that relates to C# and ASP.NET MVC would be appreciated.

Thanks in advance!

While this is a broad question, I think it's not too broad... :)

There are some similar questions to this one that are about APIs, but I haven't found any that directly address the questions I outlined here.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET