Search code examples
api-design

Is it good practice for a website to use its own API?


Is it good practice to develop the API while developing the site so the site itself actually uses the API? Or is there a performance hit if choosing to do this?

For example, does anyone know if mature sites such as Facebook or Digg use their own API to CRUD (Create, Read, Update, Delete) or do they have their own backend? Thanks


Solution

  • I doubt Facebook and such use their own API. There are a couple of reasons not to use your own API for the site itself:

    1. You can make data access more performant by using the database directly instead of doing extra requests and (de)serialization.
    2. Probably easier to implement efficient caching with memcached etc
    3. Importantly, you won't have to conform to your public API when extending your site (you don't want to change your public API very often, that'll just annoy everyone)