This article presents possible use cases and corresponding sample flows that you can support. This can be a helpful jumping off point as you plan your implementation.
You can check credit availability before translation to avoid failed requests.
To check for sufficient credits before machine translation:
Calculate the total number of words that need to be translated.
Call Check Sufficient Credits and specify the word count to determine whether a site has enough credits for the translation.
If there are sufficient credits, use the Machine Translation API to translate the content. If not, Wix users need to purchase additional credits in the Translation Manager.
You may want to monitor translation costs for a site to help users track usage and plan their translation budget.
To create a credit dashboard for a site:
For each site, periodically call Get Credit Data to obtain the quota type, quota amount, and the number of credits used at a given time.
For sites with a limited quota, calculate the remaining credits by subtracting the credits used from the quota.
Display this data on your dashboard and in a notification system to alert Wix users when a site's credit balance is running low.