Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


All Contributors

DeepDetect JS client


  • src/index.js - client source code

  • src/index.test.js - client methods tests

  • doc/web-example/server.js - simple webserver to serve web-example index.html and proxy api calls to a deepdetect server

  • doc/web-example/index.html - deepdetect-js web integration demo


Web integration

DeepDetect-JS can be used on a webpage, you probably should run deepdetect server behind a http-proxy to avoid same-origin policy issues.

A simple webserver demo is available on http://localhost:3000 when running the following command:

yarn run web-example

Here is the simple /info api call on a DeepDetect server. Note the {path: 'api'} parameter when initializing DD object.

<script src=""></script>
  async function fetchInfo() {
    const dd = new deepdetect.DD({path: 'api'});
    const info = await;
    document.getElementById('infoResult').innerHTML = JSON.stringify(info);


NodeJS integration

Following usage examples will use nodejs, install it with this command:

npm install --save deepdetect-js

Connect to DeepDetect server, and fetch informations

Here is the simplest way to get information about a DeepDetect server:

import DD from 'deepdetect-js';

async () => {

  const dd = new DD()

  // Get DeepDetect server info
  const info = await


You can also specified the DeepDetect server host and port options:

import DD from 'deepdetect-js';

async () => {

  const dd = new DD('', 8580)

  // Get DeepDetect server info
  const info = await


Service API

Once connected to a DeepDetect server, the Service API allows to:

  • create a service
  • fetch informations about a service
  • delete a service
import DD from 'deepdetect-js';

async () => {

  const dd = new DD()

  // Create a service
  const serviceName = 'myserv';

  const serviceConfig = {
    description: 'example classification service',
    model: {
      repository: '/home/me/models/example',
      templates: '../templates/caffe'
    mllib: 'caffe',
    parameters: {
      input: { connector: 'txt' },
      mllib: { nclasses: 20 },
      output: {},

  const createService = await dd.putService(serviceName, serviceConfig)

  // Fetch service information
  const service = await dd.getService(serviceName);

  // Delete service
  const deleteService = await dd.deleteService(serviceName, {clear: 'full'});

Train API

Once connected to a DeepDetect server, the Train API allows to:

  • Create a training job
  • Get information on a non-blocking training job
  • Kills a non-blocking training job
import DD from 'deepdetect-js';

async () => {

  const dd = new DD()
  const serviceName = 'myserv';

  // Create a training job
  const train = await dd.postTrain(
    [ '/home/me/deepdetect/examples/all/n20/news20' ],
      test_split: 0.2,
      shuffle: true,
      min_count: 10,
      min_word_length: 3,
      count: false,
      gpu: false,
      solver: {
        iterations: iterationsN20,
        test_interval: 200,
        base_lr: 0.05,
        snapshot: 2000,
        test_initialization: true,
      net: {
        batch_size: 100,
    { measure: ['acc', 'mcll', 'f1'] },

  // Get information on a non-blocking training job
  const trainingJob = await dd.getTrain(serviceName);

  // Kills a non-blocking training job
  const deletedTrainingJob = await dd.deleteTrain(serviceName);


Predict API

Once connected to a DeepDetect server, the Predict API allows to makes prediction from data and model

import DD from 'deepdetect-js';

async () => {

  const dd = new DD()
  const serviceName = 'myserv';

  // Predict with measures
  const postData = {
    service: serviceName,
    data: [ '/home/me/deepdetect/examples/all/n20/news20' ],
    parameters: {
      input: {},
      mllib: {
        gpu: false,
        net: {
          test_batch_size: 10,
      output: {
        measure: ['f1']

  const predict = await dd.postPredict(postData)


Build and release

  1. Modify version number in package.json
  2. npm run build
  3. npm publish - documentation


In order to run the test, you first need to run a deepdetect server loccaly on port 8080. To do so, you can use the following docker command:

docker run -d -p 8080:8080

Then you can run the test suite:

yarn test

If you find and issue with your tests, please check the header parameters available in src/index.test.js.


  • 1.8.9 - 19/10/2023 - Review dependabot alerts
  • 1.8.9 - 17/10/2023 - Update dependencies
  • 1.8.8 - 19/10/2021 - Add option to enable/disable Accept-Encoding gzip request header
  • 1.8.7 - 05/01/2020 - Replace NaN values in returned json from deepdetect server
  • 1.8.4 - 16/10/2020 - Fix conditional check of options.sameOrigin by eh-dub


Thanks goes to these people (emoji key):

Alexandre Girard


Ariel Weingarten


This project follows the all-contributors specification. Contributions of any kind welcome!


MIT © Jolibrain