Repository navigation
v3.0.0
moderation_api 3.0.0
A new major version of the Ruby SDK. Read the breaking changes before you upgrade.
gem install moderation_api -v "~> 3.0"Ruby-specific changes
- The module is
ModerationApi(wasModerationAPI). Create the client withModerationApi::ModerationApi.new(secret_key: ENV.fetch("MODAPI_SECRET_KEY")). - Requests are typed objects, for example
Operations::SubmitContentRequest.new(content: Operations::TextRequest.new(text: "...")), and responses carry the result in.object. Sorbet type signatures are included. - Verify webhooks with
require "moderation_api/webhook_signature"andModerationApi::WebhookSignature.construct_event(payload, signature).
What's new
- Covers the whole API, including the management API (
projects,channels), wordlists and the review queue. - Automatic pagination. List methods return an iterator that fetches the next page for you.
- Clear errors. One error class per HTTP status (
BadRequestError,NotFoundError,RateLimitError, ...). Every error has a specificcode(for exampleinvalid_api_key,quota_exceededorauthor_not_found), arequest_idand adoc_url. See Errors. - Retries with exponential backoff on
429and5xx, and timeouts per client or per request. - Webhook verification that reads the secret from
MODAPI_WEBHOOK_SECRET.
Breaking changes
The SDK is now generated from our OpenAPI spec with a new generator. Most calls keep their names, but check these:
- List responses are
{ data, pagination }instead of a plain array or a resource-specific shape, and list methods takepageandpageSize. - Errors have a new body:
codeis the specific error code, not the HTTP category. The olddatafield is gone. - Renamed:
account.listis nowaccount.retrieve, andactions.execute.executeis nowactions.execute. - Removed:
actions.execute.executeByID(useactions.executewithactionIdoractionKey),auth.*, andcontent.stream(see Real-time voice). - Organization keys work only with
projectsandchannels; project keys work with everything else. Use one client per key. See the README.
The license is unchanged: Apache-2.0.