Page 1 of 1

API GET all Site Contacts

Posted: Tue Aug 26, 2025 3:38 am
by NickFrank
Im sure this is in here, I havent be able to find it and I did a bit of a search. Sorry if it is can you link me?

We are trying to use a GET for a list of Site Contacts with the API. I am able to get a Company Contact with /api/v1.0/companies/0/contacts but is there one for the Site Contact?

I am also seeing it maxes out at 250 pages. Is there a way to get more than that?

Basically, we need to pull all the site contacts for a POST in another platform.

HELP PLEASE!

Re: API GET all Site Contacts

Posted: Tue Aug 26, 2025 1:17 pm
by mlt
This is a great question, and it's a hurdle many of us have had to clear. The Simpro API handles this in a specific way.

You're correct that there isn't a single global endpoint like /api/v1.0/companies/0/sitecontacts/ to get every site contact at once. Site Contacts are considered children of a specific Site. Therefore, to get all of them, you first need to get all the Sites and then loop through them to get their associated contacts.

Regarding the 250-item limit, you've correctly identified that the API uses pagination. You need to make multiple requests, incrementing the page number each time, until you get an empty response.

Here’s a step-by-step guide and some pseudo-code to solve this:

Step 1: Fetch All Site IDs with Pagination

First, you need to loop through the /sites/ endpoint to collect a list of all Site IDs.

Code: Select all

// Pseudo-code for getting all Site IDs

all_site_ids = []
current_page = 1
keep_fetching = true

while (keep_fetching) {
    // Make the API call for the current page
    api_url = "https://{your_build}.simprosuite.com/api/v1.0/companies/0/sites/?page=" + current_page
    response = GET(api_url)

    if (response is not empty) {
        // Add the Site IDs from this page to your master list
        for each site in response {
            add site.ID to all_site_ids
        }
        // Go to the next page for the next loop
        current_page = current_page + 1
    } else {
        // The response was empty, so we've reached the last page
        keep_fetching = false
    }
}
Step 2: Loop Through Site IDs to Get Contacts

Now that you have your complete list of all_site_ids, you can loop through that list and make a request to the contacts endpoint for each site.

Code: Select all

// Pseudo-code for getting contacts from each site

all_site_contacts = []

for each site_id in all_site_ids {
    // Make the API call to the site's contacts endpoint
    api_url = "https://{your_build}.simprosuite.com/api/v1.0/companies/0/sites/" + site_id + "/contacts/"
    response = GET(api_url)

    if (response is not empty) {
        // Add the returned contacts to your final list
        add response to all_site_contacts
    }
}

// Now, 'all_site_contacts' contains every site contact from your build.
This two-step process is the standard way to pull complete lists of nested resources from the API. It can seem a bit long-winded, but it's reliable.

Hope this helps you get the data you need!

Re: API GET all Site Contacts

Posted: Wed Aug 27, 2025 7:51 am
by NickFrank
Awesome! Thank you! I’ll give it a try!

Thanks so much!

Re: API GET all Site Contacts

Posted: Wed Sep 17, 2025 3:39 am
by NickFrank
Does anyone else use n8n for this type of integration?

If not, what are you guys using. I've only beeing doing this for about a yer and Im still learning!

Thanks for all the help!