Add Serverless or Event-Based Programming using OpenWhisk:
- Go to the OpenWhisk service at https://console.ng.bluemix.net/openwhisk
- Click the ‘Develop’ button, which takes you to the Openwhisk editor,
- Create a new Action and implement the JavaScript function,
- 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,
- 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
- 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
- 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:
- Create a DashDB service
- Create a Insights for Twitter service
- Open the DashDB dashboard > Load > Load Twitter Data > select the Twitter Service we created > Next
- In the Search for Twitter data: “#SEC posted:2016-11-01,2016-11-15”
- Click Get Tweet Count > Next
- Select ‘Load the data into new tables with this prefix:’ and enter prefix ‘SEC_Twitter’ > Next > Next > Finish
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
- Unzip the ‘2016q3.zip’ archive,
- Load the 4 *.txt files: num, pre, sub, tag,
- Load > Load from Desktop > drop the file into the upload window,
- Change the separator character to ‘tab’,
- 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,
- Rename the tables so they have the prefix ‘SEC_2016Q3_’.
Other datasets:
- Pitney Bowes Geodata:
- Add the Pitney Bowes service to your Bluemix application
- 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"
- 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:
- Add the WeatherCompany Data service to your Bluemix application,
- Get the username and password from the credentials,
- 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"
- 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"
- 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"