Fname code mailchimp
You're looking for the Mailchimp API code to fetch a list of subscribers by their first name (fname).
Here's an example of how you can do it using the Mailchimp API:
Using the Mailchimp API v3
You'll need to replace the placeholders with your actual Mailchimp API key and list ID.
curl -X GET \
https://us19.api.mailchimp.com/3.0/lists/{LIST_ID}/members?fields=fname&count=100 \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json'
In this example, we're making a GET request to the members
endpoint, specifying the LIST_ID
and fields
parameter to retrieve only the fname
field. We're also setting the count
parameter to 100 to retrieve 100 subscribers at a time.
Using the Mailchimp API v3 with Python
You can use the mailchimp3
library in Python to make the API call. Here's an example:
import mailchimp3
api = mailchimp3.Mailchimp('YOUR_API_KEY')
list_id = 'your_list_id'
fields = ['fname']
count = 100
response = api.lists.members.get(list_id, fields=fields, count=count)
for member in response['members']:
print(member['fname'])
Using the Mailchimp API v3 with JavaScript
You can use the mailchimp
library in JavaScript to make the API call. Here's an example:
const mailchimp = require('mailchimp');
const apiKey = 'YOUR_API_KEY';
const listId = 'your_list_id';
const fields = ['fname'];
const count = 100;
mailchimp.lists.members.get(listId, { fields, count }, (err, response) => {
if (err) {
console.error(err);
} else {
response.members.forEach((member) => {
console.log(member.fname);
});
}
});
Make sure to replace the placeholders with your actual Mailchimp API key and list ID.