Custom function that retrieves JSON code which is showing connection between contacts, emails and campaigns

Custom function that retrieves JSON code which is showing connection between contacts, emails and campaigns

Hello,

Each week, I want to see how many emails are sent, in which campaigns are they sent and I what to see what is their status - both email status and campaign status. 
For example, If email status is "bounced", I want to check if campaign status is updated to "bounced" (campaign status should be manually updated by person who has sent the email ("Sent by").

Is there I way I can retrieve JSON code where I can see connection between contacts, emails and campaigns?
I am assuming that contacts module is main link for these information.

The main goal is to see how many emails are sent on the weekly level, who has sent them and to which contact are they sent, and I want to see statuses - both email status and campaign status.

I would also like to add condition based on date, because I don't want to see all the emails that have ever been sent. For example: show me all emails sent between 12-09-2022 and 16-09-2022


2. I also have second question. Can somebody give me custom function code that loops through all accounts that we have in our database (we have around 7k accounts)? I just want to get back JSON code that contains information for all of them.