Linking userId to Referrer or Campaign

Hi Everyone,

I am trying to mine a Matomo database to generate a report on who (specific userIds that we are capturing) found the site from which campaign or referrer. In the SQL, I can find it with relative ease. However, I noticed that all of the data outside of this month is archived. Someone suggested that I use the API to mine it, but I can’t seem to find a way to get at the data. The desired output would be something like:

‘CampaignID’: userIdA, userIdB, userIdC
‘AnotherCampaignID’: userIdD, userIdA, userIdE

I’d love any suggestions that you have. Thanks! -Mark