# Discrepancy in API data vs WebUI data

**URL:** https://meta.discourse.org/t/discrepancy-in-api-data-vs-webui-data/347920
**Category:** Data & reporting
**Created:** [January 19, 2025, 7:03pm UTC](https://meta.discourse.org/t/discrepancy-in-api-data-vs-webui-data/347920 "2025-01-19T19:03:59Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Shubham\_G](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shubham_g/32/482220_2.png) [@Shubham\_G](https://meta.discourse.org/u/Shubham_G)
#### Post date: [January 19, 2025, 7:04pm UTC](https://meta.discourse.org/t/discrepancy-in-api-data-vs-webui-data/347920/1 "2025-01-19T19:04:00Z")

</div>

I want to get the data of a specific user via API. Basically, I want to know how many replies the user gave since he joined the forum. I used the following code (basically I fetched all the user\_actions where the **action\_type=5** and then printed the number of such records). **The final output did not matched with what I see in the webUI.** Can anyone explain why this might be happening?

```plaintext
import requests, time

defaultHost = #your_default_host

# Headers for authentication
headers = {
    'Api-Key': #YOUR_API_KEY,
    'Api-Username':#YOUR_API_USERNAME
}

# increment the offset by 30 each time. The loop should break when the number of elements in the response is less than 30
offset = 0
data_dict ={"user_actions":[]}
username = #username_for_which_we_want_to_fetch_the_data

# filter=5 # For the "user_replied_to_a_topic"

while True:
    time.sleep(0.2)
    endpoint = f'https://{defaultHost}/user_actions.json?username={username}&offset={offset}&filter=5'
    # Make the request
    response = requests.get(endpoint, 
                            headers=headers)

    # Check the response
    if response.status_code == 200:
        data = response.json()
        num_elements = len(data["user_actions"])
        data_dict["user_actions"].extend(data["user_actions"])
        offset+=30
        if num_elements<30: 
            break    
    else:
        print(f'Error: {response.status_code}')
        break

print(len(data_dict["user_actions"]))

```

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [January 19, 2025, 7:27pm UTC](https://meta.discourse.org/t/discrepancy-in-api-data-vs-webui-data/347920/2 "2025-01-19T19:27:41Z")

</div>

Just a guess (didn’t have a look at the core files and database). Maybe one value takes the first posts (which are not replies) into account, whereas the other only returns replies.

Also, why don’t you use a [data explorer](https://meta.discourse.org/t/32566?silent=true) query to return this data? I think it would be way more convenient unless I’m missing something. 🤔

---

<div class="post-metadata">

### Author: ![Shubham\_G](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shubham_g/32/482220_2.png) [@Shubham\_G](https://meta.discourse.org/u/Shubham_G)
#### Post date: [January 20, 2025, 7:46am UTC](https://meta.discourse.org/t/discrepancy-in-api-data-vs-webui-data/347920/4 "2025-01-20T07:46:14Z")

</div>

> [@Canapin](#):
>
> one value takes the first posts (which are not replies) into account, whereas the other only returns replies.

Can you clarify which values are you talking about?

---

<div class="post-metadata">

### Author: ![Shubham\_G](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shubham_g/32/482220_2.png) [@Shubham\_G](https://meta.discourse.org/u/Shubham_G)
#### Post date: [January 20, 2025, 7:47am UTC](https://meta.discourse.org/t/discrepancy-in-api-data-vs-webui-data/347920/5 "2025-01-20T07:47:28Z")

</div>

> [@Canapin](#):
>
> why don’t you use a [data explorer](https://meta.discourse.org/t/32566?silent=true) query

Yes if the API doesn’t give correct output, then the [Data Explorer](https://meta.discourse.org/t/32566?silent=true) is the ultimate solution. But the bigger question is: Why the API and webUI doesn’t return exactly same data?

---

<div class="post-metadata">

### Author: ![Shubham\_G](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shubham_g/32/482220_2.png) [@Shubham\_G](https://meta.discourse.org/u/Shubham_G)
#### Post date: [January 20, 2025, 7:49am UTC](https://meta.discourse.org/t/discrepancy-in-api-data-vs-webui-data/347920/6 "2025-01-20T07:49:18Z")

</div>

> [@NateDhaliwal](#):
>
> you’ll need to set the username, offset and filter in the query.

yes, I have done it as you may see in the code I posted:

```plaintext
    endpoint = f'https://{defaultHost}/user_actions.json?username={username}&offset={offset}&filter=5'

```

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [January 20, 2025, 11:32am UTC](https://meta.discourse.org/t/discrepancy-in-api-data-vs-webui-data/347920/7 "2025-01-20T11:32:04Z")

</div>

> [@Shubham\_G](#):
>
> Can you clarify which values are you talking about?

1. The value returned by Discourse’s interface

2. The value returned by your script

> [@Shubham\_G](#):
>
> what I see in the webUI

On which page?
