I do not have a C# specific example but I think this should get you up and running. This is the SparkPost API you need
https://developers.sparkpost.com/api/suppression-list/
If language is not super important and just looking for the easiest way to pull the list have a look here:
https://www.sparkpost.com/docs/tech-resources/download-suppression-list/
... Or my pal tuck1s has this great example in Python:
https://github.com/tuck1s/sparkySuppress
You will need to change $SPARKPOST_API_KEY to your API key for this.
Use this to get a summary of your suppression lists
curl -v -H "Content-Type: application/json" -H "Authorization: $SPARKPOST_API_KEY" -X GET "https://api.sparkpost.com/api/v1/suppression-list/summary"
You can do this to get your suppression list records
curl -v \
-H "Content-Type: application/json" \
-H "Authorization: $SPARKPOST_API_KEY" \
-X GET "https://api.sparkpost.com/api/v1/suppression-list?sources=Bounce+Rule,Manually+Added"
Here are the sources you can pull the suppressions for:
- Bounce Rule
- Compliance
- List Unsubscribe
- Manually Added
- Spam Complaint
- Unsubscribe Link
That will produce results like this
{
"results": [
{
"recipient": "jane@example.com",
"type": "transactional",
"source": "Manually Added",
"description": "MBL: jane@example.com,hard-bounce,\"smtp;550 5.1.1 The email account that you tried to reach does not exist. Please try double-checking the recipient's email address for typos or unnecessary spaces. Learn more at https://support.google.com/mail/answer/",
"created": "2020-10-23T18:50:07+00:00",
"updated": "2020-10-23T18:50:07+00:00",
"transactional": true
},
{
"recipient": "john@example.com",
"type": "transactional",
"source": "Manually Added",
"description": "MBL: john@example.com,hard-bounce,\"smtp;550 5.1.10 RESOLVER.ADR.RecipientNotFound; Recipient not found by SMTP address lookup\",\"2015-12-18 17:49:49.74724\",\"2016-01-28 19:44:39\",\"2016-01-14 19:44:39.83638\",\"2016-01-28 19:44:39\",",
"created": "2020-10-23T18:50:07+00:00",
"updated": "2020-10-23T18:50:07+00:00",
"transactional": true
}
],
"links": [
{
"href": "/api/v1/suppression-list?page=2&sources=Bounce Rule,Manually Added&per_page=1000",
"rel": "next"
},
{
"href": "/api/v1/suppression-list?page=10&sources=Bounce Rule,Manually Added&per_page=1000",
"rel": "last"
}
],
"total_count": 1111578
}
To get the next page of results just follow the URI sent in /links/href
Here is a C# example as produced by PostMan for the above Curl command
var client = new RestClient("https://api.sparkpost.com/api/v1/suppression-list?sources=Bounce+Rule,Manually+Added");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "SPARKPOST_API_KEY");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);