API Designer#

Please see API Designer for an introduction to interacting with datasets in Dataiku Python API

class dataikuapi.dss.apiservice.DSSAPIServiceListItem(client, data)#

An item in a list of API services.

Important

Do not instantiate directly, use dataikuapi.dss.project.DSSProject.list_api_services()

to_api_service()#

Get a handle corresponding to this API service.

Return type:

DSSAPIService

property name#

Get the name of the API service.

Return type:

string

property id#

Get the identifier of the API service.

Return type:

string

property auth_method#

Get the method used to authenticate on the API service.

Usage example:

# list all public API services
for service in project.list_api_services(as_type="list_item"):
    if service.auth_method == 'PUBLIC':
        print("Service {} isn't authenticating requests".format(service.id))
Returns:

an authentication method. Possible values: PUBLIC (no authentication), API_KEYS, OAUTH2

Return type:

string

property endpoints#

Get the endpoints in this API service.

Returns:

a list of endpoints, each one a dict with fields:

  • id : identifier of the endpoint

  • type : type of endpoint. Possible values: STD_PREDICTION, STD_CLUSTERING, STD_FORECAST, STD_CAUSAL_PREDICTION, CUSTOM_PREDICTION, CUSTOM_R_PREDICTION, R_FUNCTION, PY_FUNCTION, DATASETS_LOOKUP, SQL_QUERY

Return type:

list[dict]

class dataikuapi.dss.apiservice.DSSAPIServiceSettings(client, project_key, service_id, settings)#

The settings of an API Service in the API Designer.

Important

Do not instantiate directly, use DSSAPIService.get_settings().

get_raw()#

Get the raw settings of this API Service.

This returns a reference to the raw settings, not a copy, so changes made to the returned object will be reflected when saving.

Returns:

the settings of the API service, as a dict. The definitions of the endpoints are inside the endpoints field, itself a list of dict.

Return type:

dict

property auth_method#

Get the method used to authenticate on the API service

Returns:

an authentication method. Possible values: PUBLIC (no authentication), API_KEYS, OAUTH2

Return type:

string

property endpoints#

Get the list of endpoints of this API service

Returns:

ist of endpoints, each one a dict. Endpoint have different fields depending on their type, but always have at least:

  • id : identifier of the endpoint

  • type : type of endpoint. Possible values: STD_PREDICTION, STD_CLUSTERING, STD_FORECAST, STD_CAUSAL_PREDICTION, CUSTOM_PREDICTION, CUSTOM_R_PREDICTION, R_FUNCTION, PY_FUNCTION, DATASETS_LOOKUP, SQL_QUERY

Return type:

list[dict]

add_prediction_endpoint(endpoint_id, saved_model_id)#

Add a new “visual prediction” endpoint to this API service.

Parameters:
  • endpoint_id (string) – identifier of the new endpoint to create

  • saved_model_id (string) – identifier of the saved model (that is currently deployed to the Flow) to use

add_clustering_endpoint(endpoint_id, saved_model_id)#

Add a new “visual clustering” endpoint to this API service.

Parameters:
  • endpoint_id (string) – identifier of the new endpoint to create

  • saved_model_id (string) – identifier of the saved model (that is currently deployed to the Flow) to use

add_forecasting_endpoint(endpoint_id, saved_model_id)#

Add a new “visual time series forecasting” endpoint to this API service.

Parameters:
  • endpoint_id (string) – identifier of the new endpoint to create

  • saved_model_id (string) – identifier of the saved model (that is currently deployed to the Flow) to use

add_causal_prediction_endpoint(endpoint_id, saved_model_id, compute_propensity=False)#

Add a new “visual causal prediction” endpoint to this API service.

Parameters:
  • endpoint_id (string) – identifier of the new endpoint to create

  • saved_model_id (string) – identifier of the saved model (that is currently deployed to the Flow) to use

  • compute_propensity (bool) – whether propensity should be computed, if True, the model must have a trained propensity model

save()#

Save back these settings to the API Service.

class dataikuapi.dss.apiservice.DSSAPIService(client, project_key, service_id)#

An API Service from the API Designer on the DSS instance.

Important

Do not instantiate directly, use dataikuapi.dss.project.DSSProject.get_api_service()

property id#

Get the API service’s identifier

Return type:

string

get_settings()#

Get the settings of this API Service.

Usage example:

# list all API services using a given model
model_lookup = "my_saved_model_id"
model = project.get_saved_model(model_lookup)
model_name = model.get_settings().get_raw()["name"]
for service in project.list_api_services(as_type='object'):
    settings = service.get_settings()
    endpoints_on_model = [e for e in settings.endpoints if e.get("modelRef", '') == model_lookup]
    if len(endpoints_on_model) > 0:
        print("Service {} uses model {}".format(service.id, model_name))
Returns:

a handle on the settings

Return type:

DSSAPIServiceSettings

get_package_summary(package_id)#

Get summary of a package

Parameters:

package_id (str) – version (identifier) of the package to get the summary for

Return type:

dict

list_packages()#

List the versions of this API service.

Returns:

a list of packages, each one as a dict. Each dict has fields:

  • id : version (identifier) of the package

  • createdOn : timestamp in milliseconds of when the package was created

Return type:

list[dict]

create_package(package_id, release_notes=None)#

Create a new version of this API service.

Parameters:
  • package_id (string) – version (identifier) of the package to create

  • release_notes (str) – important changes introduced in the package

delete_package(package_id)#

Delete a version of this API service.

Parameters:

package_id (string) – version (identifier) of the package to delete

download_package_stream(package_id)#

Download an archive of a package as a stream.

The archive can then be deployed in a DSS API Node.

Warning

This call will monopolize the DSSClient until the stream it returns is closed.

Parameters:

package_id (string) – version (identifier) of the package to download

Returns:

the package archive, as a HTTP stream

Return type:

file-like

download_package_to_file(package_id, path)#

Download an archive of a package to a local file.

The archive can then be deployed in a DSS API Node.

Parameters:
  • package_id (string) – version (identifier) of the package to download

  • path (string) – absolute or relative path to a file in which the package is downloaded

publish_package(package_id, published_service_id=None)#

Publish a package on the API Deployer.

Parameters:
  • package_id (string) – version (identifier) of the package to publish

  • published_service_id (string) – identifier of the API service on the API Deployer in which the package will be published. A new published API service will be created if none matches the identifier. If the parameter is not set, the identifier from the current DSSAPIService is used.