Category Archives: cloudant

Creating a Nodejs App with Watson AlchemyAPI and CloudantDB

WIP

Requirements:

Overview:

  1. Setup
  2. Setup Details
  3. Add Watson AlchemyAPI
  4. Add Cloudant DB

Setup

  1. Login to Bluemix, in a separate tab login to Github,
  2. In Bluemix open Catalog->Boilerplates and create a ‘Node.js Cloudant DB Web Starter’ Boilerplate, named ‘<username>-nodejs-app1’, click CREATE
  3. Go to ‘Overview’, scroll down to ‘Continuous delivery’ and click ‘Enable’
  4. In the ‘Toolchain Settings’, change the name of the Toolchain to ‘<username>-nodejs-app1’, and click Create,
  5. If the Github THINK or CODE icon displays a configuration error, from the block’s dropdown icon in the topright, click the ‘Configure’ link to correct the configuration of your Github account,
  6. Go to your Github account and make sure that the repository for the new Bluemix app is created successfully,
  7. Copy the Git URL, on localhost open a commandline terminal, change to your development directory and clone the new repository,
    cd ~/dev/src/bluemix
    git clone https://github.com/remkohdev/remkohdev-nodejs-app1.git
    cd remkohdev-nodejs-app1
  8. Open the project directory in your favorite editor,
  9. Open the ‘package.json’ file and change the ‘name’ property to ‘<username>-nodejs-app1’,
  10. From the commandline, in your project directory,
    git status
    git add .
    commit -m "change package.json name property"

Continue reading

Creating Sentiment Line Chart for the News with Watson, Python, and D3js

Requirements:
You must have Python installed. Check to see if you have Python installed from the commandline:
python --version

Table of Contents:

  1. Create a Starterapp
  2. Git Clone and Setup
  3. Create Additional Folders and Files
  4. Commit and Push Changes to Repository, Build and Deploy
  5. Create an AlchemyAPI service
  6. Create a Cloudant NoSQL service
  7. Add the Basic Workflow for Request-Response
  8. Get News using AlchemyAPI
  9. Create Helper Functions
  10. Save Responses in Cloudant
  11. Parse Response for D3js
  12. Draw the Line Chart in D3js

You can import AlchemyAPI requests into Postman with this Postman collection.

The source code for the application can be viewed or cloned from Github.

1. Create a Starterapp

  1. Go to Catalog > Boilerplates
  2. Click the ‘Python Flask’ starterapp
  3. For name enter <username>-newssentiment
  4. Go to Overview
  5. Under ‘Continuous Integration’ click ‘Add GIT Repo and Pipeline’ to add a DevOps platform, select ‘Populate the repo with the starterapp packageand enable Build & Deploy pipeline’ > Click Continue > Click ‘CLOSE’.
  6. Click ‘EDIT CODE’.
  7. The very first time you login to the ‘DevOps’ environment you will need to pick a username for the ‘DevOps’ environment.
  8. In the left menu of icons, click the top folder icon, and click ‘Git URL’ to copy the Git repository url.
  9. If you prefer to edit in the online editor in Bluemix, click ‘EDIT CODE’ button and then click the second pencil icon in the left menu of icons.
  10. I will continue to work on localhost instead.

Continue reading