Below is a Python example, taken from other examples I saw :)
from watson_developer_cloud import DiscoveryV1
# SETUP ALL OF THE DISCOVERY API CREDENTIALS AND IDENTIFIERS;
my_url= "https://gateway.watsonplatform.net/discovery/api"
my_Disc_uname= "-my-freekishglky-long-name"
my_Disc_pwd="my-random-generated-password"
my_disc_collection_id ="also from credentials after I create service"
my_disc_configuration_id = "yet-another-key"
my_disc_environment_id = "my-environment"
# FIRST CALL TO DISCOVERY; GATHER THIS GIVES ME COOKIE AND SESSION
discovery = DiscoveryV1(
username=my_Disc_uname,
password=my_Disc_pwd,
version="2016-12-01"
)
qopts = {
"query": "INTERESTING STUFF",
"count": "0",
"filter": "yyyymmdd>20170401",
"aggregation" : "term(docSentiment.type,count:3)"
}
# CALLING WATSON DISCOVERY SERVICE RIGHT HERE ...
my_query = discovery.query(my_disc_environment_id, my_disc_collection_id, qopts)
I created the service on BlueMix -- and received the credentials. This snippet can run from my laptop and connect to the Watson Discovery service.