- So what is an API,
and why is it useful to you as a programmer?
Let's talk about that in today's video.
(upbeat music)
Welcome back, my name is Tim Buchalka
with another programming tip of the day.
And again the question is what is an API,
and why is it useful to you as a programmer?
Well firstly API stands for
Application Programming Interface.
And what it is,
you can really consider it as the middleman,
the middle bit of code that sits between
the code that you write and the code or pre-written code
that someone else has written.
So basically it gives you the ability as a programmer
to access that other code in a logical way.
So without that you have to write
all those other codes yourself,
an API gives you the ability to access this other code.
Now consider an example, the unreal game engine.
Now the purpose of that game engine
is to shortcut game development.
So it's basically the infrastructure
to create computer games.
Now basically that's a bunch of pre-written code
that tonnes of programmers have accessed and used
and developed over the years.
And there's all manner of game related stuff,
things like player movement, camera positioning
and all those sorts of things.
So that said, where does the API come into this again?
Well the API is the way for your code again
to use this pre-written code.
So it defines how you can access
the specific functionality in your own programmes.
Now there's nothing really magical about it,
it's really just a way for you to be able
to access this code, this pre-written code,
from the code that you develop yourself.
Now API documentation is very important here,
because documentation helps you
how to understand how to use the API.
And the good thing is that these days all commercial APIs,
which every real game engine's got its own API,
has got good documentation.
So that outlines the methods, the functionality,
the properties and so forth,
that you need to access and use,
so that you can take advantage of this pre-written software.
Now what's really important here is
that you can also use APIs in your programmes.
So you can actually create a programme yourself
and you can create an API for it.
So you can actually do it yourself.
So again there's nothing magical about APIs,
it's just a way for you to access,
or give someone else access to your programme.
Now a typical way,
that you might start using an API for your own programmes
is when you wanna share data.
So you might create a basic programme
that tracks some information or stores some information
and you wanna start sharing that information with others,
you would create an API,
an Application Programming Interface,
that defines and gives a method or way
for other programmers or other programmes
to get access to your code to your data from your programme.
Basically again, there's nothing really magical about it,
it's just a typical way that you would actually
give people access to that data.
So it's just defining an entry point
to get access to that data.
Now an API itself can be small or large,
it can be simple or complex.
There's nothing, again I've said this a few times,
there's nothing magical about it.
So with that said,
what's the biggest reason that you'd want to use an API?
Well hopefully that's become apparent in this video.
It's basically to get access to this code
that's been developed by other people.
And getting back to the game analogy again,
we'll go back to the unreal game engine.
Now because that code exists,
and there's an API for you to access it,
you don't have to create your own game engine.
When I started out developing in the late 70s early 1980s,
if you wanted to create a game,
you'd have to write all the code
to do absolutely everything.
To position the player,
to draw things on the screen and so forth.
So every game project,
would involve an all this extra code.
But these days you can use something like
the unreal game engine.
It does a lot of that work for you,
so you can concentrate on
the unique characteristics of your game,
knowing that all those things
like moving players on the screen and tracking things
and moving cameras, positioning cameras and so on,
the code to do that already exists
you just write a bit of code
that accesses the API method call
for that particular bit of functionality
and it's written already and it actually works.
So again you're just then confirming
or focusing on your code specific to your individual game.
And you can see that by doing that
you'd save a heck of a lot of time,
versus having to go through
and write the entire game engine
as well as your codes yourself.
I've used the game analogy a couple of times now,
but the same thing also exists in business software.
Another example is XERO, X-E-R-O.
That's a very popular online finance programme for businesses.
So you can use that to keep track of your finances
and give access to your accountant,
to access those finances and so forth.
Well XERO has also got an API.
So you can use that API,
to get access to your data in different ways.
So perhaps there's a bit of functionality
that you wanna get access to,
you wanna manipulate your data in some way
that the standard XERO software doesn't allow you to.
Or perhaps you want to grab the data
from another finance package and import it into XERO,
you'd be using an API.
You could write some code
to actually do that, to transfer that,
and get that working if you wanted to do that.
So you can see that
instead of creating your own accounting programme from scratch
in this case you can leverage XERO,
again a very popular accounting package
and you could use the functionality for that
and then basically get the data in or take the data out
or just basically access functionality with XERO
without having to write
your own accounting programme from scratch.
So that's it.
That's all there really is to an API,
Application Programming Interface.
All righty so I hope that helped.
If you've got any questions,
feel free to leave a comment and I'll get back to you.
If you're ready to look at the next tip,
click on up here and you can check that out.
If you're interested in coding specific programming videos,
click on the link in the bottom left-hand corner.
Consider subscribing by clicking on the link up here.
And I'll see you soon.