Skip to content

Latest commit

 

History

History
301 lines (208 loc) · 44.5 KB

README.md

File metadata and controls

301 lines (208 loc) · 44.5 KB

Analytics

Overview

Available Operations

summary

Get the totals of the project for a time window: requests, flags, flag rate, allowed, rejected and sent to review, with the window before for the trend. Also the review queue backlog and a flag-rate spike, if there is one.

Example Usage

from moderation_api import ModerationAPI
import os


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

    res = ma_client.analytics.summary(range="30d")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
range Optional[models.GetAnalyticsSummaryQueryParamRange] ➖ The time window. 24h is the last 24 hours, in hourly buckets. 7d, 30d and 90d are whole UTC days that end with today, in daily buckets.
channel Optional[str] ➖ N/A
project_id Optional[str] ➖ The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.GetAnalyticsSummaryResponse

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.InternalServerError 500 application/json
errors.ModerationAPIDefaultError 4XX, 5XX */*

policies

Get the policy labels that flagged the most content in a time window, largest first, with the count in the window before.

Example Usage

from moderation_api import ModerationAPI
import os


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

    res = ma_client.analytics.policies(range="30d", limit=8)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
range Optional[models.GetAnalyticsPoliciesQueryParamRange] ➖ The time window. 24h is the last 24 hours, in hourly buckets. 7d, 30d and 90d are whole UTC days that end with today, in daily buckets.
channel Optional[str] ➖ N/A
limit Optional[int] ➖ N/A
project_id Optional[str] ➖ The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.GetAnalyticsPoliciesResponse

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.InternalServerError 500 application/json
errors.ModerationAPIDefaultError 4XX, 5XX */*

authors

Get the authors with the most flagged content in a time window, largest first.

Example Usage

from moderation_api import ModerationAPI
import os


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

    res = ma_client.analytics.authors(range="30d", limit=6)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
range Optional[models.GetAnalyticsAuthorsQueryParamRange] ➖ The time window. 24h is the last 24 hours, in hourly buckets. 7d, 30d and 90d are whole UTC days that end with today, in daily buckets.
channel Optional[str] ➖ N/A
limit Optional[int] ➖ N/A
project_id Optional[str] ➖ The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.GetAnalyticsAuthorsResponse

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.InternalServerError 500 application/json
errors.ModerationAPIDefaultError 4XX, 5XX */*

channels

Get requests, flags and flag rate for each channel of the project in a time window.

Example Usage

from moderation_api import ModerationAPI
import os


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

    res = ma_client.analytics.channels(range="30d")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
range Optional[models.GetAnalyticsChannelsQueryParamRange] ➖ The time window. 24h is the last 24 hours, in hourly buckets. 7d, 30d and 90d are whole UTC days that end with today, in daily buckets.
project_id Optional[str] ➖ The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.GetAnalyticsChannelsResponse

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.InternalServerError 500 application/json
errors.ModerationAPIDefaultError 4XX, 5XX */*

volumes

Get requests, flags, rejections and reviews per hour (24h) or per day (7d, 30d, 90d), oldest first.

Example Usage

from moderation_api import ModerationAPI
import os


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

    res = ma_client.analytics.volumes(range="30d")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
range Optional[models.GetAnalyticsVolumesQueryParamRange] ➖ The time window. 24h is the last 24 hours, in hourly buckets. 7d, 30d and 90d are whole UTC days that end with today, in daily buckets.
channel Optional[str] ➖ N/A
project_id Optional[str] ➖ The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.GetAnalyticsVolumesResponse

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.InternalServerError 500 application/json
errors.ModerationAPIDefaultError 4XX, 5XX */*

automation

Get how flagged content was handled in a time window: settled by rules or the casebook, or sent to human review, and what the reviewers decided.

Example Usage

from moderation_api import ModerationAPI
import os


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

    res = ma_client.analytics.automation(range="30d")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
range Optional[models.GetAnalyticsAutomationQueryParamRange] ➖ The time window. 24h is the last 24 hours, in hourly buckets. 7d, 30d and 90d are whole UTC days that end with today, in daily buckets.
channel Optional[str] ➖ N/A
project_id Optional[str] ➖ The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.GetAnalyticsAutomationResponse

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.InternalServerError 500 application/json
errors.ModerationAPIDefaultError 4XX, 5XX */*