lets say I had twitter analytics data and instagram analytics data. There would be a seperate microservice for twitter analytics data and instagram analytics data.
I feel there is a need to seperate the services as each of these services are fetching a users analytics from a third party api (twitter, facebook, etc) and then storing the analytics. If all the services were combined into 1 monolith, wouldn't it be hard to add more third party providers and manage everything in general?
There's no one true answer. But instinctively I'd be considering the position of having a single "analytics service" rather than a per-external-party service.
The issue is that the per-external-party service approach means that downstream consumers are affected by the addition/removal of a third party, which means you've got a leaky abstraction on your hands. Your consumers need to know which third parties are available so that they can call the appropriate service, which defeats the purpose of abstracting that dependency away in a separate microservice.
By keeping it together as "the analytics service", you obfuscate which third parties you rely on, and you can add/remove third parties by solely redeploying "the analytics service" without impacting your downstream consumers.
But like I said, there's no one true answer. It depends on what you need. I'm mentioning the approach that you've dismissed simply to point out that it can be equally valid.
However what would happen if I had n amount of services that I needed to request to? Like let's say a user needs analytics data from facebook, instagram, twitter and tiktok. How would I handle making a seperate request to each and then combine into a single response for the client?
The bolded part especially leads you down the BFF (backend for frontend) pattern, although the consumer here might be a different backend service instead of a frontend.
The focus here is on the "General Purpose server-side API", which is effectively a microservice that fetches data from several other sources (the ghostly icons at the bottoms), collating it into a single data response, which it then sends on to the downstream consumer (commonly the frontend).
Additionally, we can considered that this intermediary service is really just "the analytics service" which I talked about before. It presents the analytics as a single front, to hide the complexity of having multiple third party providers.
The same question then arises: do you really need those additional separate per-external-party services? The answer to that is found by figuring out what it nets you.
For example, if you need vastly different scaling for these different third parties, then it can make sense to have these as different runtimes/services. But in absence of such a need, I would argue that having a single analytics service makes the most sense.
Note also that once you have this analytics service, nothing is stopping you from later adding those separate per-external-party services. Adding them will not impact the downstream consumer of the analytics service, since the analytics service breaks any direct dependency between a downstream consumer and a specific third party.