Add words to an existing wordlist
from moderation_api import ModerationAPI
import os
with ModerationAPI(
secret_key=os.getenv("MODAPI_SECRET_KEY", ""),
) as ma_client:
res = ma_client.wordlist.words.add(id="<id>", words=[
"free money",
"click here",
])
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
id |
str | ✔️ | ID of the wordlist to add words to |
words |
List[str] | ✔️ | Array of words to add to the wordlist. Duplicate words will be ignored. |
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. |
models.AddWordlistWordsResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestError | 400 | application/json |
| errors.AuthenticationError | 401 | application/json |
| errors.NotFoundError | 404 | application/json |
| errors.RateLimitError | 429 | application/json |
| errors.ModerationAPIDefaultError | 4XX, 5XX | */* |
Remove words from an existing wordlist
from moderation_api import ModerationAPI
import os
with ModerationAPI(
secret_key=os.getenv("MODAPI_SECRET_KEY", ""),
) as ma_client:
res = ma_client.wordlist.words.remove(id="<id>", words=[
"<value 1>",
"<value 2>",
"<value 3>",
])
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
id |
str | ✔️ | ID of the wordlist to remove words from |
words |
List[str] | ✔️ | Array of words to remove from the wordlist |
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. |
models.RemoveWordlistWordsResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestError | 400 | application/json |
| errors.AuthenticationError | 401 | application/json |
| errors.NotFoundError | 404 | application/json |
| errors.RateLimitError | 429 | application/json |
| errors.ModerationAPIDefaultError | 4XX, 5XX | */* |