A similar question was asked in The Test Chat Community, one month back. Here is my take on it:
API automation pays nothing when one needs UI automation.
UI automation pays nothing when one needs API automation.
UI apps are of multiple types: Web, Desktop, Mobile, PWA, Tv, Tablets
API(s) are also of multiple types: rest, soap, HTTP JSON, SDK API(s), etc.
Automation of both is possible in different frameworks, programming languages, and even no-code tools.
Different skill sets have different market demand and supply
Different companies have different demand/ supply ratios for different skills.
Some might pay more for API automation skills, while some might give more pay for UI automation skills.
The depth of your automation skills in API or UI will also play a crucial role.
However, a skilled person can earn well in both. Also, both are not exclusive skills and are mostly complementary skills, one can learn both too 🙂
Hope this helps!