Skip to content

Lab Assignment 9: Cloud Based Application II

Moulika Chadalavada edited this page Oct 28, 2016 · 10 revisions

Cloud Based Application- II

Class Id: 8
Student Id: 16234180
Student Name: Moulika Chadalavada


Objective

Using Node.js Express Framework, the below tasks are achieved.

1. Create a Private REST service that is Mashup of at least two public REST services.
2. Use this private web service in your web/mobile/hybrid application
3. Try to use a different web service and create some good use case
4. Application should have good UI/UX.

The API's which are used for Mash up are Spofity API and Alchemy Data News API.

Software/Tools Used

Webstorm, Angular JS, Node JS, HTML, CSS, Bootstrap

API's Used

Alchemy News API: Highly targeted search, trend analysis and historical access to news and blog content. Spotify API: This API is used to fetch data from the Spotify music catalog and manage user’s playlists and saved music.

Application Description

The application is about creating Private REST Service using Mash up of two public service i.e. Alchemy News API and Spotify API. In **server.js** server is created using **http.CreateServer** and listen for requests. Request is came from browser and response is sent back to same browser. In **client.js** start 'html' (**path: '/index.html'**) file is given and the callback response is handled (**var req = http.request(options, callback);**)

Server.js where connection is started


Client.js which starts index.html and handles callback responses


Once the server is started, index.html has to be executed which displays below login page where the user has to enter valid details. Once the user is logged in successfully he will be redirected to home page.

Login Page



Home Page


The two API's that are used here to perform Mashup are **_Alchemy News API_** and **_Spotlight Music API_**.This application helps in creating music playlists from Spotify based on what is happening in the news that is extracted from Alchemy.

In the home page search button the user enter few keywords of news they are interested in. This information is sent to the Alchemy API which checks the news articles that are related to these keywords and returns the titles to those articles. The news titles are then parsed and inserted into Spotify API that finds songs with titles that match to each and every word in the news titles.

The below is the API URL to which the keyword is parsed and the top news is fetched.

https://gateway-a.watsonplatform.net/calls/data/GetNews?outputMode=json&start=now-1d&end=now&count=5&q.enriched.url.enrichedTitle.keywords.keyword.text=searchkey&return=enriched.url.url,enriched.url.title&apikey=secretkey (secretkey: client_id ; searchkey: keyword entered in search)

  • Private Rest API Call for Alchemy News API

Alchemy News API invocation from Private Rest

JSON Output for the word search 'India'


For example, if the users gives keyword 'heart' and click on Go button then this keyword is sent to Alchemy API to fetch all the headlines related it. The fetched headlines are displayed in the text-area as show below.

Word Search to get top News from Alchemy API



The data is sent to Spotify API which reads every word in the headlines and returns the songs along with album name,artist etc. as shown below.

The below is the spotify API URL to which each and every word from news is sent and music album is fetched as response.

https://api.spotify.com/v1/search?type=track&limit=10&q=track:keyword (keyword: words that are fetched from Alchemy News)

  • Private Rest API Call for Spotify API

Spotify API invocation from Private Rest

JSON Output


Based on words Music Library is returned using Spotify API



To add these suggested songs into Spotify playlist then the user has to click on **_Create Spotify Playlist from suggested list_** button which will be redirected to Spotify login page.

Spotify Sign Up/Sign In to Add Playlist

Spotify Login In Page to Add Playlist



If the user logged in successfully then the displayed playlist will be added in Spotify.

Spotify Playlist is Added Successfully

References

ASE Tutorial-9

http://stackoverflow.com

http://getbootstrap.com/

https://developer.spotify.com/web-api/

http://www.alchemyapi.com/api/newsapi

https://www.youtube.com/watch?v=fPKzsPac_OU