Download as pdf or txt
Download as pdf or txt
You are on page 1of 25

Cloud

What Is Cloud Computing?

Cloud computing, in simple words, is accessing and storing data over the Internet
instead of doing it on your personal hard drive.
It offers services like storage, database, networking, and more over the Internet to
provide faster, innovative, and flexible resources to its customers. The customers get to
pay only for the resources they use, hence helping them lower their operating costs and
run their business

infrastructure more efficiently.

Now, among various cloud providers like AWS, Microsoft, VMWare, IBM, etc., Google
Cloud has been the talk of the town in recent years and there are enough reasons behind
it. Let’s begin with starters and understand what Google Cloud is.

What Is Google Cloud Platform?

Google Cloud is a suite of Cloud Computing services offered by Google. The platform
provides various services like compute, storage, networking, Big Data, and many more
that run on the same infrastructure that Google uses internally for its end users like
Google Search and YouTube.

Google server hasn’t gone down in years. So, if you are planning to run your application
on the Google Cloud infrastructure, then you can be assured of your applications being
safe and secure.
ABOUT GOOGLE CLOUD SERVICES (HTTPS://CLOUD.GOOGLE.COM/DOCS/OVERVIEW/CLOUD-PLATFORM-
SERVICES)

This overview introduces some of the commonly used Google Cloud services. For the full
list of services, see the Products and services page.

This overview covers the following types of services:

• Computing and hosting • Storage


• Databases
• Networking

• Big data
• Machine learning

OUT of Google Product you have to study 3 services in detail:

1.Compute (https://cloud.google.com/docs#section-7) a)In compute write detail steps of

https://cloud.google.com/compute/docs/quickstart-linux )

how to create a Linux virtual machine instance in Compute Engine using

the Google Cloud Console. ( Reference:

1.Click the
to select your payment method. On the left is a panel populated with the
temporary

credentials that you must use for this lab.

2.Copy the username, and then click

After tab.

o Accept the terms and conditions.


o Do not add recovery options or two-factor authentication (because this

is a temporary account).
o Do not sign up for free trials.

a few moments, the Cloud Console opens in this

Start Lab

button. If you need to pay for the lab, a pop-up opens for you

Open Google Console Sign in

1. In the Sign in page, paste the username that you copied from the
Connection Details panel. Then copy and paste the password.

2. Click through the subsequent pages:

. The lab spins up

resources, and then opens another tab that shows the

page.

Activate Cloud Shell


Cloud Shell is a virtual machine that is loaded with development tools. It offers
a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell
provides command-line access to your Google Cloud resources.

In the Cloud Console, in the top right toolbar, click theActivate Cloud Shell
button.

Click Continue.

You can list the active account name with the written commands in console :
Deploy a simple Apache web server to learn the basics of

a) Write detail steps for https://cloud.google.com/compute/docs/tutorials/basic-webserver-apache)

Now you'll install an NGINX web server, one of the most popular web servers
in the world, to connect your virtual machine to something.

1. In the SSH terminal, to get root access, run the following command:

running a server on a virtual machine instance. (Reference:

In the SSH terminal, to get root access, run the following command:
sudo su -

• As the root user, update your OS:

apt-get update

Get:1 http://security.debian.org stretch/updates InRelease [94.3 kB] Ign


http://deb.debian.org strech InRelease
Get:2 http://deb.debian.org strech-updates InRelease [91.0 kB]

• Install NGINX:

apt-get install nginx -y

content_copy

Reading package lists... Done


Building dependency tree
Reading state information... Done
The following additional packages will be installed:
• Confirm that NGINX is running:

2) GOOGLE APP ENGINE (REF: HTTPS://CLOUD.GOOGLE.COM/APPENGINE/DOCS) Start Lab

Click the

button. If you need to pay for the lab, a pop-up opens for

you to select your payment method. On the left is a panel populated with the

temporary credentials that you must use for this lab.

Open Google Console Sign in

1. In the Sign in page, paste the username that you copied from the
Connection Details panel. Then copy and paste the password.
Important: You must use the credentials from the Connection Details
panel. Do not use your Qwiklabs credentials. If you have your own
Google Cloud account, do not use it for this lab (avoids incurring
charges).

2. Click through the subsequent pages:

o Accept the terms and conditions.


o Do not add recovery options or two-factor authentication (because this

is a temporary account).
o Do not sign up for free trials.

After a few moments, the Cloud Console opens in this tab.

Copy the username, and then click

. The lab spins up

resources, and then opens another tab that shows the

page.

ACTIVATE CLOUD SHELL


Cloud Shell is a virtual machine that is loaded with development tools. It offers
a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell
provides command-line access to your Google Cloud resources.

In the Cloud Console, in the top right toolbar, click theActivate Cloud Shell
button.

your PROJECT_ID

It takes a few moments to provision and connect to the environment. When


you are connected, you are already authenticated, and the project is set to

. For example:

Enable Google App Engine Admin API


The App Engine Admin API enables developers to provision and manage their
App Engine Applications.

1. In the left menu, click APIs & Services > Library.


2. Type "App Engine Admin API" in search box. 3. Click App Engine Admin
API.

4. Click Enable.

Deploy your app


1. To deploy your app to App Engine, run the following command from within
the root directory of your application where the app.yaml file is located:

2. Type the number for your region.

3. Enter Y to confirm the deployment of service when prompted.

VIEW YOUR APPLICATION


Your application is deployed and you can read the short message in your
browser. Click Check my progress to verify the objective.

3) Firebase database service (https://firebase.google.com/docs/database/)


CHOOSE A DATABASE: CLOUD FIRESTORE OR REALTIME DATABASE
Firebase offers two cloud-based, client-accessible database solutions that support
realtime data syncing:

• Cloud Firestore is Firebase's newest database for mobile app development.


It builds on the successes of the Realtime Database with a new, more intuitive
data model. Cloud Firestore also features richer, faster queries and scales
further than the Realtime Database.
• Realtime Database is Firebase's original database. It's an efficient, low-
latency solution for mobile apps that require synced states across clients in
realtime.

Firebase Realtime Database :

Store and sync data with our NoSQL cloud database. Data is synced across
all clients in Realtime, and remains available when your app goes offline.

The Firebase Realtime Database is a cloud-hosted database. Data is stored as


JSON and synchronized in Realtime to every connected client. When you build
cross-platform apps with our iOS, Android, and JavaScript SDKs, all of your clients
share one Realtime

Database instance and automatically receive updates with the newest data.

iOS setup | Android setup | Web setup | REST API | C++ setup | Unity setup | Admin setup
1) You can add firebase to an app.

You can create a Firebase Project :

2)You can add Firebase to an game.

3)You can add Firebase to a server.


Develop an application and use Google Firbase service to store your data.

Theory: (Ref. https://firebase.google.com/docs/firestore)

What is Firebase?

How to use Firebase:


&
A running application App/Web based with Firebase.

1. Click the Start Lab button. If you need to pay for the lab, a pop-up opens
for you to select your payment method. On the left is a panel populated with
the temporary credentials that you must use for this lab.

Cloud Firestore is a flexible, scalable database for mobile, web, and server

development from Firebase and Google Cloud. Like Firebase Realtime Database, it keeps
your

data in sync across client apps through realtime listeners and offers offline support for
mobile

and web so you can build responsive apps that work regardless of network latency or
Internet

connectivity. Cloud Firestore also offers seamless integration with other Firebase and
Google

Cloud products, including Cloud Functions.

2. Copy the username, and then click Open Google Console. The lab spins
up resources, and then opens another tab that shows the Sign in page.

Tip: Open the tabs in separate windows, side-by-side.


If you see the Choose an account page, click Use Another

Account.

3. In the Sign in page, paste the username that you copied from the
Connection Details panel. Then copy and paste the password.

Important: You must use the credentials from the Connection Details
panel. Do not use your Qwiklabs credentials. If you have your own
Google Cloud account, do not use it for this lab (avoids incurring
charges).

4. Click through the subsequent pages:


o Accept the terms and conditions.
o Do not add recovery options or two-factor authentication (because

this is a temporary account). o Do not sign up for free trials.

After a few moments, the Cloud Console opens in this tab.

Note: You can view the menu with a list of Google Cloud Products and Services by clicking the
Navigation menu at the top-
left.

Activate Cloud Shell


Cloud Shell is a virtual machine that is loaded with development tools. It offers
a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell
provides command-line access to your Google Cloud resources.

In the Cloud Console, in the top right toolbar, click the Activate Cloud Shell
button.

Click Continue.

It takes a few moments to provision and connect to the environment. When


you are connected, you are already authenticated, and the project is set to
your PROJEC

T_ID. For example:


In Cloud Shell command line, clone the GitHub repository: as written in above

command in the screenshot.

git clone https://github.com/firebase/friendlychat-web

The friendlychat-web repository contains sample projects for multiple


platforms. This lab uses only two repositories:

web-start: The starting code that you'll build upon in this lab. web: The
complete code for the finished sample app.

View the starter application


Throughout this lab you will be modifying files in the friendlychat-
web directory. You can use text editors that come pre-installed in Cloud Shell
(like nano or vim), but this lab will use the Cloud Shell code editor.
To view friendlychat-web, click the Open Editor icon and then click Open
in a new window.

This opens a new browser window with the Cloud Shell tab.

The friendlychat-web/web-start directory contains the starting code for


this lab, which consists of a fully functional Chat Web App.

Navigate to friendlychat-web/web-start in the left pane to view the


application files and code in the right pane. In this lab, navigation is relative to
friendlychat-web/web-start.

Set up your Firebase project


Now that your files are opened up in the Cloud Shell code editor, get Firebase
set up. The application you build in this lab uses the whole set of Firebase
products available on the web:

• Firebase Authentication to easily let your users sign-in your app.


• Cloud Firestore to save structured data on the cloud and get instant
notification when data changes.

• Cloud Storage for Firebase to save files in the cloud.


• Firebase Hosting to host and serve your assets.
• Firebase Cloud Messaging to send push notifications and display
browser popup notifications.

Enable Firebase on your project


1. Open the Firebase console in a new tab with this link. You may need to
sign in again using your lab username and password.

2. On the Welcome to Firebase! page, click Add project.


3. In the Enter your project name dialog, select your project name.

4. Check I accept the Firebase terms. Click Continue.


5. In the Confirm Firebase billing plan dialog, click Confirm Plan.
6. In the A few things to remember when adding Firebase to a Google
Cloud projectdialog, click Continue.
7. In the Google Analytics for your Firebase project dialog, click
Continue.

8. In the Configure Google Analytics dialog:


• Uncheck Use the default settings for sharing Google Analytics for
Firebase data.
• Check to accept the Measurement Controller-Controller Data
Protection terms and acknowledge you are subject to the EU End
User Consent Policy.
• Check I accept the Google Analytics terms.
• Click Add Firebase.

Add a Firebase web app


Click the web icon to create a new Firebase web app.

Register the app with the nickname Friendly Chat, then check the box next to
"Also set up Firebase Hosting for this app". Click Register app.

Click through the remaining steps. You don't need to follow the instructions
now, these will be covered in later steps.

Enable Google sign-in for Firebase Authentication


Now enable Google Authentication to allow users to sign in to the web app
with their Google accounts.

• Click the Authentication tile > Get started > Sign-in method.

• Mouse over Google, then click the pencil icon.


• Move the toggle to Enable.
• Give the project the public-facing name "Friendly Chat".
• Click in the project support email field, select your lab email.
• Then click SAVE.

Now a user can sign into the app with their Google account credentials.

Enable Cloud Firestore


The app uses Cloud Firestore to save the chat messages and receive new
chat messages.
To enable Cloud Firestore on your Firebase project, select Firestore from the
left menu, then click Create database under Cloud Firestore.

Select the Start in test mode option, then Next.


Leave the default Cloud Firestore location, click Enable.
Install the Firebase command line
interface
Cloud Shell comes with the firebase command line interface
(CLI) already installed.
In Cloud Shell, check what version of Firebase is installed
with the following command:
firebase –version

The output should show a version above 6.0.0. Authorize


the Firebase CLI:
firebase login --no-localhost

The --no-localhost option is used because you are on a


remote shell.
When asked if you should Allow Firebase to collect CLI
usage and error reporting information?, type "Y".
Copy the link in the output into a new tab. Do not click the
link! Select your lab username, then click Allow.
Copy the verification code from the browser and enter it in
the Cloud Shell prompt.
Still in Cloud Shell command line, navigate to friendlychat-
web > web-start directory by running:
cd ~/friendlychat-web/web-start/

content_copy
Now set up the Firebase CLI to use your Firebase Project:
firebase use --add

content_copy
You'll be asked which project to add. Use the arrow keys to
select your Project ID, then press Enter. When prompted,
create an alias, such as staging.
Giving your project an alias is helpful if you are managing
multiple apps/projects. You can switch between aliases in
Cloud Shell with firebase use <alias_name>.
Stop the app by pressing

Ctrl + c

. This lab has laid out only the UI for you so far.

Now you will build a realtime chat!

Import and Configure Firebase


Import the Firebase SDK
In the Cloud Shell code editor, navigate to friendlychat-web >
web-start> public and open the index.html to check it out. You
will be editing this file soon.
Since this lab uses Firebase Hosting to serve the
application, the local URLs are imported in the index.html.
You can scroll to
the bottom of the file and look for them.
<script src="/__/firebase/6.3.0/firebase-app.js"></script> <script
src="/__/firebase/6.3.0/firebase-auth.js"></script>

<script src="/__/firebase/6.3.0/firebase-storage.js"></script> <script


src="/__/firebase/6.3.0/firebase-messaging.js"></script> <script
src="/__/firebase/6.3.0/firebase-firestore.js"></script> <script
src="/__/firebase/6.3.0/firebase-performance.js"></script>

You also need to tell the Firebase SDK which project you're
using. A special script is also imported to do that.
<script src="scripts/main.js"></script>
Set up user sign in
The Firebase SDK was imported and initialized in the index.html file, so it's
ready to use. Next, implement user sign-in using Firebase Auth.

Set up app's OAuth concent screen


The OAuth consent screen allows users to choose wether they want to grant
access to their private data as well as gives them a link to your terms of
service. For this lab, you you'll use the "internal" setting for simplicity. Read
through this page to understand what to provide for your production
environment.

In the Cloud Console, from Navigation menu click on APIs & Services >
OAuth consent screen.

For User type, Click Make Internal.

Then click Confirm.

Authenticate your users with Google Sign-In


When the user clicks the Sign in with Google button, the signIn function is
triggered (this is already set up for you). Authorize Firebase to use Google as
the Identity Provider. Users will sign in using a popup.

In the code editor, navigate to scripts/main.jsand update the signIn


function with the following information:
// Signs-in Friendly Chat.
function signIn() {

// Sign into Firebase using popup auth & Google as the identity provider.
var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider);

content_copy

The signOut function is triggered when the user clicks Sign out. Update the
signOutfunction with:

// Signs-out of Friendly Chat.


function signOut() {
// Sign out of Firebase.
firebase.auth().signOut();
}
content_copy

Track the auth state


To update the UI accordingly, you need a way to check if the user is signed-in
or signed-out. With Firebase Auth, you can register an observer on the
authentication state which will be triggered each time the auth state changes.

Still in scripts/main.js, update the initFirebaseAuth function:


// Initiate Firebase Auth.
function initFirebaseAuth() {
// Listen to auth state changes.

firebase.auth().onAuthStateChanged(authStateObserver); }

content_copy

This registers the function authStateObserver as the observer. It triggers


every time there is a change in the auth state - when the user signs in or signs
out. This function updates the UI to display or hide the Sign-in button, the
Sign-
out button, and the signed in user's profile picture.
Display the signed in user information
In Firebase, the signed-in user's data is always available in
the firebase.auth().currentUser object. The authStateObserver
function will call the getProfilePicUrl and getUserName when triggered.

To display the users name and profile picture, update the profile pic and
display name functions to the following:
// Returns the signed-in user's profile pic URL. function
getProfilePicUrl() {

return firebase.auth().currentUser.photoURL ||
'/images/profile_placeholder.png';
}

// Returns the signed-in user's display name. function getUserName() {

return firebase.auth().currentUser.displayName; }

content_copy

If the user tries to send a messages when they are not signed in, the app
should display an error message. To detect if the user is actually signed in,
change
the isUserSignedIn function to:
// Returns true if a user is signed-in.
function isUserSignedIn() {

return !!firebase.auth().currentUser; }

content_copy

Save scripts/main.js.

Test signing-in to the app


Redeploy your app by running:
firebase deploy --except functions

content_copy

Click on the Hosting URL that is returned to open the application in your
browser.

Sign in using the Sign-In with Google button. Remember to use your
Qwiklabs credentials!
After Signing in the profile pic and name of the user will be displayed:

Write messages to Cloud Firestore


Next you'll write some data to Cloud Firestore so that you can populate the
app's UI. This can be done manually in the Firebase console, but for this lab
you'll do it in the app itself to demonstrate basic Cloud Firestore write.

Data model
Firestore data is split into collections, documents, fields, and subcollections.
Each message of the chat is stored as a document in a top-level collection
called messages.

Add messages to Firestore


In this section you’ll add the functionality to let users write new messages to
Cloud Firestore. A user clicking the SEND button will trigger the code snippet
below. It adds a message object with the contents of the message fields to
your Firestore instance in the messages collection. The add() method adds
a new document with an automatically generated ID to the collection.

Go back to the file public/scripts/main.js. Find the function


saveMessage. Replace the entire function with the following code:
// Saves a new message on the Cloud Firestore.
function saveMessage(messageText) {

// Add a new message entry to the Firebase database. return


firebase.firestore().collection('messages').add({

name: getUserName(),
text: messageText,
profilePicUrl: getProfilePicUrl(),
timestamp: firebase.firestore.FieldValue.serverTimestamp()

}).catch(function(error) {
console.error('Error writing new message to Firebase Database', error);

}); }

content_copy

Test sending messages


Redeploy your app by running:
firebase deploy --except functions

content_copy

Click on the Hosting URL that is returned to open the application in your
browser.

After signing-in, enter a message such as “Hi there!”, then click SEND. This
will write the message into Firestore. However, you won't yet see the data in
your
actual web app because you still need to implement retrieving the data (the
next section of the lab).

You can see the newly added message in your Firebase Console. In the
Develop section click on Firestore and you should see the messages
collection with your newly added message:

Read messages
Synchronize Messages
To read messages on the application, add listeners that trigger when changes
are made to the data then creates a UI element that shows new messages.

In scripts/main.js, update the loadMessages function:

// Loads chat messages history and listens for upcoming ones. function
loadMessages() {
// Create the query to load the last 12 messages and listen for new ones.
var query = firebase.firestore()
.collection('messages')
.orderBy('timestamp', 'desc')
.limit(12);

// Start listening to the query. query.onSnapshot(function(snapshot) {

snapshot.docChanges().forEach(function(change) { if (change.type ===


'removed') {

deleteMessage(change.doc.id);
} else {

var message = change.doc.data();


displayMessage(change.doc.id, message.timestamp, message.name,

message.imageUrl);
}

}); });

content_copy

message.text, message.profilePicUrl,

To listen to messages in the database, create a query on a collection by using


the .collection function to specify in which collection is the data you want
to listen to. Above, you're listening to the changes under the messages
collection, which is where the messages are stored. You're also applying a
limit and only listening to the last 12 messages using .limitToLast(12)
and ordering the messages by date using .orderBy('timestamp','desc')
to get the 12 newest
messages.

The .onSnapshot function takes one parameter: a callback function. The


callback function will be triggered when there are any changes to documents
that match the query. This could be if a message gets deleted, or modified, or
added.
Test message sync
Redeploy your app by running:
firebase deploy --except functions

content_copy
Click on the Hosting URL that is returned to open the application in your
browser or refresh the Friendly Chat tab you're already signed into.

The messages you typed earlier and saw in the database should be displayed
in
the Friendly Chat UI. You can also write a new message, it should appear
instantly. You can also try manually deleting, modifying, or adding new
messages directly in the Firestoresection of the Firebase Console, the
changes should reflect in the UI.

Send Images
Now add a feature that shares images.

While the Cloud Firestore is good to store structured data, files are better
stored in Cloud Storage. Cloud Storage for Firebase is a file/blob storage
service. Use it to store the images the user shares.

Save images to Cloud Storage


There's already a button in the UI that triggers a file picker dialog. After
selecting an image file, the saveImageMessage function is triggered and you
get a reference to the selected file. You'll add code to the file that:

• Creates a "placeholder" chat message into the chat feed, so that users
see a "Loading" animation while we upload the image.
• Upload the image file to Cloud Storage to the path:
/<uid>/<messageId>/<file_name>.
• Generate a publicly readable URL for the image file.
• Update the chat message with the newly uploaded image file's URL in
lieu

of the temporary loading image.


Now actually add the funtionality. In scripts/main.js, modify the
saveImageMessage function to the following:

// Saves a new message containing an image in Firebase. // This first


saves the image in Firebase storage. function saveImageMessage(file) {

// 1 - We add a message with a loading icon that will get updated with the
shared image.

firebase.firestore().collection('messages').add({
name: getUserName(),
imageUrl: LOADING_IMAGE_URL,
profilePicUrl: getProfilePicUrl(),
timestamp: firebase.firestore.FieldValue.serverTimestamp()

}).then(function(messageRef) {
// 2 - Upload the image to Cloud Storage.
var filePath = firebase.auth().currentUser.uid + '/' + messageRef.id +

'/' + file.name;
return

firebase.storage().ref(filePath).put(file).then(function(fileSnapshot) {
// 3 - Generate a public URL for the file.
return fileSnapshot.ref.getDownloadURL().then((url) => {
// 4 - Update the chat message placeholder with the image's URL. return
messageRef.update({

imageUrl: url,

storageUri: fileSnapshot.metadata.fullPath });

}); });

}).catch(function(error) {
console.error('There was an error uploading a file to Cloud Storage:',

error); });

content_copy

Test sending images


Redeploy your app:
firebase deploy --except functions

content_copy

Open the hosting URL, or refresh your app.

Click the image upload button and select an image file from your computer
using the file picker. If you’re looking for an image, feel free to use this
nice pic of my gallery.
Create a sample web-based application using Python and deploy it on
AWS.

Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your
payment method. On the left is a panel populated with the temporary credentials that you must
use for this lab.

Copy the username, and then click Open Google Console. The lab spins up resources, and then
opens another tab that shows the Sign in page.

In the Sign in page, paste the username that you copied from the Connection Details panel. Then
copy and paste the password.

Important: You must use the credentials from the Connection Details panel. Do not use your
Qwiklabs credentials. If you have your own Google Cloud account, do not use it for this lab (avoids
incurring charges).

Now Activate Cloud Shell,

Enable Google App Engine Admin API


The App Engine Admin API enables developers to provision and manage their
App Engine Applications.

1. In the left menu click APIs & Services > Library.


2. Type "App Engine Admin API" in search box.
3. Click App Engine Admin API.
4. Click Enable. If there is no prompt to enable the API, then it is already
enabled and no action is needed.

Download the Hello World app


There is a simple Hello World app for Python you can use to quickly get a feel
for deploying an app to Google Cloud. Follow these steps to download Hello
World to your Google Cloud instance.

1. Enter the following command to copy the Hello World sample app
repository to your Google Cloud instance:

2. Go to the directory that contains the sample code:

Make a change
You can leave the development server running while you develop your
application. The development server watches for changes in your source files
and reloads them if necessary.
Let's try it. Leave the development server running. We'll open another
command line window, then edit main.py to change "Hello World!" to "Hello,
Cruel World!".

1. Click the (+) next to your Cloud Shell tab to open a new command line
session.

2. Enter this command to go to the directory that contains the sample code.

cd python-docs-samples/appengine/standard_python3/hello_world

3. Enter the following to open main.py in nano to edit the content.

nano main.py

4. Change "Hello World!" to "Hello, Cruel World!". Exit and save the file. 5.
Reload the Hello World! Browser or click the Web Preview > Preview

on port 8080to see the results.

Deploy your app


To deploy your app to App Engine, run the following command from within the
root directory of your application where the app.yaml file is located:

gcloud app deploy

View your application


To launch your browser enter the following command, then click on the link it
provides.

MODULE : API Basics


Salesforce
An API is equivalent to a user interface, except it’s designed for software instead of

humans. This is why APIs are often described in the media as technology that allows

applications to talk to one another.

The client sends a request for specific information or functionality to another system. That
system

returns the data or functionality in a response. To send or receive data, there is an


expectation

that it will be in a specific format that both sides can understand. That format is often very

sensitive to the context(s) it serves. Let's take a closer look.

APIs: The Electric Current Between Software


So what, if anything, do electric wall sockets have to do with APIs?

• The electricity coming from the wall is a service. It can stop and start at any
time.
• The treadmill plugged into the wall uses the electricity to run.
• Since the treadmill does not have its own source of power, the treadmill is

outsourcing the power it needs to a service provider, for example, to one that
uses wind turbines or solar power.

While electrical sockets differ depending on where you are in the world, they
have predictable, standard patterns of openings; and the electrical plugs
attached to devices like treadmills are designed to fit those standard patterns.

All these specifications essentially set expectations on behalf of any device


that wants to use the service. The plugs and power supplies conform to the
standard patterns and specifications (like 120 volts) for the service. The same
goes for APIs.

2.The Benefits of Using APIs :


APIs.

Outsourcing
APIs help open up a plethora of opportunities. Here are ways that software,

customers, citizen integrators, developers, and their teams can benefit from using

In the name of repeatability, any compatible device (in this case, the gym equipment)

can easily outsource its electrical requirements to a service, and those devices can

expect to get the same results.

Similarly, APIs allow you to outsource key data and functionality through a

predictable standard interface. Focus on making great applications, services, and

customer experiences, not on figuring out how you’re going to get common, yet

nuanced information.

Increased Mobility
Consuming-devices are easily moved from one socket to another. For example, with
no plug, matching socket or specifications, the gym owner may have to hardwire
equipment into the walls of the building

Abstraction
When taking a look at the fitness club, the electrical socket is a layer of abstraction to
the underlying service, or electricity. What is abstraction you ask? It is a way of hiding
the working details of another system.

As long as the service delivers 120 volts of AC power to the wall socket in the
standard way, the service provider is free to change anything and everything from
just behind the socket all the way to the source of power. Any changes are opaque to
consuming devices.

Increased Developer Productivity


When programmers write code, they rarely start from scratch. APIs are designed to
take an existing code base and use it whenever, wherever instead of attempting to
re-create those features.

Using HTTP Protocols to Access Data


While there are no rules or laws deciding exactly how developers must connect their
applications to an API, several standards have emerged.

For example, when applications connect to APIs from across the Internet, the
majority of API providers make these connections available over HTTP, or hypertext
transfer protocol, otherwise known as the World Wide Web.

API
While reusing existing code limits differentiation between applications, a reference to

the API (more commonly referred to as "calling" an API) can supply the program with

the expected data or functionality.

HTTP Verbs

Descriptions

POST

Submit requested data to a server for processing

GET

Retrieve requested data from a server

PUT

DELETE

Update and replace existing data with new data being sent in the request

Remove the requested data from the server

Of course, the above response isn’t very intuitive and would never be presented to
the treadmill user. It is formatted according to another standard called JSON
(JavaScript Object Notation) that is often used with HTTP.

Treadmill Interface
Once the treadmill receives a response, the user can see total calories burned, how
they're tracking against the most recent fitness challenge, and more.

Thanks to the thousands of APIs that software developers and non-programmers


equipped with citizen integration tools (citizen integrators) can reach over the

Internet (more than 23,000 by last count according to ProgrammableWeb.com), the

Web has turned into a programmable platform that’s equally, if not more, powerful

than programmable platforms including Windows, Mac, and Linux.

3. Put the Web in Web API


Networkable APIs Are Game-Changers :

APIs aren’t limited to what can be found in the same local network. Developers and
citizen integrators can also consume APIs offered by remote systems and devices.

The number and types of devices that can be plugged into electrical sockets are

limited only by the imaginations of inventors and the capacity of the utility.

API Economy
Depending on the volume of calls or some other way of breaking down different tiers
of service, a provider like Google might charge the application developer a fee for
using the API. This gives rise to the idea of an API economy.

API Growth Then and Now


You may be thinking networkable APIs are the greatest thing since sliced bread. You
also may be wondering, if they’re so great, why didn’t the tech industry come up with
them earlier? As it turns out, it did.

Back in the days when Unix first came out, it was not uncommon for programmers to
remotely invoke business logic from another machine across a network through a
technology called RPC, or remote procedure call.

The (Possible) Future of Integration


So if history is any kind of indicator, the way we integrate between systems may be
due for a change. There are now two relatively new API-like technologies that part
ways with the currently favored web approach. One comes from Facebook, called
GraphQL, and the other is from Google, called gRPC.

You might also like