I’ve read the Wikipedia article and know it’s basic function but I don’t understand what it physically is. Like, is an api a text file that the main program reads from and you are just putting your text in that file to be read or is it an other program that just puts what you type directly into the main program? I don’t understand. Maybe what I’m really asking is what is the actual process that allows an api to take an executable with no way to input information and allows you the programmer to input information.
1 Answers
API is a contract between two systems. Nothing more, nothing less.
The key question is why do you need api? Api's allow decoupling systems and modelling interaction between them. Here are few examples:
A file system has a set of APIs to manage files and directories. One of those apis is "touch a file" which "updates timestamp on the file". As a customer of that api, you don't need to know how timestamp is stored and how the actual update is happening - all you need to know - there is a contract.
Another example would be a database. When you tell database to commit a transaction, the database guarantees certain properties, like data durability.
Basically API allows simpler modelling of systems.
I highly recommend to lookup on youtube a video: "How To Design A Good API and Why it Matters". It is a very old talk from google. It gives you a perspective on what is api and when an api is a good one.
- 259
- 1
- 3