I mean, yes you could, but it would take forever and require a TON of looping through multiple calls. You would use the documented REST endpoint (no direct link) of:
/contacts/v1/addresses/search/{{attributeName}}
This endpoint shows a requirement of a body containing a filterConditionOperator
and filterConditionValue
- but you can make the call without these and it will return all contacts. The issue is that the default page size is 50, so using that, it would take an extremely long time with a crazy amount of calls to get all your contacts.
You can adjust the returned pageSize via the following params attached to the endpoint though: ?$page=1&$pageSize=2500
but with the large amount of data passed back per subscriber, this can make your API call reach closer and closer to timing out.
Plus, even still, with a cap of (I think) 10,000 - that is still small potatoes compared to the average of a couple million contacts that most people have. Meaning if you could safely hit the maximum of 10k per call, you would still need 100 calls just to collect 1 million records. Lets say each call is around 30 seconds just to get the data, then lets add another 30 seconds for processing and concatenation of the returned arrays - we are looking at nearly 2 hours for a million records - and that doesn't account for increased processing as the array grows in size each time records are added to it.
This process could take days to fully run and during that time, you run into risks of contacts being updated or deleted or added that you will miss. It also has a risk of erroring in a call and potentially tossing the whole process up to that point or even missing sections of it completely and leaving gaps that you may not even know about.
Instead of using the actual REST service, what I would do to get ALL contacts is first create a mobile list that has the following filter condition:
Contact Key is not null
(Here is a good resource talking about this type of a solution for gathering contacts via Mobile Lists)
This should grab every single contact in your account into a single mobile list. If this is a 'one time' need, you can just export this here onto the FTP and then move the file wherever you need for your system to grab it.
If it is a multiple use thing, you could then create a SQL query to move this data from a mobile list into a Data Extension as you can use the List name similar to a Data Extension inside of SQL Queries.
SELECT ContactKey
FROM [myMobileListName]
Then you can do a data extract on this DE and use a File Transfer to push to the SFMC FTP or any other FTP location you need to send this to. You can then use your system to grab the file.