# Pulling Emails via API

**URL:** https://meta.discourse.org/t/pulling-emails-via-api/380701
**Category:** Support
**Tags:** rest-api
**Created:** [August 28, 2025, 9:25am UTC](https://meta.discourse.org/t/pulling-emails-via-api/380701 "2025-08-28T09:25:13Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Joe\_F](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@Joe\_F](https://meta.discourse.org/u/Joe_F)
#### Post date: [August 28, 2025, 9:25am UTC](https://meta.discourse.org/t/pulling-emails-via-api/380701/1 "2025-08-28T09:25:13Z")

</div>

Hi all,

I have set up a pipeline that pulls in all user information but the option to pull in their email is not available.

I have an admin role and the API key, etc, can I set this up, if so how? I want to add this column in a table for all users not a one off user query.

Kind regards, Joe

---

<div class="post-metadata">

### Author: ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)
#### Post date: [August 28, 2025, 9:38am UTC](https://meta.discourse.org/t/pulling-emails-via-api/380701/2 "2025-08-28T09:38:09Z")

</div>

Interestingly, something like `/admin/users/{id}.json` doesn’t return the user’s email as part of the response, but [getting a list of users](https://docs.discourse.org/#tag/Admin/operation/adminListUsers) (`/admin/users/list/{flag}.json`) does. If you pass a parameter like `username`, you can probably get the specific user.

---

<div class="post-metadata">

### Author: ![Joe\_F](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@Joe\_F](https://meta.discourse.org/u/Joe_F)
#### Post date: [August 28, 2025, 1:07pm UTC](https://meta.discourse.org/t/pulling-emails-via-api/380701/3 "2025-08-28T13:07:25Z")

</div>

I want to get a full list of users, their activity on the community and have their email also, it seems it is not an option though.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [August 28, 2025, 3:36pm UTC](https://meta.discourse.org/t/pulling-emails-via-api/380701/4 "2025-08-28T15:36:46Z")

</div>

The [data explorer](https://meta.discourse.org/t/32566?silent=true) plugin is probably the way to do that. And then you can request a particular query via the API.

---

<div class="post-metadata">

### Author: ![Joe\_F](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@Joe\_F](https://meta.discourse.org/u/Joe_F)
#### Post date: [September 2, 2025, 1:17pm UTC](https://meta.discourse.org/t/pulling-emails-via-api/380701/5 "2025-09-02T13:17:17Z")

</div>

Thanks, I had not seen this before, but seems this is not possible there unless I am missing something!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 2, 2025, 1:30pm UTC](https://meta.discourse.org/t/pulling-emails-via-api/380701/6 "2025-09-02T13:30:58Z")

</div>

> [@Joe\_F](#):
>
> seems this is not possible there unless I am missing something!

You could probably search here and find some examples or at [ask.discourse.com](http://ask.discourse.com), I asked

> [@On another topic](https://meta.discourse.org/t/13832/1):
>
> I want to get a full list of users, their activity on the community and have their email using the [data explorer](https://meta.discourse.org/t/32566?silent=true) plugin and then pull that result with the api

I’m unclear about who this link can work for:  
[https://ask.discourse.com/discourse-ai/ai-bot/shared-ai-conversations/oeofVCGwHrYuzKrtLV6PeQ](https://ask.discourse.com/discourse-ai/ai-bot/shared-ai-conversations/oeofVCGwHrYuzKrtLV6PeQ)

> [@On another topic](https://meta.discourse.org/t/13832/2):
>
> ### 1. **Create a [Data Explorer](https://meta.discourse.org/t/32566?silent=true) Query**
> 
> As an admin, create your query in `/admin/plugins/explorer`. For example, to fetch username, email, and activity information:
> 
> ```plaintext
> SELECT 
> u.id AS user_id,
> u.username,
> u.email,
> u.created_at,
> u.last_seen_at,
> u.active,
> u.trust_level,
> (
> SELECT COUNT(*)
> FROM posts p
> WHERE p.user_id = u.id
> ) AS post_count,
> (
> SELECT COUNT(*)
> FROM topics t
> WHERE t.user_id = u.id
> ) AS topic_count
> FROM users u
> WHERE u.id > 0
> ORDER BY u.created_at DESC
> 
> ```

> [@On another topic](https://meta.discourse.org/t/13832/2):
>
> ### 2. **Run the Query via the API**
> 
> - Find your query ID in the [Data Explorer](https://meta.discourse.org/t/32566?silent=true) UI.
> - Run your query using a POST request to `/admin/plugins/explorer/queries/{query_id}/run`.
> 
> **Example cURL:**
> 
> ```plaintext
> curl -X POST "https://your-site-url/admin/plugins/explorer/queries/{query_id}/run" \
> -H "Content-Type: application/json" \
> -H "Api-Key: YOUR_API_KEY" \
> -H "Api-Username: system" \
> -d '{"params":{}}'
> 
> ```
> 
> - Results will be returned as JSON (default).
> - To remove extra relations data, add `-F "download=true"` or equivalent.

---

<div class="post-metadata">

### Author: ![Joe\_F](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@Joe\_F](https://meta.discourse.org/u/Joe_F)
#### Post date: [September 2, 2025, 1:47pm UTC](https://meta.discourse.org/t/pulling-emails-via-api/380701/7 "2025-09-02T13:47:03Z")

</div>

Solved it thanks!

You have been amazing!

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [October 2, 2025, 1:47pm UTC](https://meta.discourse.org/t/pulling-emails-via-api/380701/8 "2025-10-02T13:47:40Z")

</div>

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