Facebook profited handsomely from the truly fucked up ad targeting they offered CA, quite literally segmenting populations based on things like personality, political beliefs, traits that define protected classes, racist/antisemetic/etc beliefs, whether they were friends with people who were/had either of those things, if they were mentally ill, etc. Their API also exposed their users' private data, including things like location, likes, follows, comments, friends, their posts, etc.
Facebook's API allowed CA to harvest a lot of data, which allowed them to conduct psychological profiling and targeting research, and analysis on massive troves of FB's data. All of that allowed them to develop tailored ads for specific segments of the population they chose to turn elections. Based on the profiling they did, for example, they were able to determine that if they were able to show 1,000 narrowly chosen people in one neighborhood, say, racist ads, CA's statistics show that they will be able to turn a tight election. CA was able to do this because of the data Facebook provided them, as well as the advertising platform Facebook provides that allowed CA to pinpoint segments of the public that are susceptible to their particular brand of psychological and political exploitation.
However, the data that CA mined was provided by Facebook's API, and anyone with a free API key could have mined it. FB technically didn't sell them the data, but they certainly sold them the means to manipulate elections and violate the privacy of millions of people. And as I said, that's a technicality that doesn't mean much.