This topic provides basic instructions for obtaining credentials for Watson services and provides relevant links for each service and the Watson Developer Cloud SDKs.
Watson services homepages:
Version | Release Date |
---|---|
1.0.0 | 2016-05-05 |
Depending on the service, you will either need to use Basic Authentication with a username
and password
or pass an apikey
as a parameter in each request.
Some services also support token authentication.
GET using Tone Analyzer:
curl -X GET \
-u "username":"password" \
-d "version=2016-05-19" \
-d "text=Hey! Welcome to Watson Tone Analyzer!" \
"https://gateway.watsonplatform.net/tone-analyzer/api/v3/tone
POST using AlchemyLanguage:
curl -X POST \
-d "apikey=YOUR_API_KEY" \
-d "url=www.ibm.com" \
"https://gateway-a.watsonplatform.net/calls/url/URLGetRankedKeywords"
To authenticate to Watson services, you need credentials for each service that you plan to use. Depending on the service, you will need to pass a username and password with Basic Authentication, or you will need to pass an API key in a parameter for each request you make.
How to get credentials for a Watson service:
The quickest way to get started with Watson services is to use the Watson Developer Cloud SDKs. The following GitHub repositories contain installation instructions and basic usage examples:
For example, here's how to make an AlchemyLanguage API call with the Node.js SDK:
Install the SDK:
$ npm install watson-developer-cloud
Save the following code to a file (we'll call it app.js). Make sure you replace API_KEY
with your API key.
// Instantiate the service
var AlchemyLanguageV1= require('watson-developer-cloud/alchemy-language/v1');
var alchemy_language = AlchemyLanguageV1({
api_key: 'API_KEY'
})
var parameters = {
extract: [
'entities',
'keywords'
]
url: 'https://www.ibm.com/us-en/'
};
alchemy_language.combined(parameters, function (err, response) {
if (err)
console.log('error:', err);
else
console.log(JSON.stringify(response, null, 2));
});
Run the app:
$ node app.js