DEV Community

Callum Connolly
Callum Connolly

Posted on

What is an API? Part 2

For those who haven't read Part 1, you can read it here. Otherwise, carry on. I cannot stop you.

Now we have a grasp of some common terminology, let's take a short look into some more details about APIs in practice and some of the things I have personally learned.

It's not just for Sending or Receiving Data

Interfaces to certain systems are synonymous with the API for that system. It is the defined way of getting that program, or set of programs, to do something. Windows provides a Graphical User Interface in the form of scroll bars, task bars, and well, windows. These are an API (albeit a intuitive one) for interacting with the underlying hardware and software on a computer. Interfaces for sending packets across a space channel to get a satellite to do something will be defined.

silly little meme of always has been

It isn't the Database Schema

Whilst one way of creating an API is to make it as granular as possible, exposing create, read, update, and delete methods which are largely in line with the database schema, this isn't the best approach. APIs are designed for someone to use (whether that is through a program or otherwise) and should encapsulate the information that they want well. In some cases they should be like an acceptance test - one function that your program should fulfil with the defined and encapsulated data.

Document It (Por Favor)

One of the ways to make API design a lot easier for both the programmer, and the user, is to ensure that it is well documented. It is such a relief when we come across a well documented API and makes our jobs 100 times easier. Even so only around 8% of developers feel that their API documentation is very good.

API design is Difficult

Even for fairly simple APIs designing the interface is difficult. It requires a lot pf practice of going over similar problems, and even then there are tens if not hundreds of ways of going about designing the API. They should be simple to understand, stable, easy to use, and efficient. Whether you're working over a network with limited bandwidth, or across a board with restricted computational resources, applying these rules and making APIs efficient and simple is the goal. Standards, along with documentation, particularly help with this.

This is the article I wish I had when I begun programming and learning about APIs, so I hope that it is useful to whomever may read it. If you have your own thoughts, please share them below as well.

Top comments (0)