[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

New to working with APIs, any good tutorials/books/guides?

On Thu, 20 Feb 2014 23:59:16 -0800, ApathyBear wrote:

> I don't understand how APIs work to save my life. I am a complete
> beginner. In fact, I am a bit confused on what API even means and what
> the meaning entails.

API stands for "Application Programming Interface", and it essentially 
means the set of interfaces, calling conventions, functions, methods etc. 
of a language, library or even a single function.

For example, in Python, the API of the len() function is really simple:

- len() takes a single mandatory argument;

- that argument must be a sequence, mapping, or some other object 
  with a __len__ method;

- otherwise len() will raise TypeError;

- len() will always return an int;

- which is supposed to be the length of the sequence or mapping.

That's pretty much the API for the function len(). Simple, isn't it? Now, 
obviously the API for an entire library is more complicated. It includes 
rules for how many and what kind of arguments each function, class or 
method expects; what values they are allowed to be; what sort of values 
will be returned; what exceptions will be raised, and so forth.

Basically, when you read the manual for a language or library, that's 
documenting the API. That's all there is to it.