Mailchimp API Get last campaign sent - mailchimp-api-v3.0

Is there any direct way to get the last campaign sent on a Mailchimp account via Mailchimp API V3?
So far the only way I found was to iterate over the campaigns and get the last one but it takes too much time.
Thanks in advance.

This is what I did:
/campaigns?sort_field=send_time&sort_dir=DESC&status=sent&count=1
Or for anyone who needs the last campaign from a particular folder:
/campaigns?folder_id=[FOLDER ID]&sort_field=send_time&sort_dir=DESC&status=sent&count=1

I don't think you can get only the last campaign sent using only one request, but you can achieve this by making two requests to the following endpoint
/campaigns
as described here. The parameters that you need are count, status, and offset.
For the first request, set the count parameter to 1 and status parameter to sent. You will get the first campaign sent, but you will also get total_items in the response body. The total_items indicates the total number of sent campaigns in your MailChimp account regardless of the pagination and that's what you need to make the second request.
For the second request, set the count parameter to 1, status parameter to sent, and offset parameter to the value of total_items above - 1. For example if the total_items from the first request is 150, then you should set offset to 149. Setting the offset parameter to 149 will skip the first 149 sent campaigns. The campaigns field in the response of the second request will contain the last campaign sent from your MailChimp account, which is what you're looking for. This will be much quicker than enumerating through all of the sent campaigns.

Related

Google Play Store Reviews API -- next page token not returned from 3rd request when retrieving reviews

I'm using this Google Play Store API to retrieve reviews: https://developers.google.com/android-publisher/api-ref/rest/v3/reviews/list
I was able to get OAuth2 authentication token, connect to the API endpoint, and get a list of reviews. For each request, I get 100 reviews. The app in question has about more than 300K reviews/ratings. However, I'm only able to grab 210 reviews.
In the first and second request to the API endpoint, I get a next page token (in the nextPageToken field) in the data. However, from the third request, the next page token is missing from the returned data.
First request: 100 reviews obtained; next page token issued
Second request: 100 reviews obtained; next page token issued
Third request: 10 reviews obtained; next page token NOT issued
Does anyone know why I don't get next page token from the third request to the API? I don't think I reached the "end" page, as I know there are over 300K reviews for the app.
Oh boy I forgot - reviews with no feedback won’t be pulled, ie: ratings only: ‘Also, note that the API shows only the reviews that include comments. If a user rates your app but does not provide a comment, their feedback is not accessible from the API.’ As Google puts it in their docs:
https://developers.google.com/android-publisher/reply-to-reviews
Possible many of the reviews your hitting may only be ratings - however, surprised you don’t have a next page token; when you dump the review post dates do you notice large gaps between the returned results in the 210? If so, could be the above is the reason.
—- Starting post before the above update —-
Since your limited to a MaxResults of 100 - I’d chunk it to see if I can get past the 210 returned results to see if it’s my calls timing out or anything if that nature - playing process of eliminations;
Loop this 5 times,
https://www.googleapis.com/androidpublisher/v3/applications/your_package_name/reviews?
access_token=your_auth_token&token=page_token&maxResults=50
Print the review IDs to console/page with a count, see if you break 250 even - if you do, don’t make 100 pills because for whatever reason it isn’t returning your requested data - could be the reviews aren’t “all published” with Google as I’ve experienced with GMB sometimes but often it could be server time outs, requesting an index far off the last index - can be anything until you rule it all out;
Pull 250 by max of 50s, that’s the best way to begin isolating IMO.

The public subscriber lists pages not matching batch size and total counts

I am trying to get a list of my public subscribers. When I execute the request below I get weird and inconsistent results. When I ask for a max result size of 50 I get two pages back, one with 27 and another with 9. Also when I look at my web page subscribers it says I only have 24 public subscribers. I have 95 total subscribers.
Why is it paging in buckets less than my max page size?
Why are the reported numbers so far off?
https://www.googleapis.com/youtube/v3/subscriptions?part=subscriberSnippet&mySubscribers=true&key=[MY_API_KEY]
According to the official docs, for to call the Subscriptions.list API endpoint with parameter mySubscribers=true you have to pass on to the endpoint proper authorization credentials:
mySubscribers (boolean)
This parameter can only be used in a properly authorized request. Set this parameter's value to true to retrieve a feed of the subscribers of the authenticated user in no particular order.
Therefore, passing on only an application key, via the parameter key, is not sufficient. If passing on proper authorization credentials (i.e. a valid access token), then the key parameter is superfluous.

How to perform load testing for many users?

I am new to jmeter, I am trying to do load testing for 20 users for the below scenario but facing some issues
There are 3 sequential url, in the first url.. request will be send and in the 3rd url the response message (response is processed) will be obtained.
So to obtain the response message we have to refresh the 3rd url i.e 3rd url will be refreshed until we get a response message like response is processed. If I am doing a load testing for 3 users. for first user the response message may be obtained at 3rd time refresh of 3rd url and for 2nd user it may be obtained at 5th time refresh similarly for 3rd user it may be obtained at 8th or 10th time refresh of 3rd url so we will be getting the response message at any n'th refresh of 3rd url.
On each HTTP request the sample time is calculated however i need to calculate how long for 1 user it takes i.e timetaken ,starting from the 1st request until the response message is obtained in 3rd url
There are 2 issues:
I am unaware of how can I set a condition to click on the 3rd url until response message is obtained.
How can I get the timetaken for 1 user for 3 url i.e from sending request in 1st url to obtaining response message in 3rd url instead of sample time for each url (http request)
Can somebody please help me with this issues
Put your "3rd url" request under While Controller and specify the condition in the way so the request will loop until response matches your expectations
You can measure the whole sequence execution time by putting all 3 requests under Transaction Controller

MailChimp API not displaying all the newsletters

I am using mailchimp to display all the newsletters in my webpage.
Am using this API call to get all newsletters, https://usX.api.mailchimp.com/3.0/campaigns
But am only getting 10 campaigns, but there are many more campaigns in the mailchimp account.
Is there anything wrong here?
How can I get all the newsletters or all campaign ids?
According to the official documentation of the /campaigns endpoint here, there is a count parameter that indicates the number of campaign records you want to return. The default value of the count parameter is 10. You're not passing any parameters to the /campaigns endpoint, so the default value of the count parameter (10) is used and that's why you only get 10 campaigns.
You can get all campaigns by making two API calls to the /campaigns endpoint. Make the first API call with count parameter set to 1. You will get only one campaign, but you will also get total_items in the response body. The value of total_items shows the total number of campaigns you currently have in your MailChimp account. The second API call should have count parameter set to the value of total_items obtained from the response of the first API call. You will get all campaigns in the response body of the second API call.

How to get message_id of emails sent using transmission?

We're moving from Mandrill to SparkPost. We figured that SparkPost's transmission is the closest thing to Mandrill's send-template message call.
Mandrill responded to those calls with a list of ids and statuses for each email. On the other hand SparkPost returns a single id and summary statistics (number of emails that were sent and number of emails that failed). Is there some way to get those ids and statuses out of the transmission response or at all?
you can get the message IDs for messages sent using the tranmissions API two ways:
Query the message events API, which allows you to filter by recipients, template IDs, campaign IDs, and other values
Use webhooks - messages are sent to your endpoint in batches, and each object in the batch contains the message ID
Which method you choose really depends on your use case. It's essentially poll (message events) vs. push (webhooks). There is no way to get the IDs when you send the transmission because they are sent asynchronously.
Querying message events API, while a viable option, would needlessly complicate our simple solution. On the other hand we very much want to use Webhooks, but not knowing which message they relate to would be troublesome...
The missing link was putting our own id in rcpt_meta. Most of the webhooks we care about do contain rcpt_meta, so we can substitute message_id with that.
I'm stacked too in this problem..
using rcpt_meta solution would be perfect if substitution would work on rcpt_meta but it's not the case.
So, in case of sending a campaign, I cannot specify all recipients inline but have to make a single API call for every message, wich is bad for - say - 10/100k recipients!
But now, all transmission_id are unique for every SINGLE recipient, so I have the missing key and rcpt_meta is not needed anymore.
so the key to be used when receiving a webhook is composed:
transmission_id **AND** rcpt_to

Resources