JavaScript Dev

JavaScript Dev


Calling Rest API from JavaScript / jQuery

How to call rest APIs in javascript/jquery. In this tutorial, you will learn how to call rest APIs in javascript/jquery on your web applications or web pages.

If you are looking for how to consume restful web services in javascript, call rest service from HTML page, jquery rest API post, ajax API, call example, jquery API call, calling web API from jquery ajax, javascript call rest API JSON. This tutorial solves your all queries related to calling APIs (web services).

In this web services (Apis) tutorial, we will call Google’s free news web service (API). This will make it easier for you to learn how to call web service and API in JavaScript and Jquery using Ajax.

You might not know that Google provides free (web services) APIs for news. You can get the Google News API key by clicking on the link given below.

Calling Google News RESTful Web Service with JavaScript / jQuery

This guide walks you through writing a simple javascript/jquery to calling rest web service.

Google News Apis key:


This the google news web services (Apis)

When we call Google News API and web service with the help of javascript and jquery then we will get the JSON response given below.

"status": "ok",
"totalResults": 38,
"articles": [
    "source": {
    "id": null,
    "name": ""
    "author": null,
    "title": "Coronavirus: Death toll rises to 81 as China extends holiday  BBC News  BBC News",
    "description": "The number of people killed in China by the new coronavirus has risen to 81, with almost 3,000 confirmed ill. The national new year holiday has been extended...",
    "url": "",
    "urlToImage": "",
    "publishedAt": "20200127T10:35:49Z",
    "content": "The number of people killed in China by the new coronavirus has risen to 81, with almost 3,000 confirmed ill.
    The national new year holiday has been extended by three days to Sunday, in an attempt to contain the spread.
    On Monday, Chinese Premier Li Keqiang… [+268 chars]"
    "source": {
    "id": "thewashingtonpost",
    "name": "The Washington Post"
    "author": "Gerry Shih, Simon Denyer",
    "title": "Worries grow that quarantine in China not enough to stem increasingly virulent coronavirus  The Washington Post",
    "description": "Even as the quarantine was being laid down, some 5 million people left Wuhan, the virus epicenter.",
    "url": "",
    "urlToImage": "",
    "publishedAt": "20200127T10:21:00Z",
    "content": "Chinas health minister said the coronavirus is increasing in virulence and now could be contagious even before people exhibit symptoms making perfectly healthyseeming people possible carriers.
     A scientific assessment of the disease spread assuming an optim… [+10160 chars]"

Create a js File

First, you will create the js file and in this file call the web service (apis) :

$(document).ready(function() {
        url: ""
    }).then(function(data) {
        for (i = 0; i < data.articles.length; i++) {

This controller module is represented as a simple JavaScript function. It uses jQuery’s $.ajax() method to consume the REST service at If successful, it will assign the JSON received to data, effectively making it a Greeting model object. The id and content are then appended to the news id and DOM elements respectively.

Note the use of the jQuery promise .then(). This directs jQuery to execute the anonymous function when the $.ajax() method completes, passing the data result from the completed AJAX request.

Create the Web Page

Now that you have a js, you will create the HTML page that will load the google news into the user’s web browser:


<!DOCTYPE html>
        <title>Google News Apis</title>
        <script src=""></script>  
        <script src="my-news.js"></script>
        <div id="news"> </div>

We need to add two jQuery /JavaScript libraries inside the head tag on html web page. The former gives jQuery. He: We have created another in which we will call Web Services / Interconnect

<script src=""></script>  
<script src="my-news.js"></script>

We have created a div in an html web page. When calling Google’s free news API / web service, the format that will get the response, we will read in this div. Of the jquery append method ():

Call the API

Open your browser and simply hit the following url into your browser:


#javascript #jquery

What is GEEK

Buddha Community

Calling Rest API from JavaScript / jQuery
Wilford  Pagac

Wilford Pagac


What is REST API? An Overview | Liquid Web

What is REST?

The REST acronym is defined as a “REpresentational State Transfer” and is designed to take advantage of existing HTTP protocols when used for Web APIs. It is very flexible in that it is not tied to resources or methods and has the ability to handle different calls and data formats. Because REST API is not constrained to an XML format like SOAP, it can return multiple other formats depending on what is needed. If a service adheres to this style, it is considered a “RESTful” application. REST allows components to access and manage functions within another application.

REST was initially defined in a dissertation by Roy Fielding’s twenty years ago. He proposed these standards as an alternative to SOAP (The Simple Object Access Protocol is a simple standard for accessing objects and exchanging structured messages within a distributed computing environment). REST (or RESTful) defines the general rules used to regulate the interactions between web apps utilizing the HTTP protocol for CRUD (create, retrieve, update, delete) operations.

What is an API?

An API (or Application Programming Interface) provides a method of interaction between two systems.

What is a RESTful API?

A RESTful API (or application program interface) uses HTTP requests to GET, PUT, POST, and DELETE data following the REST standards. This allows two pieces of software to communicate with each other. In essence, REST API is a set of remote calls using standard methods to return data in a specific format.

The systems that interact in this manner can be very different. Each app may use a unique programming language, operating system, database, etc. So, how do we create a system that can easily communicate and understand other apps?? This is where the Rest API is used as an interaction system.

When using a RESTful API, we should determine in advance what resources we want to expose to the outside world. Typically, the RESTful API service is implemented, keeping the following ideas in mind:

  • Format: There should be no restrictions on the data exchange format
  • Implementation: REST is based entirely on HTTP
  • Service Definition: Because REST is very flexible, API can be modified to ensure the application understands the request/response format.
  • The RESTful API focuses on resources and how efficiently you perform operations with it using HTTP.

The features of the REST API design style state:

  • Each entity must have a unique identifier.
  • Standard methods should be used to read and modify data.
  • It should provide support for different types of resources.
  • The interactions should be stateless.

For REST to fit this model, we must adhere to the following rules:

  • Client-Server Architecture: The interface is separate from the server-side data repository. This affords flexibility and the development of components independently of each other.
  • Detachment: The client connections are not stored on the server between requests.
  • Cacheability: It must be explicitly stated whether the client can store responses.
  • Multi-level: The API should work whether it interacts directly with a server or through an additional layer, like a load balancer.

#tutorials #api #application #application programming interface #crud #http #json #programming #protocols #representational state transfer #rest #rest api #rest api graphql #rest api json #rest api xml #restful #soap #xml #yaml

An API-First Approach For Designing Restful APIs | Hacker Noon

I’ve been working with Restful APIs for some time now and one thing that I love to do is to talk about APIs.

So, today I will show you how to build an API using the API-First approach and Design First with OpenAPI Specification.

First thing first, if you don’t know what’s an API-First approach means, it would be nice you stop reading this and check the blog post that I wrote to the Farfetchs blog where I explain everything that you need to know to start an API using API-First.

Preparing the ground

Before you get your hands dirty, let’s prepare the ground and understand the use case that will be developed.


If you desire to reproduce the examples that will be shown here, you will need some of those items below.

  • NodeJS
  • OpenAPI Specification
  • Text Editor (I’ll use VSCode)
  • Command Line

Use Case

To keep easy to understand, let’s use the Todo List App, it is a very common concept beyond the software development community.

#api #rest-api #openai #api-first-development #api-design #apis #restful-apis #restful-api