Ask DN: How do I make an API?

over 8 years ago from , UX Designer/Developer

Hey everyone!

I know this is a design-centric forum, but I was wondering if anyone has experience making APIs. In my daily work, my co-workers create the APIs, schemas, and set up databases and such. Daily experience working with APIs made me want to apply the same to my own projects. Often, I want a different design, but the content stays the same.

All I know about API construction is that they require a database, so something like SQL/Mongo is needed. I hear great things about NoSQL, so should I use that? Also, I would like to set up access for only a handful of domains for the API endpoints.

Any help is greatly appreciated! My findings from this experiment will definitely make a great blog post in the future.


  • KeVon TicerKeVon Ticer, over 8 years ago


    One place to start is to figure out all the different types of data your app will need to show and manipulate on any given screen for the user. Typically you make calls to an API from your front-end code to do one of 4 things: Create a new entry in the database, Read an existing entry, Update / change an existing entry, or Delete an entry (CRUD). Your API is going to consist of code designed talk to the database to deliver these actions in ways that make your application work efficiently.

    An example: you have a restaurant suggestion app. On one screen, you show a list of restaurants and if a user clicks an entry, they see details on that specific restaurant. When the screen loads, your front-end makes a call to a function/endpoint in your API (probably via HTTP request) handing over your location. You have designed your API to return a list of restaurants given a location as input (it looks through your database for the restaurants that match). On the front end, you manipulate the raw data returned from the API for presentation to the user. When the user clicks on one of the restaurants in the list, your app loads a new page and makes another call to your API, handing over the restaurant the user clicked's database key (unique number identifying it in the database) to look up the rest of it's information. Your front end code gets this raw data again and you manipulate it to present to the user again. Now, one last thing to think about is that you should be efficient about your API calls because they can be expensive, especially if the user does not have a great internet connection. So maybe in this example, if the detailed restaurant information isn't very much data, you just load it all in that first API call so the UI doesn't have to make another one for the next screen. This goal is generally to figure out how to create endpoints that give the best possible amount of data given the situations for which they will be called. There are lots of API design best practices resources available online.

    When it comes to NoSQL vs SQL, there is a lot of debate and they both can offer different positives depending on how you want to program on the back end. Here's a link to get you started: Stack Overflow.

    3 points
    • ポール ウェッブ, over 8 years ago (edited over 8 years ago )

      Thank you for your comment (and, your example!), I'll start mapping out how I want things to work.

      EDIT: The accepted question to the SO link you shared was helpful as well.

      0 points
  • Trevor Stacy, over 8 years ago (edited over 8 years ago )

    And if you're not quite sure what you should be using to make the API, I would suggest Lumen, it's an incredibly fast micro-framework that has the same syntax (api) as Laravel (made by the creator himself). The whole reason he made it was to handle API requests hitting his server for his Envoyer project.


    1 point
    • ポール ウェッブ, over 8 years ago

      Oh damn, Laravel's been killing it lately! I'll definitely look into Lumen more, it looks good so far, even if I don't understand it 100%, haha.

      0 points
  • Benjamin LundquistBenjamin Lundquist, over 8 years ago

    This is a good light read to get yourself in the right mindset. https://leanpub.com/build-apis-you-wont-hate

    1 point