Your first API service

This page will guide you through the process of your creating your first API service in a DSS design node, testing it, making a package out of it, and deploying on the DSS API node.

For this example, we’ll use a prediction endpoint, used to expose as a REST API service a model developed using the DSS visual machine learning component.

The steps to expose a prediction model are:

  • Train the model in Analysis
  • Deploy the model to Flow
  • Create a new API service
  • Create a prediction endpoint using the saved model
  • Create a package of your service
  • Deploy and activate the package on the API node

This section assumes that you already have installed and started a DSS API node instance. Please see Installing the API node if that’s not yet the case.

Creating the model

The first step is to create a model and deploy it to the Flow. This is done using the regular Machine Learning component of DSS. Please refer to the “Machine Learning” tutorial of DSS and to Machine learning for more information.

Create the service and endpoint in DSS

An API service is created within a project in DSS. From the project Homepage, click on “API SERVICES” in the navigation bar.

  • Click on New API Service
  • You need to give an identifier to your service. This “service id” will be referenced in APP interaction with the API node, and will be part of the URL to which your clients connect.
  • Click on your newly-created service

Our service is created but does not yet have any endpoint, ie. it does not yet expose any model. See Concepts for what endpoints are.

  • Click on the “Create new endpoint” button

We are going to create a “Prediction model” endpoint. You need to select the model that this endpoint will use. This is a saved model (ie. a model which has been deployed to the Flow). You also need to give an identifier to your endpoint. The endpoint id will be part of the URL to which your clients connect.

If your model is java-compatible (See: Machine learning training engines), you may select “Java scoring.” This will make the deployed model use java to score new records, resulting in extremely improved performance and throughput for your endpoint.

For a simple service, that’s it! You don’t need any further configuration.

Create and transfer the package

Now that your service is properly configured in DSS, the next step is to create a package (See Concepts).

  • Click on the “Prepare package” button
  • DSS asks you for a package version number. This version number will be the identifier of this generation for all interaction with API node. It is recommended that you use a meaningful short name like v4-new-customer-features. You want to be able to remember what was new in that generation (think of it as a Git tag)
  • Go to the packages tab.
  • Click on the Download button

The package file (a .zip file) is downloaded to your computer. Upload the zip file to all hosts running the API node software.

Create the service in API node

We are now going to actually activate the package in the API node

  • Go to the API node directory
  • Create the service: run the following command
./bin/apinode-admin service-create <SERVICE_ID>
  • Then, we need to import the package zip file:
./bin/apinode-admin service-import-generation <SERVICE_ID> <PATH TO ZIP FILE>

Now, the API node has unzipped the package in its own folders, and is ready to start using it. At that point, however, the new generation is only available, it’s not active. In other words, if we were to perform an API query, it would fail because no generation is currently active.

./bin/apinode-admin service-switch-to-newest <SERVICE_ID>

When this command returns, the API node service is now active, running on the latest (currently the only) generation of the package.

Perform a test query

We can now actually perform a prediction. Query the following URL (using your browser for example):


where feat1 and feat2 are the names of features (a.k.a. columns) in your train set.

You should receive a JSON reply with a result section containing your prediction (and probabilities in case of a classification model)

Perform real queries

Once you have confirmed that your service endpoint works, you can actually use the API to integrate in your application.

See API node user API

Next steps

Head over to the documentation page for each endpoint to get more information about how to use each one of them.