Skip to content

Latest commit

 

History

History
306 lines (212 loc) · 28.2 KB

README.md

File metadata and controls

306 lines (212 loc) · 28.2 KB

Channels

Overview

Available Operations

list

List the channels in a project. The list is paginated. Needs the channels:read permission.

Example Usage

from moderation_api import ModerationAPI
import os


with ModerationAPI(
    secret_key=os.getenv("MODAPI_SECRET_KEY", ""),
) as ma_client:

    res = ma_client.channels.list(project_id="<id>", page=1, page_size=20)

    while res is not None:
        # Handle items

        res = res.next()

Parameters

Parameter Type Required Description
project_id str ✔️ The ID of the project.
page Optional[int] ➖ N/A
page_size Optional[int] ➖ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.ListChannelsResponse

Errors

Error Type Status Code Content Type
errors.AuthenticationError 401 application/json
errors.PermissionDeniedError 403 application/json
errors.NotFoundError 404 application/json
errors.RateLimitError 429 application/json
errors.ModerationAPIDefaultError 4XX, 5XX */*

create

Create a channel in a project, with the default rules. The project's first channel becomes its default. Needs the channels:write permission.

Example Usage

from moderation_api import ModerationAPI
import os


with ModerationAPI(
    secret_key=os.getenv("MODAPI_SECRET_KEY", ""),
) as ma_client:

    res = ma_client.channels.create(project_id="<id>", name="<value>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
project_id str ✔️ The ID of the project to add the channel to.
name str ✔️ The channel's name.
key Optional[str] ➖ The key you pass as channel when you moderate content. Defaults to the name in lowercase with dashes. Must be unique in the project.
description Optional[str] ➖ The channel's description.
content_type Optional[models.CreateChannelContentType] ➖ The kind of content the channel moderates.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.Channel

Errors

Error Type Status Code Content Type
errors.BadRequestError 400 application/json
errors.AuthenticationError 401 application/json
errors.PermissionDeniedError 403 application/json
errors.NotFoundError 404 application/json
errors.RateLimitError 429 application/json
errors.ModerationAPIDefaultError 4XX, 5XX */*

retrieve

Get a channel by ID. Needs the channels:read permission.

Example Usage

from moderation_api import ModerationAPI
import os


with ModerationAPI(
    secret_key=os.getenv("MODAPI_SECRET_KEY", ""),
) as ma_client:

    res = ma_client.channels.retrieve(id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
id str ✔️ The ID of the channel.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.Channel

Errors

Error Type Status Code Content Type
errors.AuthenticationError 401 application/json
errors.PermissionDeniedError 403 application/json
errors.NotFoundError 404 application/json
errors.RateLimitError 429 application/json
errors.ModerationAPIDefaultError 4XX, 5XX */*

update

Update a channel. Fields you leave out keep their value. Needs the channels:write permission.

Example Usage

from moderation_api import ModerationAPI
import os


with ModerationAPI(
    secret_key=os.getenv("MODAPI_SECRET_KEY", ""),
) as ma_client:

    res = ma_client.channels.update(id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
id str ✔️ The ID of the channel to update.
name Optional[str] ➖ The channel's name.
key Optional[str] ➖ The key you pass as channel when you moderate content. Changing it breaks integrations that send the old key.
description OptionalNullable[str] ➖ The channel's description.
content_type Optional[models.UpdateChannelContentType] ➖ The kind of content the channel moderates.
flagging_mode Optional[models.UpdateChannelFlaggingMode] ➖ ACTIVE flags content. DRY_RUN evaluates content without flagging it.
context_enabled Optional[bool] ➖ Whether earlier messages in the conversation are read when moderating a message.
enable_image_moderation Optional[bool] ➖ Whether images are moderated.
enable_video_moderation Optional[bool] ➖ Whether videos are moderated.
enable_audio_moderation Optional[bool] ➖ Whether audio is moderated.
enable_voice_moderation Optional[bool] ➖ Whether real-time voice streams are moderated.
include_transcript_in_response Optional[bool] ➖ Whether audio and video transcripts are returned in responses.
transcription_quality Optional[models.UpdateChannelTranscriptionQuality] ➖ Trade-off between transcription speed and accuracy.
unicode_spoof_detection_enabled Optional[bool] ➖ Whether look-alike Unicode characters are normalized before moderation.
frame_capture_interval Optional[float] ➖ Seconds between frames captured from a video.
max_frames_per_video Optional[int] ➖ The most frames moderated per video.
spread_frames Optional[bool] ➖ Whether frames are spread evenly across the whole video.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.Channel

Errors

Error Type Status Code Content Type
errors.BadRequestError 400 application/json
errors.AuthenticationError 401 application/json
errors.PermissionDeniedError 403 application/json
errors.NotFoundError 404 application/json
errors.RateLimitError 429 application/json
errors.ModerationAPIDefaultError 4XX, 5XX */*

delete

Delete a channel. Its key is freed for a new channel. When it was the default, the oldest remaining channel becomes the default. A channel that still moderates a Slack workspace must be disconnected first. Needs the channels:write permission.

Example Usage

from moderation_api import ModerationAPI
import os


with ModerationAPI(
    secret_key=os.getenv("MODAPI_SECRET_KEY", ""),
) as ma_client:

    res = ma_client.channels.delete(id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
id str ✔️ The ID of the channel.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.DeleteChannelResponse

Errors

Error Type Status Code Content Type
errors.BadRequestError 400 application/json
errors.AuthenticationError 401 application/json
errors.PermissionDeniedError 403 application/json
errors.NotFoundError 404 application/json
errors.RateLimitError 429 application/json
errors.ModerationAPIDefaultError 4XX, 5XX */*

duplicate

Copy a channel in its project, with every setting, policy, rule and wordlist. Integrations (Discord, Slack, WordPress) are not copied. Needs the channels:write permission.

Example Usage

from moderation_api import ModerationAPI
import os


with ModerationAPI(
    secret_key=os.getenv("MODAPI_SECRET_KEY", ""),
) as ma_client:

    res = ma_client.channels.duplicate(id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
id str ✔️ The ID of the channel to copy.
name Optional[str] ➖ Name of the copy. Defaults to the original name with "(copy)".
key Optional[str] ➖ Key of the copy. Defaults to the original key with a timestamp. Must be unique in the project.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.Channel

Errors

Error Type Status Code Content Type
errors.BadRequestError 400 application/json
errors.AuthenticationError 401 application/json
errors.PermissionDeniedError 403 application/json
errors.NotFoundError 404 application/json
errors.RateLimitError 429 application/json
errors.ModerationAPIDefaultError 4XX, 5XX */*