dify-spring-boot-starter
  • Guide
  • Getting-started
  • Install
  • Configure
  • Client Builder
  • Features

    • Chat API
    • Workflow API
    • Dataset API
    • Server API
  • Using configurations
  • Customized Configuration
  • v0.x
  • Changelog
  • 简体中文
  • English
GitHub
  • Guide
  • Getting-started
  • Install
  • Configure
  • Client Builder
  • Features

    • Chat API
    • Workflow API
    • Dataset API
    • Server API
  • Using configurations
  • Customized Configuration
  • v0.x
  • Changelog
  • 简体中文
  • English
GitHub
  • Guide

    • Guide
    • Getting-started
    • Install
    • Configure
    • Client Builder
  • Features

    • Chat API
    • Workflow API
    • Dataset API
    • Server API

Server API

Interface Overview

The Server API provides comprehensive functionality for interacting with the Dify platform, including managing applications, retrieving and initializing API keys for both applications and datasets. All interfaces require a valid API key for authentication. Use the DifyServer interface instance.

By default, if the current environment contains redis, then use redis to persist the token, if not, then use the default implementation to save the token (it will be lost if the service is restarted).

1. Application Management

1.1 Get All Applications

Method

List<AppsResponseVO> apps(String mode, String name);

Request Parameters

Parameter nameTypeRequiredDescription
modeStringNomode chat\agent-chat\completion\advanced-chat\workflow
nameStringNoApplication name, used to filter the application list (optional)

Response Parameters

AppsResponseVO

Parameter nameTypeDescription
idStringApplication ID
nameStringApplication name
maxActiveRequestsIntegerMaximum active requests
descriptionStringApplication description
modeStringApplication mode
iconTypeStringIcon type
iconStringIcon
iconBackgroundStringIcon background
iconUrlStringIcon URL
modelConfigModelConfigModel configuration
workflowObjectWorkflow information
useIconAsAnswerIconBooleanWhether to use icon as answer icon
createdByStringCreator ID
createdAtLongCreation time (timestamp)
updatedByStringUpdater ID
updatedAtLongUpdate time (timestamp)
tagsList<String>Application tags

ModelConfig

Parameter nameTypeDescription
modelModelModel information
prePromptStringPre-prompt text
createdByStringCreator ID
createdAtLongCreation time (timestamp)
updatedByStringUpdater ID
updatedAtLongUpdate time (timestamp)

Model

Parameter nameTypeDescription
providerStringModel provider
nameStringModel name
modeStringModel mode
completionParamsCompletionParamsCompletion parameters

CompletionParams

Parameter nameTypeDescription
stopList<String>Stop sequences

Request Example


@Resource
private DifyServer difyServer;

@Test
public void testGetApps() {
    // Get all applications
    List<AppsResponseVO> apps = difyServer.apps("");

    // Get applications with name filter
    List<AppsResponseVO> filteredApps = difyServer.apps("myApp");
}

1.2 Get Application by ID

Method

AppsResponseVO app(String appId);

Request Parameters

Parameter nameTypeRequiredDescription
appIdStringYesApplication ID

Response Parameters

Same as the AppsResponseVO structure defined above.

Request Example


@Resource
private DifyServer difyServer;

@Test
public void testGetApp() {
    AppsResponseVO app = difyServer.app("app-123456789");
}

1.3 Get Application API Keys

Method

List<ApiKeyResponseVO> getAppApiKey(String id);

Request Parameters

Parameter nameTypeRequiredDescription
idStringYesApplication ID

Response Parameters

ApiKeyResponseVO

Parameter nameTypeDescription
idStringAPI Key ID
tokenStringAPI Key token value

Request Example


@Resource
private DifyServer difyServer;

@Test
public void testGetAppApiKeys() {
    List<ApiKeyResponseVO> apiKeys = difyServer.getAppApiKey("app-123456789");
}

1.4 Initialize Application API Key

Method

List<ApiKeyResponseVO> initAppApiKey(String id);

Request Parameters

Parameter nameTypeRequiredDescription
idStringYesApplication ID

Response Parameters

Same as the ApiKeyResponseVO structure defined above.

Request Example


@Resource
private DifyServer difyServer;

@Test
public void testInitAppApiKey() {
    List<ApiKeyResponseVO> apiKeys = difyServer.initAppApiKey("app-123456789");
}

2. Knowledge Base Management

2.1 Get Knowledge Base API Keys

Method

List<DatasetApiKeyResponseVO> getDatasetApiKey();

Response Parameters

DatasetApiKeyResponseVO

Parameter nameTypeDescription
idStringAPI Key ID
typeStringAPI Key type
tokenStringAPI Key token value
lastUsedAtLongLast used time (timestamp)
createdAtLongCreation time (timestamp)

Request Example


@Resource
private DifyServer difyServer;

@Test
public void testGetDatasetApiKeys() {
    List<DatasetApiKeyResponseVO> datasetApiKeys = difyServer.getDatasetApiKey();
}

2.2 Initialize Knowledge Base API Key

Method

List<DatasetApiKeyResponseVO> initDatasetApiKey();

Response Parameters

Same as the DatasetApiKeyResponseVO structure defined above.

Request Example


@Resource
private DifyServer difyServer;

@Test
public void testInitDatasetApiKey() {
    List<DatasetApiKeyResponseVO> datasetApiKeys = difyServer.initDatasetApiKey();
}
Edit this page on GitHub
Last Updated: 4/14/25, 3:22 AM
Prev
Dataset API