### GET /microapp/app/info Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Retrieves basic information about an authorized mini-program. ```APIDOC ## GET /microapp/app/info ### Description Retrieve basic information about an authorized mini-program including app name, icon, and configuration details. ### Method GET ### Endpoint https://open.microapp.bytedance.com/openapi/v1/microapp/app/info ### Parameters #### Query Parameters - **access_token** (string) - Required - The access token for the mini-program. ### Response #### Success Response (200) - **app_name** (string) - Name of the mini-program. - **icon** (string) - URL of the mini-program icon. ``` -------------------------------- ### Get Mini-Program Basic Info (Java) Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Retrieves basic information for an authorized mini-program, including its name, icon, and configuration details. This requires obtaining the mini-program service instance first, using the mini-program's AppID. ```Java import com.github.yydzxz.open.api.v1.IByteDanceOpenV1MiniProgramService; import com.github.yydzxz.open.api.v1.IByteDanceOpenV1MiniProgramInfoService; import com.github.yydzxz.open.api.v1.response.appinfo.AppInfoResponse; // Get mini-program service for a specific authorized app String appId = "authorized_mini_program_appid"; IByteDanceOpenV1MiniProgramService miniProgramService = byteDanceOpenService.getByteDanceOpenV1ComponentService().getByteDanceOpenV1MiniProgramServiceByAppid(appId); IByteDanceOpenV1MiniProgramInfoService infoService = miniProgramService.getByteDanceOpenV1MiniProgramInfoService(); // Get mini-program basic information AppInfoResponse appInfo = infoService.getAppInfo(); System.out.println("App Info: " + appInfo); // API endpoint: https://open.microapp.bytedance.com/openapi/v1/microapp/app/info ``` -------------------------------- ### GET /tp/auth_app_list Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Queries the list of all mini-programs that have authorized your third-party platform. ```APIDOC ## GET /tp/auth_app_list ### Description Query the list of all mini-programs that have authorized your third-party platform with pagination support. ### Method GET ### Endpoint https://open.microapp.bytedance.com/openapi/v1/tp/auth_app_list ### Parameters #### Query Parameters - **page** (integer) - Required - Page number starting from 1. - **size** (integer) - Required - Number of items per page (max 50). ### Response #### Success Response (200) - **data** (array) - List of authorized mini-program objects. ``` -------------------------------- ### Upload Material for Mini-Program Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Handles the upload of images and materials necessary for modifying mini-programs, such as changing the name, icon, or category certification. It specifies the supported file types and provides an example of uploading a material and using the returned URL. The API endpoint is also included. ```java import com.github.yydzxz.open.api.v1.IByteDanceOpenV1MaterialService; import com.github.yydzxz.open.api.v1.request.material.UploadMaterialRequest; import com.github.yydzxz.open.api.v1.response.material.UploadMaterialResponse; import java.io.File; IByteDanceOpenV1MaterialService materialService = byteDanceOpenService.getByteDanceOpenV1ComponentService().getByteDanceOpenMaterialService(); // Upload material (supports bmp, jpeg, jpg, png) UploadMaterialRequest materialRequest = new UploadMaterialRequest(); materialRequest.setMaterialType(1); // Material type materialRequest.setMaterialFile(new File("/path/to/material.png")); UploadMaterialResponse materialResponse = materialService.uploadMaterial(materialRequest); System.out.println("Material URL: " + materialResponse.getMaterialPath()); // Use the returned URL for name/icon modification requests // API endpoint: https://open.microapp.bytedance.com/openapi/v1/microapp/upload_material ``` -------------------------------- ### Configure Custom HTTP Client and JSON Serializer (Java) Source: https://context7.com/yydzxz/bytedanceopen/llms.txt This example shows how to configure custom HTTP clients (OkHttp, JoddHttp, RestTemplate) and JSON serializers (Gson, Jackson) for the ByteDance Open Platform SDK. It demonstrates creating a custom `OkHttpClient` with specific timeouts and integrating it with the SDK. The code also mentions how the JSON serializer is auto-detected or can be manually set. ```java import com.github.yydzxz.common.http.impl.OkHttpClientByteDanceHttpClient; import com.github.yydzxz.common.http.impl.JoddHttpByteDanceHttpClient; import com.github.yydzxz.common.http.impl.RestTemplateByteDanceHttpClient; import com.github.yydzxz.common.util.json.GsonSerializer; import com.github.yydzxz.common.util.json.JacksonSerializer; import okhttp3.OkHttpClient; import java.util.concurrent.TimeUnit; // Option 1: Custom OkHttpClient with timeouts OkHttpClient customOkHttpClient = new OkHttpClient.Builder() .connectTimeout(30, TimeUnit.SECONDS) .readTimeout(30, TimeUnit.SECONDS) .writeTimeout(30, TimeUnit.SECONDS) .build(); OkHttpClientByteDanceHttpClient httpClient = new OkHttpClientByteDanceHttpClient( customOkHttpClient, new GsonSerializer() // or new JacksonSerializer() ); // Option 2: JoddHttp client // JoddHttpByteDanceHttpClient joddClient = new JoddHttpByteDanceHttpClient(); // Option 3: RestTemplate client (for Spring integration) // RestTemplateByteDanceHttpClient restClient = new RestTemplateByteDanceHttpClient(restTemplate); // Set custom HTTP client byteDanceOpenService.setByteDanceHttpClient(httpClient); // JSON serializer is auto-detected in priority: Gson > FastJson > Jackson // Or manually set via ByteDanceJsonBuilder.setJsonSerializer(new JacksonSerializer()); ``` -------------------------------- ### GET /oauth/pre_auth Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Generates the authorization URL to redirect mini-program administrators to authorize your third-party platform. ```APIDOC ## GET /oauth/pre_auth ### Description Generates the authorization URL to redirect mini-program administrators to authorize your third-party platform to manage their mini-programs. ### Method GET ### Endpoint https://open.microapp.bytedance.com/mappconsole/tp/authorization ### Parameters #### Query Parameters - **component_appid** (string) - Required - The ID of the third-party platform. - **pre_auth_code** (string) - Required - The pre-authorization code. - **redirect_uri** (string) - Required - The URL to redirect to after authorization. ### Request Example N/A (Redirect URL generation) ### Response #### Success Response (302) - **Redirect** (string) - Redirects the user to the ByteDance authorization page. ``` -------------------------------- ### Generate Mini-Program QR Code (Java) Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Generates a QR code image that users can scan to access a specific mini-program. This functionality is useful for distributing the mini-program and guiding users to it. The code requires specifying the desired page path within the mini-program and outputs a byte array representing the QR code image, which can then be saved to a file. ```Java import com.github.yydzxz.open.api.v1.IByteDanceOpenV1MiniProgramInfoService; import com.github.yydzxz.open.api.v1.request.appinfo.AppQrCodeRequest; import java.io.FileOutputStream; IByteDanceOpenV1MiniProgramInfoService infoService = miniProgramService.getByteDanceOpenV1MiniProgramInfoService(); // Generate QR code for mini-program AppQrCodeRequest qrRequest = new AppQrCodeRequest(); qrRequest.setPath("pages/index/index"); // Mini-program page path byte[] qrCodeImage = infoService.getAppQrCode(qrRequest); // Save QR code image to file try (FileOutputStream fos = new FileOutputStream("miniprogram_qrcode.png")) { fos.write(qrCodeImage); System.out.println("QR Code saved successfully"); } // API endpoint: https://open.microapp.bytedance.com/openapi/v1/microapp/app/qrcode ``` -------------------------------- ### Error Handling and Automatic Retry with ByteDance SDK (Java) Source: https://context7.com/yydzxz/bytedanceopen/llms.txt This code illustrates the SDK's built-in error handling and automatic retry mechanism. It shows how to make an API call within a try-catch block to handle potential `ByteDanceErrorException`. The example demonstrates checking for success, printing error details, and specifically handling token expiration errors (40009/40010), which trigger automatic retries and token refreshes by the SDK. Default retry configurations are also mentioned. ```java import com.github.yydzxz.common.error.ByteDanceError; import com.github.yydzxz.common.error.ByteDanceErrorException; import com.github.yydzxz.common.error.ByteDanceErrorMsgEnum; try { // Make any API call - retry is automatic AppInfoResponse response = infoService.getAppInfo(); // Check if response indicates success if (!response.checkSuccess()) { System.out.println("Error code: " + response.getErrno()); System.out.println("Error message: " + response.getMessage()); } } catch (ByteDanceErrorException e) { ByteDanceError error = (ByteDanceError) e.getError(); // Common error codes: // 40009 - Component access token expired // 40010 - Component access token incorrect // 40000 - General system error (triggers retry) System.out.println("Error Code: " + error.errorCode()); System.out.println("Error Message: " + error.errorMessage()); if (error.errorCode() == ByteDanceErrorMsgEnum.CODE_40009.getCode()) { // Token expired - SDK handles this automatically by refreshing System.out.println("Token was expired, request will be retried"); } } // Retry configuration in component service: // Default retry sleep: 1000ms // Default max retries: 5 // Automatic token refresh on 40009/40010 errors ``` -------------------------------- ### Release and Rollback Code Package Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Manages the release of approved code packages to production or rolls back to a previous version. It includes functionalities to get version lists, perform releases, rollbacks, and revoke audit submissions. API endpoints for release and rollback are specified. ```java import com.github.yydzxz.open.api.v1.IByteDanceOpenV1MiniProgramCodeService; import com.github.yydzxz.open.api.v1.response.code.*; IByteDanceOpenV1MiniProgramCodeService codeService = miniProgramService.getByteDanceOpenV1MiniProgramCodeService(); // Get version list CodeVersionsResponse versionsResponse = codeService.versions(); System.out.println("Available versions: " + versionsResponse.getData()); // Release approved code to production CodeReleaseResponse releaseResponse = codeService.release(); System.out.println("Release result: " + releaseResponse.checkSuccess()); // Rollback to previous version if needed CodeRollbackResponse rollbackResponse = codeService.rollback(); System.out.println("Rollback result: " + rollbackResponse.checkSuccess()); // Revoke audit submission CodeRevokeAuditResponse revokeResponse = codeService.revokeAudit(); System.out.println("Revoke audit result: " + revokeResponse.checkSuccess()); // API endpoints: // Release: https://open.microapp.bytedance.com/openapi/v1/microapp/package/release // Rollback: https://open.microapp.bytedance.com/openapi/v1/microapp/package/rollback ``` -------------------------------- ### Apply for Mini-Program Capabilities with Java SDK Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Shows how to check the status of and apply for special mini-program capabilities such as video mounting, live streaming, and phone number retrieval. It utilizes the IByteDanceOpenV1MiniProgramOperationService to manage these application requests. ```java import com.github.yydzxz.open.api.v1.IByteDanceOpenV1MiniProgramOperationService; import com.github.yydzxz.open.api.v1.request.operation.*; import com.github.yydzxz.open.api.v1.response.operation.*; IByteDanceOpenV1MiniProgramOperationService operationService = miniProgramService.getByteDanceOpenV1MiniProgramOperationService(); OperationVideoApplicationStatusResponse videoStatus = operationService.videoApplicationStatus(); OperationVideoApplicationRequest videoRequest = new OperationVideoApplicationRequest(); OperationVideoApplicationResponse videoResponse = operationService.videoApplication(videoRequest); OperationLiveApplicationStatusResponse liveStatus = operationService.liveApplicationStatus(); OperationLiveApplicationRequest liveRequest = new OperationLiveApplicationRequest(); OperationLiveApplicationResponse liveResponse = operationService.liveApplication(liveRequest); OperationPhoneNumberApplicationStatusResponse phoneStatus = operationService.phoneNumberApplicationStatus(); ``` -------------------------------- ### V2 API Pre-Authorization with Additional Options (Java) Source: https://context7.com/yydzxz/bytedanceopen/llms.txt This snippet demonstrates how to use the V2 API of the ByteDance Open Platform SDK for pre-authorization, including advanced options like permission scope selection. It shows how to obtain a `IByteDanceOpenV2ComponentService`, create a `GetPreAuthCodeRequest`, set additional V2-specific options, and generate the pre-authorization URL. The relevant V2 API endpoint is also provided. ```java import com.github.yydzxz.open.api.v2.IByteDanceOpenV2ComponentService; import com.github.yydzxz.open.api.v2.request.auth.GetPreAuthCodeRequest; IByteDanceOpenV2ComponentService v2ComponentService = byteDanceOpenService.getByteDanceOpenV2ComponentService(); // V2 pre-auth with additional options GetPreAuthCodeRequest preAuthRequest = new GetPreAuthCodeRequest(); // Set authorization scope and other V2-specific options... String redirectUri = "https://your-domain.com/callback"; String preAuthUrl = v2ComponentService.getPreAuthUrl(redirectUri, preAuthRequest); System.out.println("V2 Pre-Auth URL: " + preAuthUrl); // API endpoint: https://open.microapp.bytedance.com/openapi/v2/auth/pre_auth_code ``` -------------------------------- ### Manage Mini-Program Orders with Java SDK Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Demonstrates how to create, update, and delete order records using the IByteDanceOpenV1MiniProgramPayService. These operations require valid order IDs and open IDs to interact with the ByteDance payment API endpoints. ```java import com.github.yydzxz.open.api.v1.IByteDanceOpenV1MiniProgramPayService; import com.github.yydzxz.open.api.v1.request.pay.*; import com.github.yydzxz.open.api.v1.response.pay.*; IByteDanceOpenV1MiniProgramPayService payService = miniProgramService.getByteDanceOpenV1MiniProgramPayService(); OrderPayAddRequest addRequest = new OrderPayAddRequest(); addRequest.setOrderId("ORDER_20231001_001"); addRequest.setOpenId("user_open_id"); addRequest.setOrderStatus(1); OrderPayAddResponse addResponse = payService.orderAdd(addRequest); OrderPayUpdateRequest updateRequest = new OrderPayUpdateRequest(); updateRequest.setOrderId("ORDER_20231001_001"); updateRequest.setOpenId("user_open_id"); updateRequest.setOrderStatus(2); OrderPayUpdateResponse updateResponse = payService.orderUpdate(updateRequest); OrderPayDeleteRequest deleteRequest = new OrderPayDeleteRequest(); deleteRequest.setOrderId("ORDER_20231001_001"); deleteRequest.setOpenId("user_open_id"); OrderPayDeleteResponse deleteResponse = payService.orderDelete(deleteRequest); ``` -------------------------------- ### Initialize ByteDance Open SDK with Redis Configuration Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Configures the SDK using a Redisson-backed Redis storage for distributed state management. It sets up the HTTP client, credentials, and initializes both v1 and v2 component services. ```java import com.github.yydzxz.open.api.IByteDanceOpenService; import com.github.yydzxz.open.api.impl.ByteDanceOpenServiceImpl; import com.github.yydzxz.open.api.impl.ByteDanceOpenInRedisConfigStorage; import com.github.yydzxz.open.api.v1.impl.ByteDanceOpenV1ComponentServiceImpl; import com.github.yydzxz.open.api.v2.impl.ByteDanceOpenV2ComponentServiceImpl; import com.github.yydzxz.common.redis.RedissonByteDanceRedisOps; import com.github.yydzxz.common.http.impl.OkHttpClientByteDanceHttpClient; import org.redisson.api.RedissonClient; import org.redisson.Redisson; import org.redisson.config.Config; Config redissonConfig = new Config(); redissonConfig.useSingleServer().setAddress("redis://localhost:6379"); RedissonClient redissonClient = Redisson.create(redissonConfig); RedissonByteDanceRedisOps redisOps = new RedissonByteDanceRedisOps(redissonClient); ByteDanceOpenInRedisConfigStorage configStorage = new ByteDanceOpenInRedisConfigStorage(redisOps, "bytedance:"); configStorage.setByteDanceOpenInfo("your_component_app_id", "your_component_app_secret", "your_component_token", "your_component_aes_key"); IByteDanceOpenService byteDanceOpenService = new ByteDanceOpenServiceImpl(); byteDanceOpenService.setByteDanceOpenConfigStorage(configStorage); byteDanceOpenService.setByteDanceHttpClient(new OkHttpClientByteDanceHttpClient()); byteDanceOpenService.setByteDanceRedisOps(redisOps); byteDanceOpenService.setByteDanceOpenV1ComponentService(new ByteDanceOpenV1ComponentServiceImpl(byteDanceOpenService)); byteDanceOpenService.setByteDanceOpenV2ComponentService(new ByteDanceOpenV2ComponentServiceImpl(byteDanceOpenService)); ``` -------------------------------- ### Query Mini-Program Quality Rating and Credit Score (Java) Source: https://context7.com/yydzxz/bytedanceopen/llms.txt This snippet demonstrates how to query your mini-program's quality rating and credit score using the ByteDance Open Platform SDK. It utilizes the `IByteDanceOpenV1MiniProgramInfoService` to fetch these details. The code prints the retrieved quality rating and credit score to the console. It also provides the relevant API endpoints for reference. ```java import com.github.yydzxz.open.api.v1.IByteDanceOpenV1MiniProgramInfoService; import com.github.yydzxz.open.api.v1.response.appinfo.AppQualityRatingResponse; import com.github.yydzxz.open.api.v1.response.appinfo.AppCreditScoreResponse; IByteDanceOpenV1MiniProgramInfoService infoService = miniProgramService.getByteDanceOpenV1MiniProgramInfoService(); // Query quality rating AppQualityRatingResponse qualityRating = infoService.qualityRating(); System.out.println("Quality Rating: " + qualityRating); // Query credit score AppCreditScoreResponse creditScore = infoService.creditScore(); System.out.println("Credit Score: " + creditScore); // API endpoints: // Quality: https://open.microapp.bytedance.com/openapi/v1/microapp/app/quality_rating // Credit: https://open.microapp.bytedance.com/openapi/v1/microapp/app/credit_score ``` -------------------------------- ### Modify Mini-Program Information (Java) Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Allows updating the basic information of a mini-program, including its name, introduction, icon, and server domain settings. This involves checking app name availability, modifying the app name, updating the introduction text, and managing server domain configurations (adding, deleting, or setting). ```Java import com.github.yydzxz.open.api.v1.IByteDanceOpenV1MiniProgramInfoService; import com.github.yydzxz.open.api.v1.request.appinfo.*; import com.github.yydzxz.open.api.v1.response.appinfo.*; import java.util.Arrays; IByteDanceOpenV1MiniProgramInfoService infoService = miniProgramService.getByteDanceOpenV1MiniProgramInfoService(); // Check if app name is available AppCheckAppNameResponse nameCheckResponse = infoService.checkAppName("New App Name"); System.out.println("Name available: " + nameCheckResponse.checkSuccess()); // Modify app name AppModifyAppNameRequest nameRequest = new AppModifyAppNameRequest(); nameRequest.setNewName("New App Name"); nameRequest.setMaterialPath("https://example.com/material.png"); // Supporting material AppModifyAppNameResponse nameResponse = infoService.modifyAppName(nameRequest); // Modify app introduction AppModifyAppIntroRequest introRequest = new AppModifyAppIntroRequest(); introRequest.setNewIntro("This is the new app introduction"); AppModifyAppIntroResponse introResponse = infoService.modifyAppIntro(introRequest); // Modify server domain AppModifyServerDomainRequest domainRequest = new AppModifyServerDomainRequest(); domainRequest.setAction("add"); // add, delete, set domainRequest.setRequest(Arrays.asList("https://api.example.com")); AppModifyServerDomainResponse domainResponse = infoService.modifyServerDomain(domainRequest); System.out.println("Domain modification result: " + domainResponse.checkSuccess()); ``` -------------------------------- ### Query Authorized App List (Java) Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Queries the list of all mini-programs that have authorized your third-party platform. Supports pagination to manage large numbers of authorized applications. Requires page number and size as input. ```Java import com.github.yydzxz.open.api.v1.IByteDanceOpenV1ComponentService; import com.github.yydzxz.open.api.v1.response.auth.AuthAppListResponse; IByteDanceOpenV1ComponentService componentService = byteDanceOpenService.getByteDanceOpenV1ComponentService(); // Query authorized apps with pagination (page starts from 1, max size is 50) int page = 1; int size = 20; AuthAppListResponse response = componentService.authAppList(page, size); System.out.println("Total authorized apps: " + response.getData().size()); for (Object app : response.getData()) { System.out.println("Authorized App: " + app); } // API endpoint: https://open.microapp.bytedance.com/openapi/v1/tp/auth_app_list ``` -------------------------------- ### Generate Pre-Authorization URL (Java) Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Generates the authorization URL required to redirect mini-program administrators to your platform for authorization. This URL is essential for initiating the third-party platform's management of their mini-programs. It requires a redirect URI as input. ```Java import com.github.yydzxz.open.api.v1.IByteDanceOpenV1ComponentService; IByteDanceOpenV1ComponentService componentService = byteDanceOpenService.getByteDanceOpenV1ComponentService(); // Generate pre-authorization URL for mini-program administrators String redirectUri = "https://your-domain.com/callback"; String preAuthUrl = componentService.getPreAuthUrl(redirectUri); System.out.println("Redirect user to: " + preAuthUrl); // Output: https://open.microapp.bytedance.com/mappconsole/tp/authorization?component_appid=xxx&pre_auth_code=xxx&redirect_uri=xxx // After user authorizes, they will be redirected to your callback URL with authorization_code ``` -------------------------------- ### Generate Mini-Program QR Code Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Generates a QR code or image for a mini-program, allowing users to scan and access it. ```APIDOC ## Generate Mini-Program QR Code ### Description Generates a QR code or code image that users can scan to access your mini-program. ### Method POST ### Endpoint https://open.microapp.bytedance.com/openapi/v1/microapp/app/qrcode ### Parameters #### Request Body - **path** (string) - Required - The path to the mini-program page (e.g., "pages/index/index"). ### Request Example ```json { "path": "pages/index/index" } ``` ### Response #### Success Response (200) - **qr_code_image** (byte[]) - The binary data of the QR code image. #### Response Example (Binary image data) ``` -------------------------------- ### Operations Management - Capability Applications API Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Apply for special capabilities like video mounting, live streaming components, and phone number retrieval for your mini-program. ```APIDOC ## GET /openapi/v1/microapp/operation/video_application/status ### Description Checks the application status for the video mounting capability. ### Method GET ### Endpoint https://open.microapp.bytedance.com/openapi/v1/microapp/operation/video_application ### Response #### Success Response (200) - **status** (string) - The current status of the video mounting capability application. ## POST /openapi/v1/microapp/operation/video_application ### Description Applies for the video mounting capability for your mini-program. ### Method POST ### Endpoint https://open.microapp.bytedance.com/openapi/v1/microapp/operation/video_application ### Parameters #### Request Body - **applicationDetails** (object) - Required - Details required for the application. ### Response #### Success Response (200) - **success** (boolean) - Indicates if the application request was successful. ## GET /openapi/v1/microapp/operation/live_application/status ### Description Checks the application status for the live streaming component capability. ### Method GET ### Endpoint https://open.microapp.bytedance.com/openapi/v1/microapp/operation/live_application ### Response #### Success Response (200) - **status** (string) - The current status of the live streaming component capability application. ## POST /openapi/v1/microapp/operation/live_application ### Description Applies for the live streaming component capability for your mini-program. ### Method POST ### Endpoint https://open.microapp.bytedance.com/openapi/v1/microapp/operation/live_application ### Parameters #### Request Body - **applicationDetails** (object) - Required - Details required for the application. ### Response #### Success Response (200) - **success** (boolean) - Indicates if the application request was successful. ## GET /openapi/v1/microapp/operation/phone_number_application/status ### Description Checks the application status for the phone number retrieval capability. ### Method GET ### Endpoint https://open.microapp.bytedance.com/openapi/v1/microapp/operation/phone_number_application ### Response #### Success Response (200) - **status** (string) - The current status of the phone number retrieval capability application. ## POST /openapi/v1/microapp/operation/phone_number_application ### Description Applies for the phone number retrieval capability for your mini-program. ### Method POST ### Endpoint https://open.microapp.bytedance.com/openapi/v1/microapp/operation/phone_number_application ### Parameters #### Request Body - **applicationDetails** (object) - Required - Details required for the application. ### Response #### Success Response (200) - **success** (boolean) - Indicates if the application request was successful. ``` -------------------------------- ### Code Package Management: Upload Code (Java) Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Uploads a code package to an authorized mini-program, utilizing a template from a third-party platform. This process involves specifying the template ID, a user-defined version number and description, and an extension configuration in JSON format. The result indicates whether the code upload was successful. ```Java import com.github.yydzxz.open.api.v1.IByteDanceOpenV1MiniProgramCodeService; import com.github.yydzxz.open.api.v1.request.code.CodeUploadRequest; import com.github.yydzxz.open.api.v1.response.code.CodeUploadResponse; IByteDanceOpenV1MiniProgramCodeService codeService = miniProgramService.getByteDanceOpenV1MiniProgramCodeService(); // Upload code package using template CodeUploadRequest uploadRequest = new CodeUploadRequest(); uploadRequest.setTemplateId(12345L); // Template ID from your platform uploadRequest.setUserVersion("1.0.0"); // Version number uploadRequest.setUserDesc("Initial release"); // Version description uploadRequest.setExtJson("{\"extAppid\":\"" + appId + "\"}"); // Extension config (JSON string) CodeUploadResponse uploadResponse = codeService.upload(uploadRequest); System.out.println("Code upload result: " + uploadResponse.checkSuccess()); // API endpoint: https://open.microapp.bytedance.com/openapi/v1/microapp/package/upload ``` -------------------------------- ### Code Package Management - Submit for Audit Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Submit the uploaded code package for ByteDance platform review before release. This includes fetching available audit hosts and submitting the code for audit. ```APIDOC ## Code Package Management - Submit for Audit ### Description Submit the uploaded code package for ByteDance platform review before release. ### Method POST (Implied by submission, specific HTTP method not detailed in source) ### Endpoint `https://open.microapp.bytedance.com/openapi/v1/microapp/package/audit` ### Parameters #### Query Parameters None specified. #### Request Body None specified. ### Request Example ```json { "example": "No specific request body example provided in source" } ``` ### Response #### Success Response (200) - **checkSuccess** (boolean) - Indicates if the audit submission was successful. #### Response Example ```json { "example": "{ \"success\": true }" } ``` ``` -------------------------------- ### Modify Mini-Program Information API Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Allows updating basic mini-program information, including name, introduction, icon, and domain settings. ```APIDOC ## Modify Mini-Program Information ### Description Update mini-program basic information including name, introduction, icon, and domain settings. ### Method POST ### Endpoint (Specific endpoints vary for each modification type, e.g., /openapi/v1/microapp/app/name/modify, /openapi/v1/microapp/app/intro/modify, /openapi/v1/microapp/app/domain/modify) ### Parameters #### Check App Name Availability ##### Request Body - **appName** (string) - Required - The app name to check. ##### Response Example ```json { "success": true } ``` #### Modify App Name ##### Request Body - **newName** (string) - Required - The new name for the app. - **materialPath** (string) - Required - Path to supporting material (e.g., an image). ##### Response Example ```json { "success": true } ``` #### Modify App Introduction ##### Request Body - **newIntro** (string) - Required - The new introduction for the app. ##### Response Example ```json { "success": true } ``` #### Modify Server Domain ##### Request Body - **action** (string) - Required - Action to perform ('add', 'delete', 'set'). - **request** (array of strings) - Required - List of domain names. ##### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Manage Code Templates Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Provides functionalities to manage code templates for third-party platforms. This includes listing all available templates, retrieving a list of drafts, adding a new template from a draft, and deleting existing templates. Relevant API endpoints are included. ```java import com.github.yydzxz.open.api.v1.IByteDanceOpenV1TemplateService; import com.github.yydzxz.open.api.v1.request.template.*; import com.github.yydzxz.open.api.v1.response.template.*; IByteDanceOpenV1TemplateService templateService = byteDanceOpenService.getByteDanceOpenV1ComponentService().getByteDanceOpenTemplateService(); // Get all templates TemplateGetTplListResponse tplListResponse = templateService.getTplList(); System.out.println("Templates: " + tplListResponse.getData()); // Get draft list TemplateGetDraftListResponse draftListResponse = templateService.getDraftList(); System.out.println("Drafts: " + draftListResponse.getData()); // Add a draft as template TemplateAddTplRequest addTplRequest = new TemplateAddTplRequest(); addTplRequest.setDraftId(123L); // Draft ID to convert to template TemplateAddTplResponse addTplResponse = templateService.addTpl(addTplRequest); System.out.println("Template added: " + addTplResponse.checkSuccess()); // Delete a template TemplateDelTplRequest delTplRequest = new TemplateDelTplRequest(); delTplRequest.setTemplateId(456L); TemplateDelTplResponse delTplResponse = templateService.delTpl(delTplRequest); System.out.println("Template deleted: " + delTplResponse.checkSuccess()); // API endpoints: // Get templates: https://open.microapp.bytedance.com/openapi/v1/tp/template/get_tpl_list // Get drafts: https://open.microapp.bytedance.com/openapi/v1/tp/template/get_draft_list ``` -------------------------------- ### Get/Refresh Authorized Mini-Program Access Token (Java) Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Retrieves the access token for an authorized mini-program. It can automatically refresh the token if it has expired, using the stored refresh token. You can also force a refresh. Requires the mini-program's AppID. ```Java import com.github.yydzxz.open.api.v1.IByteDanceOpenV1ComponentService; IByteDanceOpenV1ComponentService componentService = byteDanceOpenService.getByteDanceOpenV1ComponentService(); String miniProgramAppId = "authorized_mini_program_appid"; // Get access token (automatically refreshes if expired) String accessToken = componentService.getAuthorizerAccessToken(miniProgramAppId, false); System.out.println("Mini-Program Access Token: " + accessToken); // Force refresh the access token String refreshedAccessToken = componentService.getAuthorizerAccessToken(miniProgramAppId, true); System.out.println("Refreshed Access Token: " + refreshedAccessToken); // API endpoint: https://open.microapp.bytedance.com/openapi/v1/oauth/token ``` -------------------------------- ### Code Package Management - Upload Code Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Uploads a code package to an authorized mini-program using a template from your third-party platform. ```APIDOC ## Code Package Management - Upload Code ### Description Upload a code package to an authorized mini-program using a template from your third-party platform. ### Method POST ### Endpoint https://open.microapp.bytedance.com/openapi/v1/microapp/package/upload ### Parameters #### Request Body - **templateId** (integer) - Required - Template ID from your platform. - **userVersion** (string) - Required - Version number of the code. - **userDesc** (string) - Required - Description of the version. - **extJson** (string) - Required - Extension configuration in JSON string format (e.g., {"extAppid":"your_app_id"}). ### Request Example ```json { "templateId": 12345, "userVersion": "1.0.0", "userDesc": "Initial release", "extJson": "{\"extAppid\":\"your_app_id\"}" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the code upload was successful. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Code2Session: Exchange User Login Code for Session Information (Java) Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Converts a user's login code obtained from the mini-program frontend into session information, including a unique openid for user identification. This is crucial for authenticating users and maintaining their session state. It requires the user's login code and optionally an anonymous code. ```Java import com.github.yydzxz.open.api.v1.IByteDanceOpenV1MiniProgramInfoService; import com.github.yydzxz.open.api.v1.response.appinfo.Code2SessionResponse; IByteDanceOpenV1MiniProgramInfoService infoService = miniProgramService.getByteDanceOpenV1MiniProgramInfoService(); // Exchange login code for session (code from tt.login() in mini-program frontend) String code = "user_login_code"; String anonymousCode = null; // Optional anonymous code Code2SessionResponse sessionResponse = infoService.code2Session(code, anonymousCode); System.out.println("Session Key: " + sessionResponse.getSessionKey()); System.out.println("OpenId: " + sessionResponse.getOpenid()); // API endpoint: https://open.microapp.bytedance.com/openapi/v1/microapp/code2session ``` -------------------------------- ### Submit Code Package for Audit Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Submits an uploaded code package for review by the ByteDance platform before it can be released. It first retrieves available audit hosts and then initiates the audit process. The API endpoint for this operation is provided. ```java import com.github.yydzxz.open.api.v1.IByteDanceOpenV1MiniProgramCodeService; import com.github.yydzxz.open.api.v1.response.code.CodeAuditResponse; import com.github.yydzxz.open.api.v1.response.code.CodeAuditHostsResponse; IByteDanceOpenV1MiniProgramCodeService codeService = miniProgramService.getByteDanceOpenV1MiniProgramCodeService(); // Get available audit hosts (Douyin, Toutiao, etc.) CodeAuditHostsResponse hostsResponse = codeService.auditHosts(); System.out.println("Available audit hosts: " + hostsResponse.getData()); // Submit code for audit CodeAuditResponse auditResponse = codeService.audit(); System.out.println("Audit submission result: " + auditResponse.checkSuccess()); // API endpoint: https://open.microapp.bytedance.com/openapi/v1/microapp/package/audit ``` -------------------------------- ### POST /oauth/token Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Exchanges the authorization code for an access token and refresh token. ```APIDOC ## POST /oauth/token ### Description Exchange the authorization code received from the callback for the mini-program's access token and refresh token. ### Method POST ### Endpoint https://open.microapp.bytedance.com/openapi/v1/oauth/token ### Parameters #### Request Body - **authorization_code** (string) - Required - The code received from the callback URL. ### Request Example { "authorization_code": "auth_code_123" } ### Response #### Success Response (200) - **authorizer_appid** (string) - The app ID of the authorized mini-program. - **authorizer_access_token** (string) - The access token for the mini-program. - **expires_in** (integer) - Token expiration time in seconds. - **authorizer_refresh_token** (string) - Token used to refresh the access token. ``` -------------------------------- ### Manage Component Access Tokens Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Retrieves the third-party platform component access token required for API authentication. The SDK automatically manages token caching and refreshing via Redis. ```java import com.github.yydzxz.open.api.v1.IByteDanceOpenV1ComponentService; IByteDanceOpenV1ComponentService componentService = byteDanceOpenService.getByteDanceOpenV1ComponentService(); // Get component access token (uses cached token if valid) String componentAccessToken = componentService.getComponentAccessToken(false); System.out.println("Component Access Token: " + componentAccessToken); // Force refresh the component access token String refreshedToken = componentService.getComponentAccessToken(true); System.out.println("Refreshed Token: " + refreshedToken); ``` -------------------------------- ### Payment Service - Order Management API Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Manage mini-program orders including creating, updating, and deleting order records. ```APIDOC ## POST /api/apps/order/add ### Description Adds a new order record for a mini-program. ### Method POST ### Endpoint https://developer.toutiao.com/api/apps/order/add ### Parameters #### Request Body - **orderId** (string) - Required - The unique identifier for the order. - **openId** (string) - Required - The open ID of the user associated with the order. - **orderStatus** (integer) - Required - The current status of the order. ### Request Example ```json { "orderId": "ORDER_20231001_001", "openId": "user_open_id", "orderStatus": 1 } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. #### Response Example ```json { "success": true } ``` ## PUT /api/apps/order/update ### Description Updates the status of an existing mini-program order. ### Method PUT ### Endpoint https://developer.toutiao.com/api/apps/order/update ### Parameters #### Request Body - **orderId** (string) - Required - The unique identifier for the order. - **openId** (string) - Required - The open ID of the user associated with the order. - **orderStatus** (integer) - Required - The new status of the order. ### Request Example ```json { "orderId": "ORDER_20231001_001", "openId": "user_open_id", "orderStatus": 2 } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. #### Response Example ```json { "success": true } ``` ## DELETE /api/apps/order/delete ### Description Deletes an order record from the mini-program. ### Method DELETE ### Endpoint https://developer.toutiao.com/api/apps/order/delete ### Parameters #### Request Body - **orderId** (string) - Required - The unique identifier for the order. - **openId** (string) - Required - The open ID of the user associated with the order. ### Request Example ```json { "orderId": "ORDER_20231001_001", "openId": "user_open_id" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Exchange Authorization Code for Access Token (Java) Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Exchanges an authorization code, received after a user authorizes your platform, for the mini-program's access token and refresh token. This is a crucial step for subsequent API calls on behalf of the mini-program. The authorization code is the primary input. ```Java import com.github.yydzxz.open.api.v1.IByteDanceOpenV1ComponentService; import com.github.yydzxz.open.api.v1.response.auth.GetAuthorizerAccessTokenResponse; IByteDanceOpenV1ComponentService componentService = byteDanceOpenService.getByteDanceOpenV1ComponentService(); // Exchange authorization code for access token (received from callback) String authorizationCode = "authorization_code_from_callback"; GetAuthorizerAccessTokenResponse response = componentService.getAuthorizerAccessTokenByAuthorizationCode(authorizationCode); System.out.println("Authorizer AppId: " + response.getAuthorizerAppid()); System.out.println("Access Token: " + response.getAuthorizerAccessToken()); System.out.println("Expires In: " + response.getExpiresIn() + " seconds"); System.out.println("Refresh Token: " + response.getAuthorizerRefreshToken()); // Tokens are automatically stored in Redis for later use // Access token valid for ~2 hours, refresh token valid for ~1 month ``` -------------------------------- ### Code Package Management - Release and Rollback Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Release the approved code package to production or rollback to a previous version. Also includes functionality to revoke an audit submission. ```APIDOC ## Code Package Management - Release and Rollback ### Description Release the approved code package to production or rollback to a previous version. Also includes functionality to revoke an audit submission. ### Method POST (Implied by actions, specific HTTP methods not detailed in source) ### Endpoint - **Release:** `https://open.microapp.bytedance.com/openapi/v1/microapp/package/release` - **Rollback:** `https://open.microapp.bytedance.com/openapi/v1/microapp/package/rollback` ### Parameters #### Query Parameters None specified. #### Request Body None specified. ### Request Example ```json { "example": "No specific request body example provided in source" } ``` ### Response #### Success Response (200) - **checkSuccess** (boolean) - Indicates if the operation (release, rollback, revoke) was successful. #### Response Example ```json { "example": "{ \"success\": true }" } ``` ``` -------------------------------- ### Material Upload Service Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Upload images and materials required for mini-program modifications such as changing the name, icon, or category certification. ```APIDOC ## Material Upload Service ### Description Upload images and materials required for mini-program modifications like changing name, icon, or category certification. ### Method POST (Implied by upload, specific HTTP method not detailed in source) ### Endpoint `https://open.microapp.bytedance.com/openapi/v1/microapp/upload_material` ### Parameters #### Path Parameters None specified. #### Query Parameters None specified. #### Request Body - **materialType** (integer) - Required - The type of material being uploaded. - **materialFile** (file) - Required - The material file to upload (supports bmp, jpeg, jpg, png). ### Request Example ```json { "materialType": 1, "materialFile": "/path/to/material.png" } ``` ### Response #### Success Response (200) - **materialPath** (string) - The URL of the uploaded material. #### Response Example ```json { "materialPath": "http://example.com/path/to/uploaded/material.png" } ``` ``` -------------------------------- ### Template Management API Source: https://context7.com/yydzxz/bytedanceopen/llms.txt Manage code templates for your third-party platform, including listing all templates, retrieving drafts, adding templates from drafts, and deleting templates. ```APIDOC ## Template Management ### Description Manage code templates for your third-party platform including listing, adding from drafts, and deleting templates. ### Method POST (Implied by actions, specific HTTP methods not detailed in source) ### Endpoint - **Get Templates:** `https://open.microapp.bytedance.com/openapi/v1/tp/template/get_tpl_list` - **Get Drafts:** `https://open.microapp.bytedance.com/openapi/v1/tp/template/get_draft_list` - **Add Template:** `https://open.microapp.bytedance.com/openapi/v1/tp/template/add_tpl` - **Delete Template:** `https://open.microapp.bytedance.com/openapi/v1/tp/template/del_tpl` ### Parameters #### Path Parameters None specified. #### Query Parameters None specified. #### Request Body - **addTpl:** - **draftId** (long) - Required - The ID of the draft to convert into a template. - **delTpl:** - **templateId** (long) - Required - The ID of the template to delete. ### Request Example #### Add Template ```json { "draftId": 123 } ``` #### Delete Template ```json { "templateId": 456 } ``` ### Response #### Success Response (200) - **getTplList:** Returns a list of templates. - **getDraftList:** Returns a list of drafts. - **addTpl:** - **checkSuccess** (boolean) - Indicates if the template was added successfully. - **delTpl:** - **checkSuccess** (boolean) - Indicates if the template was deleted successfully. #### Response Example ```json { "example": "{ \"success\": true }" } ``` ```