Query Member by email with Admin API

I am trying to query member by email address using Admin API. I tried using the @tryhost npm package to api.members.find({ email: 'xxx' }), but that didn’t work. Upon closer inspection, it actually didn’t even generate the right url.

I then try to make curl request to /ghost/api/v3/admin/members?email=xxx, also no dice.

Could someone please help? :slight_smile:

Try using this (haven’t tested): api.members.browse({filter: 'email:{{email}}'})

1 Like

it works! you are awesome :heart_eyes:

1 Like

Seems to be broken when email address contains a plus symbol: Can't fetch Members from API when email contains plus symbol · Issue #13277 · TryGhost/Ghost · GitHub

@james.kerber make sure you’re wrapping text strings in quotes, api.members.browse({filter: ‘email:"{{email}}"’}) so you’re not creating invalid filter queries.

2 Likes

Thank you! Didn’t know it was allowed, but it does fix the issue :slight_smile:

Hey @Kevin,

Thanks for helping out.

Shouldn’t the following work?

const member = await api.members.read({
  email: "john@example.net",
})

I am getting “Resource not found” error when using email associated to member.

Using id works as expected.

Found this while working on a member api request - agreed, it doesn’t work. api.members.read seems to be non-functional when called with email.

This works: api.members.browse({filter: `email: ${validatedEmail}`, limit:1})