Now in this core section,
I want to start with a very important question.
What exactly are services and APIs no matter
if we're talking about a third party services,
or custom build services,
we'll discuss the latter once in a later course section,
but what are services and APIs to begin with?
Well, when it comes to services,
you can really take that word.
Literally services are just debt services that you can use
in your projects and websites to enhance these projects and
websites. Like for example,
a third party service that helps us handle credit card
payments. That makes that much easier for us,
but we don't have to start with such more complex services
like handling credit card payments.
We can actually have a look at services if you want to call
them such that we have been using throughout,
this course already.
And that would, for example,
be third party packages like Axiom, which we haven't used,
but which has showed you or express or be crypt or the Mongo
DB package,
all those packages that we have been using throughout the
discourse section, we used such packages like for example,
express so that we could have an easier time handling
incoming requests and sending back responses so that we
don't have to write all the low-level code ourselves so that
we don't have to reinvent the wheel all the time and write
all the functionalities that we might need on our own.
But so that we can instead use a package,
which solves a certain problem for us. For example,
the B crypt package solves the problem of hashing passwords,
and we can then just use that package and its functionality,
and don't care about how it solves that problem in any way.
And that is why we use services like third party packages.
Now, thus far, I always called the dose packages packages,
but we could also call them services because clearly those
packages provide a service to us. And to our website,
the B trip package provides the service of making hash
and passwords easy.
Now packages,
aren't the only kind of service you could integrate into a
website. And indeed, in this course section,
we are going to have a look at a different kind of service,
for example,
another service that you could use in your website to add
a certain feature would be Google maps,
the Google maps API specifically though I will come back to
what API means in just a second.
We all of course know Google maps,
but besides the Google maps, which you know,
and probably use every day on their website or in their
mobile app,
they're actually also is a service the maps platform,
which you can use as a developer to integrate maps into your
app because you might be building a mobile app maybe,
or website that should show some maps.
For example,
if you are using Airbnb and you choose some category there,
you also are presented with a map and this is actually
powered by Google maps.
Airbnb did not build their own map service.
If you think about it,
that would be super complex because it's not just about the
graphics here.
It is about getting all the data for that map,
all the names of the streets and off the cities and the
shops to which are there.
So therefore Airbnb uses to Google maps platform so that
they can get all the data from Google so that they can get
the map rendering by Google.
And they can focus on enriching that map with their own
data, which an Airbnb's case is about vacation rentals,
rooms, apartments, and so on.
Uber would be another,
a very popular website and app that you might know that
leverage is to Google maps, API to show a map.
So Google maps is a great example for a service that is
provided by another company, Google,
in this case to any developer who wants to integrate maps
into their websites.
Now, when it comes to Google maps,
if you check out the pricing,
you'll learn that you can get started for free.
There is some free credit, which you can use every month,
but from a certain point on you'll have to pay.
And that's quite typical for us services whilst there are
free services and especially a third party packages are
often free to use services like Google maps or in general
more complex services where you rely on data and logic
provided by another company may be free,
but often they actually cost money.
So you,
as a developer can pay these companies to use their services
in your website. And that's a quite common use case.
And now, for example, for such a third-party service,
which you could use would be Google analytics,
which is an analytics service provided by Google,
which helps you collect data about your website visitors,
and which gives you a dashboard and a user interface for
browsing these analytics.
But of course there also are services offered by other
companies. Then Google, for example,
there is a company called Stripe,
which offers a payments service.
And indeed Stripe is the service at which we'll have a
closer look throughout the discourse section because they
offer many products,
many different kinds of services you could say,
and we're going to use the payments service for all the dis
section to add payments,
credit card payments and handling such payments to our
website so that we don't have to write all the logic for it
as ourselves,
so that we don't have to negotiate contracts with credit
card providers,
but that we can instead use Stripe to easily handle customer
payments in our website.
So using such services is a really common thing.
And as a side note, it,
of course also means that as a web developer,
you could not just earn money by building websites or
selling products on websites.
You could also build a service that provides a really useful
kind of service,
and you could make that a paid service and then offer that
service to other developers and companies.
So as a web developer,
you could also be building such services.
And especially if you keep in mind that there are not just
websites out there,
but also many mobile apps that might need certain features
in their apps.
There is a broad customer base that could be interested in
your services.
Now we're going to have a look at building custom services
and API APIs later in the course section in this core
section,
I just want to introduce you to this feature and especially
show an example, Stripe,
to be precise so that you see how you could use such
services, but that's services.
What are API then?
Well, when it comes to APIs,
it's important to understand that all those services,
no matter if we are talking about a third party package or
something like Google maps or Stripe,
all those services in the end provide certain actions or
so-called end points that we can access from inside our
code.
If you have a look at the express package, again,
for example, by visiting their official website,
then you will notice that on their website,
they actually have an API reference.
Now this is in the end,
just a list of documentation of all the methods and features
offered by express and how you use them in your code.
For example,
that you can use the Jason method to get a middleware that
parses Jason request bodies.
It's a feature we use before in this course that we can call
the router method to get a router and never featured,
which we used for all the discourse.
So in the end,
an API is really just a collection and a description of all
the methods that we can call on a third-party package.
It's a documentation off the code.
We can write using a third-party package to use the various
features off that third-party package or in case of Google
maps.
It's a documentation of the various features you can use
from that service there.
If you have a look at the documentation,
you'll find various pieces of documentation and you,
for example,
all defined a JavaScript package that's provided by Google,
which you can download and integrate into your website.
And then again,
a description of how to use that package and which methods
or constructors or properties it provides,
but you could also have an API.
That's actually not a description of a third-party package,
but instead,
a list of URLs to which you can send requests and
then a description of how these requests should be
formatted,
which parameters and query parameters you might need to
provide, or which requests bodies,
which HDP methods should be used.
So a description of such URLs to which you can send requests
because a service doesn't have to be a package.
It sometimes is.
And sometimes services like Google maps do provide packages,
which you can add to your website,
but a service can also provide access to its various
features. By giving you a list of URLs,
to which you can send the request from either the front end,
with fetch or from the backend from node JS.
You can also send requests there,
even though we haven't done this in this course,
but you can use packages like axial stair as well to send
requests.
And then these requests will give you responses.
And for example, here,
where I'm having a look at the description of the routes
service provided by Google,
I can send the request to get a description of the route
between two points on a map.
And then the response will contain data in the Jason format
that I could use on my website to den well,
show data about this route between these two destinations,
for example.
So in the end,
no matter if it's through a third-party package,
which we add to our code or through a bunch of URLs,
to which we can send requests and where we then get back
responses with some data,
those services do provide these actions or endpoints,
which we can access from inside our code.
And it's always in the documentation of a service where we
can learn how to use that service.
If it gives us a package we can use,
or if we should send requests to certain URLs.
And in the end,
it's this collection of actions and end points that makes up
the so-called API,
the application programming interface because of these
actions or end points,
which are clearly documented and which are not up to us,
but which are instead clearly defined by the service
provider.
These are the actions or end points we have to target from
inside our code to get a certain behavior or to get certain
data.
Because of course, if you are using a third-party service,
it's not up to you as a developer to decide how you want to
call a certain method that you want to execute.
Instead you have to call and execute a method or send a
request to our URL that is clearly defined and provided by
the service provider. And they'll for debts, the API,
this collections of actions and endpoints. And of course,
all of the documentation then,
because without documentation, as a user of a service,
you wouldn't know how to use the service,
which methods to call or where to send your age to the P
requests to.