# Using the open API

# outline

In addition to simple voice functions, VChatCloud provides several voice functions in the form of an open API. These APIs are included in the VChatCloudApi class inside the SDK and can be actually called and used.

# How to query chat room information

This is how to query chat room information.

ChatRoomModel roomInfo = await VChatCloudApi.getRoomInfo(roomId: "YOUR_CHANNEL_KEY");
1
  • parameter value
value identifier Description
roomId String ChannelKey of the chat room created in CMS
  • result value
value identifier Description
roomInfo ChatRoomModel (opens new window) room information

# How to find the number of likes in a chat room

This method retrieves the cumulative number of likes for a chat room.

int likeCount = await VChatCloudApi.getLike(roomId: "YOUR_CHANNEL_KEY");
1
  • parameter value

    value identifier Description
    roomId String ChannelKey of the chat room created in CMS
  • result value

    value identifier Description
    likeCount int Chat Room Cumulative Likes

# How to add number of chat room likes

This method adds the number of likes to a chat room.

int likeCount = await VChatCloudApi.like(roomId: "YOUR_CHANNEL_KEY");
1
  • parameter value

    value identifier Description
    roomId String ChannelKey of the chat room created in CMS
  • result value

    value identifier Description
    likeCount int Chat Room Cumulative Likes

# How to retrieve the list of files uploaded to the chat room

This method retrieves the list of files uploaded to the chat room.

List<FileModel> fileList = await VChatCloudApi.getFileList(roomId: "YOUR_CHANNEL_KEY");
1
  • parameter value

    value identifier Description
    roomId String ChannelKey of the chat room created in CMS
  • result value

    value identifier Description
    fileList List<FileModel (opens new window)> Array of list of uploaded files

# How to download the file uploaded to the chat room

This method gets the data of the file uploaded to the chat room and saves it to the specified path.

String roomId = "YOUR_CHANNEL_KEY";
List<FileModel> fileList = await VChatCloudApi.getFileList(roomId: roomId);
File result = await VChatCloudApi.download(
  file: fileList.first,
  downloadPath: "/",
);
1
2
3
4
5
6
  • parameter value

    value identifier Description
    file FileModel (opens new window) File Info
    downloadPath String Path to save the file
  • result value

    value identifier Description
    result File stored file object

# OpenGraph information request method

This method requests OpenGraph information of the desired URL.

var url = "https://vchatcloud.com"; // Enter the desired address.
OpenGraphModel openGraphInfo = await VChatCloudApi.openGraph(requestUrl: url); 
1
2
  • parameter value

    value identifier Description
    requestUrl String URL to query OpenGraph information
  • result value

    value identifier Description
    openGraphInfo OpenGraphModel (opens new window) About OpenGraph

# Google Translate method

This method translates the desired text using the Google Translate API. To use this function, after setting Google Translate to Enable in the chat room settings in the CMS, enter the API KEY issued by Google in the Google API KEY value, click the Edit button to save, and It is available.

The process of obtaining a Google API KEY is detailed in Using translation.

List of languages ​​and codes that can be translated

For language codes that can be used for target, refer to Google language support (opens new window).

GoogleTranslationModel translated = await VChatCloudApi.googleTranslation(
  text: "message",
  target: "en",
  roomId: "YOUR_CHANNEL_KEY",
);
1
2
3
4
5
  • parameter value

    value identifier Description
    text String Text you want to translate
    target String Language you want to translate
    roomId String ChannelKey of the chat room created in CMS
  • result value

    value identifier Description
    translated GoogleTranslationModel (opens new window) Translated message content
Copyright 2022. E7Works Inc. & JOYTUNE Corp. All Rights Reserved.