Avoid repetitive API calling in form rebuild while submitting
You can test whether the form is currently rebuilding using the FormStateInterface::isRebuilding method:

if (!$form_state-&gt;isRebuilding()) {
  // Contact the API
}