JavaScript SDK for the Slamby API Service
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
src
README.md
git_push.sh
package.json

README.md

slamby-sdk

SlambySdk - JavaScript client for slamby-sdk

Slamby API

This SDK is automatically generated by the Swagger Codegen project:

  • API version: 1.5.0
  • Package version: 1.5.1
  • Build date: 2017-02-07T12:59:23.910+01:00
  • Build package: class io.swagger.codegen.languages.JavascriptClientCodegen

Installation

For Node.js

npm

To publish the library as a npm, please follow the procedure in "Publishing npm packages".

Then install it via:

npm install slamby-sdk --save

git

If the library is hosted at a git repository, e.g. https://github.com/YOUR_USERNAME/slamby-sdk-javascript then install it via:

npm install YOUR_USERNAME/slamby-sdk-javascript --save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Getting Started

INFO: We use Promises as return values from the client API, instead of superagent callbacks

Please follow the installation instruction and execute the following JS code:

// Sample error handler
function handleError(e) {
    if (e.errno) {
        console.error(`${e.message}`);
    } else if (e.status) {
        console.error(`${e.status} ${e.message} - ${e.response.res.text}`);
    } else {
        console.error('Unknown error!');
    }
}

var SlambySdk = require('slamby-sdk');
// OR if you use from local
var SlambySdk = require('./path/to/src/index.js');

var client = new SlambySdk.ApiClient(); 
client.basePath = "http://<api_host>/";
client.defaultHeaders = {
    "Authorization": "Slamby <api_secret>"
};

Getting DataSet list

var dataSetManager = new SlambySdk.DataSetApi(client);
dataSetManager.getDataSets()
    .then(function(dataSets){
      // ...
    })
    .catch(handleError);

Selecting a DataSet for work

client.defaultHeaders["X-DataSet"] = "<my_dataset>"; 

Get Tag list

var tagManager = new SlambySdk.TagApi(client);
tagManager.getTags({withDetails : false})
    .then(function(tags){
      // ...
    })
    .catch(handleError);

Creating a new Tag

var tag = new SlambySdk.Tag("1234", "New tag");
tagManager.createTag({tag : tag})
    .then(function(res){
    })
    .catch(handleError);

Get & update a Document

var documentManager = new SlambySdk.DocumentApi(client);
documentManager.getDocument("123456")
    .then(function(document){
        document.language = "hu";
        documentManager.updateDocument("123456", {document : document})
            .catch(handleError);
    })
    .catch(handleError);

Filter Documents

var pagination = new SlambySdk.Pagination();
pagination.Limit = 10;
pagination.Offset = 0;
pagination.OrderByField = 'id';
pagination.OrderDirection = 'Asc';
var filterSettings = new SlambySdk.DocumentFilterSettings();
filterSettings.Pagination = pagination;

documentManager.getFilteredDocuments({filterSettings: filterSettings})
    .then(function(documents){
        // ...
    })
    .catch(handleError);    

Documentation for API Endpoints

All URIs are relative to https://localhost/

Class Method HTTP request Description
SlambySdk.ClassifierServiceApi classifierActivateService POST /api/Services/Classifier/{id}/Activate
SlambySdk.ClassifierServiceApi classifierDeactivateService POST /api/Services/Classifier/{id}/Deactivate
SlambySdk.ClassifierServiceApi classifierExportDictionaries POST /api/Services/Classifier/{id}/ExportDictionaries
SlambySdk.ClassifierServiceApi classifierGetService GET /api/Services/Classifier/{id}
SlambySdk.ClassifierServiceApi classifierPrepareService POST /api/Services/Classifier/{id}/Prepare
SlambySdk.ClassifierServiceApi classifierRecommendService POST /api/Services/Classifier/{id}/Recommend
SlambySdk.DataSetApi createDataSet POST /api/DataSets
SlambySdk.DataSetApi createDataSetSchema POST /api/DataSets/Schema
SlambySdk.DataSetApi deleteDataSet DELETE /api/DataSets/{name}
SlambySdk.DataSetApi getDataSet GET /api/DataSets/{name}
SlambySdk.DataSetApi getDataSets GET /api/DataSets
SlambySdk.DataSetApi updateDataSet PUT /api/DataSets/{existingName}
SlambySdk.DocumentApi bulkDocuments POST /api/Documents/Bulk
SlambySdk.DocumentApi copyDocuments POST /api/Documents/Copy
SlambySdk.DocumentApi createDocument POST /api/Documents
SlambySdk.DocumentApi deleteDocument DELETE /api/Documents/{id}
SlambySdk.DocumentApi getDocument GET /api/Documents/{id}
SlambySdk.DocumentApi getFilteredDocuments POST /api/Documents/Filter/{scrollId}
SlambySdk.DocumentApi getSampleDocuments POST /api/Documents/Sample
SlambySdk.DocumentApi moveDocuments POST /api/Documents/Move
SlambySdk.DocumentApi updateDocument PUT /api/Documents/{id}
SlambySdk.HelperApi fileParser POST /api/Helper/FileParser
SlambySdk.LicenseApi changeLicense POST /api/License
SlambySdk.LicenseApi getLicense GET /api/License
SlambySdk.MaintenanceApi changeSecret POST /api/Maintenance/ChangeSecret
SlambySdk.PrcServiceApi prcActivateService POST /api/Services/Prc/{id}/Activate
SlambySdk.PrcServiceApi prcDeactivateService POST /api/Services/Prc/{id}/Deactivate
SlambySdk.PrcServiceApi prcExportDictionaries POST /api/Services/Prc/{id}/ExportDictionaries
SlambySdk.PrcServiceApi prcGetService GET /api/Services/Prc/{id}
SlambySdk.PrcServiceApi prcIndexPartialService POST /api/Services/Prc/{id}/IndexPartial
SlambySdk.PrcServiceApi prcIndexService POST /api/Services/Prc/{id}/Index
SlambySdk.PrcServiceApi prcKeywordsService POST /api/Services/Prc/{id}/Keywords
SlambySdk.PrcServiceApi prcPrepareService POST /api/Services/Prc/{id}/Prepare
SlambySdk.PrcServiceApi prcRecommendByIdService POST /api/Services/Prc/{id}/RecommendById
SlambySdk.PrcServiceApi prcRecommendService POST /api/Services/Prc/{id}/Recommend
SlambySdk.ProcessApi cancelProcess POST /api/Processes/{id}/Cancel
SlambySdk.ProcessApi getProcess GET /api/Processes/{id}
SlambySdk.ProcessApi getProcesses GET /api/Processes
SlambySdk.SearchServiceApi searchActivateService POST /api/Services/Search/{id}/Activate
SlambySdk.SearchServiceApi searchDeactivateService POST /api/Services/Search/{id}/Deactivate
SlambySdk.SearchServiceApi searchGetService GET /api/Services/Search/{id}
SlambySdk.SearchServiceApi searchPrepareService POST /api/Services/Search/{id}/Prepare
SlambySdk.SearchServiceApi searchService POST /api/Services/Search/{id}
SlambySdk.ServiceApi createService POST /api/Services
SlambySdk.ServiceApi deleteService DELETE /api/Services/{id}
SlambySdk.ServiceApi getService GET /api/Services/{id}
SlambySdk.ServiceApi getServices GET /api/Services
SlambySdk.ServiceApi updateService PUT /api/Services/{id}
SlambySdk.StatisticsApi getStatistics GET /api/Statistics
SlambySdk.StatisticsApi getStatistics_0 GET /api/Statistics/{year}
SlambySdk.StatisticsApi getStatistics_1 GET /api/Statistics/{year}/{month}
SlambySdk.StatusApi getStatus GET /api/Status
SlambySdk.TagApi bulkTags POST /api/Tags/Bulk
SlambySdk.TagApi cleanDocuments POST /api/Tags/CleanDocuments
SlambySdk.TagApi createTag POST /api/Tags
SlambySdk.TagApi deleteTag DELETE /api/Tags/{id}
SlambySdk.TagApi getTag GET /api/Tags/{id}
SlambySdk.TagApi getTags GET /api/Tags
SlambySdk.TagApi updateTag PUT /api/Tags/{id}
SlambySdk.TagApi wordsExport POST /api/Tags/ExportWords

Documentation for Models

Documentation for Authorization

All endpoints do not require authorization.