It's legal though. See SerpAPI for precedent. Google was really bummed about losing that one.
It's also legal for X to pressure you in many ways to stop doing a legal thing, to take technical measures to prevent you from doing it, and to ban your account on X.
Doing it and making money from it was always going to end in a ban.