Mailgun event API call

Does anyone have experience with generating an API call for ‘events’ for mailgun? I need to extract the event data by date. I understand mailgun maintains 30 days of detailed data, 365 days of monthly summarized data. I want to pull the last 30 days. I was able to use api key and make a successful connection (code 200), but I’m struggling with identifying how to pull a larger date range. It seems that it is only pulling recent data and I think it’s pulling one row. I think I read I need to create a loop to extract more data? In any event, would love some direction on best practice to extract data from event API for mailgun. Thank you and happy holidays!

Hi @ebarr ,

This question sounds like it is about understanding the Mailgun REST API.

We’re here to help with KNIME-specific questions. However, this question is likely the same whether you’re using KNIME, Postman, or any other tool to make REST calls. It probably makes more sense to ask about Mailgun on a Mailgun forum, or by reaching out to the vendor directly.

You can search the KNIME Community Hub for existing workflows, though in this case I didn’t find anything for the search term “mailgun”.

Kind regards
Marvin

2 Likes

I’m new to using JSON and have limited experience with API requests. I have pulled a GET request for the MAILGUN platform (email platform). I added a JSON path node for the output, added my collection queries, then added an ungroup node and I’m seeing everything in a table. However, the data is only pulling data for today. In the API documentation, there are JSON calls that show how you can add a filter:

example -
Fetches the first page of log records that are older than Fri, 3 May 2013 09:00:00 -0000 and correspond to delivery to joe@example.com:
import com.mailgun.api.v3.MailgunEventsApi;
import com.mailgun.model.events.EventsQueryOptions;
import com.mailgun.model.events.EventsResponse;

import java.time.ZoneId;
import java.time.ZonedDateTime;

// …

public EventsResponse getEvents() {
MailgunEventsApi mailgunEventsApi = MailgunClient.config(API_KEY)
.createApi(MailgunEventsApi.class);

EventsQueryOptions eventsQueryOptions = EventsQueryOptions.builder()
    .begin(ZonedDateTime.now().minusDays(5))
    .ascending(true)
    .limit(1)
    .build();

return mailgunEventsApi.getEvents(YOUR_DOMAIN_NAME, eventsQueryOptions);

}

what I’m most interested in is the query builder that contains " .begin(ZonedDateTime.now().minusDays(5))" which lets the API pull everything from today and 5 days back. Where can I add this type of information into the GETReqeust node, or should there be another way to extract this information?

Hi @ebarr -

I merged your two threads, as they are both about Mailgun calls, to keep the forum tidy.

took some time, but I got the answer I was looking for…

the cURL was integrated into the URL in the GET node, and the additional points added as parameters:

https://api.mailgun.net/v3/domain.com/events?begin=Fri%2C%2025%20Dec%202023%2009%3A00%3A00%20-0000&ascending=yes&limit=300

First parameter follows a “?”, the next parameters follow and “&”. any spaces, commas, etc., use the %## format.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.