Mailchimp API Key Regex

419 views
Skip to first unread message

bgetting

unread,
Nov 2, 2009, 11:51:19 PM11/2/09
to MailChimp API Discuss
We are developing an app that will connect with the Mailchimp API. Is
there a convenient way to validate an API key? Can you provide a regex
that will ensure that a submitted API is in the correct format?

jesse

unread,
Nov 3, 2009, 10:19:48 AM11/3/09
to MailChimp API Discuss
I would not recommend building a regex in for key validation since we
may very well change the keys we hand out in the future. A better
thing would be to link to this:
http://admin.mailchimp.com/account/api-key-popup
In a convenient place in your app and then use a lightweight method,
like ping() or getAccountDetails() to verify that the key works. You
can test the responses you'll get by sending either a completely bogus
key or expiring one of your test keys and passing it through.

If you really want to build a regex in to pre-validate the key, this
seems to work for now:
/^[0-9a-z]{32}(-us[12]{1})?$/
Obviously even if the pattern is correct you'll still need to verify
that it's valid and is not an expired key, so you should probably end
up building something like I mentioned initially anyway.


jesse
Reply all
Reply to author
Forward
0 new messages