Add Serverless Programming and Data Integration on Bluemix

Add Serverless or Event-Based Programming using OpenWhisk:

  1. Go to the OpenWhisk service at https://console.ng.bluemix.net/openwhisk
  2. Click the ‘Develop’ button, which takes you to the Openwhisk editor,
  3. Create a new Action and implement the JavaScript function,
  4. At the bottom right, click the ‘View REST Endpoint’, and in the ‘cURL Example’, click the ‘Show Full Command’ to reveal the Base64 encoded authentication token for the OpenWhisk service,
  5. You can get the username:password credentials by installing the OpenWhisk ‘wsk’ command line and run:
    wsk property get --auth
    Or to Base64 encode it, run:
    wsk property get --auth | awk '{printf("%s", $3)}' | base64
  6. The way to call the OpenWhisk endpoint is using ‘Basic Auth’:
    https://openwhisk.ng.bluemix.net/api/v1/namespaces/<organization_id>_<space>/actions/<action>?blocking=true
  7. Then, for example:

    • Next create a new action and link the two actions together by Extending the first action and link it to the second action.
    • Next create an action to save the result to the Cloudant Database using the ‘Create Document’ action,
    • Next trigger the Slack notification

Using Twitter data via DashDB:

  1. Create a DashDB service
  2. Create a Insights for Twitter service
  3. Open the DashDB dashboard > Load > Load Twitter Data > select the Twitter Service we created > Next
  4. In the Search for Twitter data: “#SEC posted:2016-11-01,2016-11-15”
  5. Click Get Tweet Count > Next
  6. Select ‘Load the data into new tables with this prefix:’ and enter prefix ‘SEC_Twitter’ > Next > Next > Finish

insights_for_twitter_sec_finished

Using public SEC data via DashDB:
https://www.sec.gov/dera/data/financial-statement-data-sets.html
Download the SEC file for 2016Q3: 2016q3.zip

  1. Unzip the ‘2016q3.zip’ archive,
  2. Load the 4 *.txt files: num, pre, sub, tag,
  3. Load > Load from Desktop > drop the file into the upload window,
  4. Change the separator character to ‘tab’,
  5. Don’t check the ‘Does the file have columns that contain dates or times? Yes No’, this may break the dataload sometimes, as the data is not always 100% cleaned correctly,
  6. Rename the tables so they have the prefix ‘SEC_2016Q3_’.

Other datasets:

  • Pitney Bowes Geodata:
    1. Add the Pitney Bowes service to your Bluemix application
    2. Get AccessToken using OAuth2:
      curl -X POST -H "Authorization: Basic a2t2eetceteratVA==" -H "Content-Type: application/x-www-form-urlencoded" -d 'grant_type=client_credentials' "https://api.pitneybowes.com/oauth/token"
    3. Then call the PB service:
      curl -X GET -H "Authorization: Bearer vc84ZaccesstokenoK2" "https://api.pitneybowes.com/location-intelligence/geolife/v1/demographics/byaddress?address=550%20W%2054th%20St%2C%20New%20York%2C%20NY%2010019&country=USA"
  • WeatherCompany Data:
    1. Add the WeatherCompany Data service to your Bluemix application,
    2. Get the username and password from the credentials,
    3. Daily Forecasts:
      curl -X GET "https://<username>:<password>@twcservice.mybluemix.net/api/weather/v1/geocode/33.40/-83.42/forecast/daily/10day.json?units=m&language=en-US"
    4. Current Conditions:
      curl -X GET "https://<username>:<password>@twcservice.mybluemix.net/api/weather/v1/geocode/33.40/-83.42/observations.json?language=en-US&units=m"
    5. Almanac (Historic Data):
      curl -X GET "https://<username>:<password>@twcservice.mybluemix.net/api/weather/v1/geocode/33.40/-83.42/almanac/monthly.json?start=01"
Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *