-: API, the application programming interface.
In this lesson, we're going to dig into APIs.
Now, I've mentioned them a couple of times,
but we've never really defined them
and gone into depth with them.
When we talk about an API,
this is an application programming interface.
It's a library of programming utilities
that are used to enable software developers
to access functions of another application.
And this is one of the key things we use
when we start talking about piecing things together
by using things that are service-oriented
in their architecture.
Now, when we deal with an API,
this is going to allow for the automated administration,
management, and monitoring of cloud services,
as well as lots of other applications.
Now these APIs are commonly going to use either REST or SOAP,
the simple object access protocol as their frameworks.
Now, when we talk about APIs,
we think about these from the perspective of integration.
APIs allow for integration
between lots of different cloud services.
Cloud service providers also allow
for us to do provisioning, configuration,
deep provisioning, and lots of other things
to their services through these APIs.
So, APIs will allow us to have direct integration
of different third-party applications
into our own web applications, as well.
And again, this is those things that allow us
to tie things together and make function calls
instead of having to build services ourself.
We could just call on somebody else's function
and let them do the work for us.
That's the idea of a service-oriented architecture.
Let me give you a great example
of how we use APIs in our business.
Now, in our business, we have a centralized
service management system called Freshdesk.
Freshdesk is a commercial product that we pay for,
and we use this to be able to get
all of our trouble tickets from our students,
and any questions you may have, and track those things
and make sure you're getting the answers you want.
Now, if you email support@diontraining.com,
it goes into our Freshdesk system,
and my team and I can look at those
and answer your questions.
Think about it like a shared inbox,
but again, it's a ticketing system,
so we don't lose track of it,
and we can make sure everybody's
doing what they're supposed to.
Now, we've had students ask questions
as well in our Udemy courses,
and they do it inside the Q&A section on that platform.
Well, I don't own Udemy, and I don't have the ability
to do what I want and program their system how I want.
But they do have an API,
so instead of me having to log into Udemy
to answer those questions, we instead have an application
we built that uses Udemy's API.
Whenever there's a question that's posted
inside the Q&A section on Udemy,
we actually get notified from their API
to our Freshdesk API,
and we create a new ticket in our service management tool
and tag those as a Udemy Q&A question.
That all goes from API to API and sends that data back.
This is the type of integrations you can do.
Now, all of this is being done
with a very small program that we wrote.
That integration program is less than 50 lines of code
inside of Python, and we're actually connecting
these two different cloud systems, Udemy and Freshdesk,
to be able to accomplish everything we want
with just 50 lines of code.
Now, when either myself or one of my team members
answers those questions inside of Freshdesk
and we close that ticket,
it then triggers a function in the Udemy API
to take our response and post it back as a reply
to your question in the Udemy Q&A.
For you, it's going to look just as if I went in there
and answered it directly on Udemy,
but for us, it's easier to manage
and allows us to help more students quicker.
In addition to that, there's a function in there
that will mark that answer as the top answer
because we wrote it and we want it to be the top answer
that you see when you ask a question inside of Udemy.
Now, all of that is how you can use
some of these things to integrate.
Another example of using an API
to access an online cloud service
is how we integrate our hands-on, cloud-based labs
into our products inside of our own website.
Now, we integrate these labs from our partners,
using their API.
We create all the videos, we create all of the lessons,
we create all the study guides and all the quizzes,
but when it comes to the labs, we don't build that ourself.
We have a third-party partner that we work with,
and we want to integrate theirs into our course experience,
and we want it to be native for you
so it feels like it's much more integrated.
So, if you're taking this course
at diontraining.com, for instance,
you have access to that full lab environment.
Now, what happens is, as you're going through the course,
you'll watch a video and eventually get to one that says,
"Now there's a lab, and in this lab,
you're going to do X, Y, and Z.
Click this link to start the lab."
And that link actually looks something
like what you see here on the screen.
It'll say diontraining.com, question mark,
action equals run instance and ID equals,
and the count, and the access key, and all those things.
These are the perimeters that we're passing
to the API of our cloud service provider.
So, when we go to the lab partner,
they're knowing who the student is,
where they are in the course, what lab to run,
and which one to start up.
And all of that is stuff we send over through an API call
from our system to their system.
And then, it gives you a link,
you click on it, and it loads up.
Now, notice here you have an authorization token, as well.
This is because the cloud provider
needs to be able to know who they're servicing
because we have hundreds of thousands of students,
and by knowing which student you are,
they know which lesson you're on,
and they can know which lab you need to have.
And so, they can give you the right services
that you paid for and the ones that you've already used.
Now, when you're doing APIs,
there are lots of different tools you can use to do this.
One of the ways you can test APIs
is by using a tool known as curl, C-U-R-L.
This is a tool to transfer data from one server to another,
and you can do this using any supportive protocol,
including HTTP, HTTPS, FTP, FTPS,
SCP, SFTP, TFTP, DICT, TELNET, LDAP, or FILE.
All of these are valid ways of doing it.
So, if I wanted to test an API as a cybersecurity analyst,
I could test it by using curl,
and I might do something like this,
curl --data, and then the data I want to send.
In this case, I'm sending firstname equals boolean
and last name equals world.
And then where I'm sending it.
In this case, https://httpbin.org/post.
When I send that information, what do I get back?
This list as you see here on the screen,
which is a list of arguments and fields
that came back from that particular API.
This allows you to send the data over
and see what comes back.
So, if you were hired to do testing of our server
and make sure the right student
is getting sent to the right lab,
you would have to know how to do this
to make sure the API calls are being programmed
correctly by our developer
and that we're getting the responses we expect.