Signals Node JS API
Quick Start
Install Signals API
$ npm install signals-api
Get API Credential
- Create an API key in the account info panel. The API key has the same user groups as the owner.
- Download the API key.
Warning! It's your resposibility to protect the credential. A json with a complete credential will be pasted to your clipboard.
NodeJS has a easy way to load json.
moduleexports=/*your credential here*/ // load json with require
If you want to use the command line, save the credential to .signalsrc under your working folder.
Create API instance
Save the credential to a json file and import it into your NodeJS code.
// import signals apivar Signals = Signals;// load your credentialvar kAPPCredential = ;// if region is undefined, then it is defaulted to envar region = 'en'var api = ;// do something with the api ...
Replace 'en' with 'zh' if you are using china node
Install Signals Command Line Tool
Command line tool is no longer included in the signals-api, use signals-cli instead
$ npm install -g signals-cli
Job Configuration
Job configuration tells Signals how to process the data. The most important part is the params which define the data type of each column in the csv file. You have to assign an array of column names to each index.
"file_encoding": "utf-8" // encoding "params": // map your header fields //Text Analysis "text_index": ... text columns // multi value, put all your text fields in this array //Contributors "user_index": ... user id column // only support 1 user field now "user_image_index": ... user image src columns // 1 user image field, need to map "user_index" too // Geo Info, use related fields together, the more detailed fieilds you put in, the more accurate and efficient our engine will be "geo_index.unknown" : ... general address columns "geo_index.global": ... country name columns "geo_index.subglobal": ... state/provices name columns "geo_index.local": ... city columns "geo_index.sublocal": ... street columns "geo_index.postcode": ... postcode columns "geo_index.latitude": ... latitude columns "geo_index.longitude": ... longitude columns "geo_index.latitude_longitude": ... latitude_longitude columns ex: "lat,lon" "geo_index.longitude_latitude": ... longitude_latitude columns ex: "lon,lat" // Date info, the more detailed fieilds you put in, the more accurate and efficient our engine will be "date_index.unknown": ... general date columns "date_index.year": ... year columns "date_index.month": ... month columns "date_index.day": ... day of month columns "date_index.timestamp": ... epoch in milliseconds columns // use timestamp for Excel files // general information "user_timezone": -4 // time zone offset, user current timezone "user_emails": ...array of emails that will be notified after analysis finished /* looking at specific languages, optional if your documents are all in the same language "run_language_detection":false, "default_language": "zh", // will increse accuracy and speed of your analysis else "run_language_detection": true, "filter_language": [... optional, only analysis on these languages, ex : 'en','zh','ja' ], */ // customize engine "sentimentlists": ... array of your customized sentiment list "fid": 1234567 "version": 1 "stopdocslists": ... array of your customized junk and feedback list "fid": 1234567 "version": 1 "stopwordslists": ... array of your customized stop words list "fid": 1234567 "version": 1 "tokenslists": ... array of your customized chinese tokens list "fid": 1234567 "version": 1 "taxonomies": ... // tag your documents with selected taxonomy "label": ... Optional leave empty array thi is an array of the labels in the taxonomy hierarcy if you only want to tag a subtree of your taxonomy input the path to your desired label "model" : "fid": 123456789 "version": 1 "meta": "name": "API test small_lulu.csv 2016-6-24" // analysis name "source": "csv" // data format csv or xlsx "description": "Descrption of your analysis" // string
Examples
List finished jobs
// import signals apivar Signals = ;// load your credentialvar kAPPCredential = ;var api = kAPPCredential'en';// list all finished jobsapi;
List running jobs
// import signals apivar Signals = ;// load your credentialvar kAPPCredential = ;var api = kAPPCredential'en';// list all finished jobsapi;
Get a specific job
You need a job id to locate a specific job.
Job ids can be found in the response of creating a new job or the previous job status calls.
// import signals apivar Signals = ;// load your credentialvar kAPPCredential = ;var api = kAPPCredential'en';signals;
Command Line
$ signals -job <job id>
Create a new job
You need a CSV data and a job configuration to create a job.
The job configuration tells Signals how to process the data in the csv and provides initial meta data for the job.
Check out more detailed job configuration/parameters that you can use in the "Job Configuration" section.
// import signals apivar Signals = ;// load your credentialvar kAPPCredential = ;var api = kAPPCredential'en';// create a new jobvar job = api;job;// upload datavar fs = ;job;
Command Line
$ signals submit -config <job configuration in json> -data <csv file>
Delete a job
// import signals apivar Signals = ;// load your credentialvar kAPPCredential = ;var api = kAPPCredential'en';var jobId = '' /*job id*/;api;
Command Line
$ signals delete -job <job id>
Create a group
// import signals apivar Signals = ;// load your credentialvar kAPPCredential = ;var api = kAPPCredential'en';api;
Delete a group
// import signals apivar Signals = ;// load your credentialvar kAPPCredential = ;var api = kAPPCredential'en';var groupId = /* your group id */api;
Update a group
// import signals apivar Signals = ;// load your credentialvar kAPPCredential = ;var api = kAPPCredential'en';var groupId = /* your group id */api;
Get a group detail
// import signals apivar Signals = ;// load your credentialvar kAPPCredential = ;var api = kAPPCredential'en';var groupId = /* your group id */api;
Change access level for a user in the group
// import signals apivar Signals = ;// load your credentialvar kAPPCredential = ;var api = kAPPCredential'en';var groupId = /* your group id */ userId = /*Your user id*/ acessLevel = /*1~4*/api;
Share relational object with a user/group
// import signals apivar Signals = ;// load your credentialvar kAPPCredential = ;var api = kAPPCredential'en';var fid = /* object fid */ type = /* relational object type dashboards,jobs,streams... */var groupId = /* your group/user id */ acessLevel = /*1~4*/api;