# Accessing the Data API using a token

**URL:** <https://forum.bubble.io/t/accessing-the-data-api-using-a-token/307123>\
**Category:** Bugs\
**Created:** [February 12, 2024, 1:11pm UTC](https://forum.bubble.io/t/accessing-the-data-api-using-a-token/307123 "2024-02-12T13:11:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![christina.sandberg](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/christina.sandberg/32/138547_2.png) [@christina.sandberg](https://forum.bubble.io/u/christina.sandberg)\
**Post date:** [February 12, 2024, 1:11pm UTC](https://forum.bubble.io/t/accessing-the-data-api-using-a-token/307123/1 "2024-02-12T13:11:57Z")

</div>

hi,  
I think I have discovered a “newly introduced” bug.

I am accessing an endpoint “as an admin with a token”. However the private fields are not included in the response as they should be per the documentation.

When making the fields non-private ; they are included.

---

<div class="post-metadata">

**Author:** ![georgecollier](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/georgecollier/32/182327_2.png) [@georgecollier](https://forum.bubble.io/u/georgecollier)\
**Post date:** [February 12, 2024, 1:16pm UTC](https://forum.bubble.io/t/accessing-the-data-api-using-a-token/307123/2 "2024-02-12T13:16:57Z")

</div>

What does your API call look like?

---

<div class="post-metadata">

**Author:** ![christina.sandberg](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/christina.sandberg/32/138547_2.png) [@christina.sandberg](https://forum.bubble.io/u/christina.sandberg)\
**Post date:** [February 12, 2024, 1:23pm UTC](https://forum.bubble.io/t/accessing-the-data-api-using-a-token/307123/3 "2024-02-12T13:23:40Z")

</div>

def retrieve\_activity\_data(endpoint, headers, start\_date, end\_date, club):  
activity\_list =   
cursor = 0 # Start at the first record  
limit = 100

```
while True:
    params = {'cursor': cursor, 'limit': limit}
    if start_date and end_date:
        params['StartDate_gte'] = start_date
        params['EndDate_lte'] = end_date
    response = requests.get(endpoint, headers=headers, params=params).json()

    if 'response' not in response:
        print(f"Cursor: {cursor}, Limit: {limit}, No 'response' in the JSON returned from {endpoint} "
              f"with params {params}")
        break

    activities = response['response']['results']
    remaining = response['response']['remaining']

    if not activities:
        print(f"Cursor: {cursor}, Limit: {limit}, Activities are empty")
        break

    filtered_activities = [activity for activity in activities if activity.get('StartDate') is not None and
                           activity.get('RegisteredTime') is not None and activity.get('Club') == club]
    print(f"Cursor: {cursor}, Limit: {limit}, Total activities: {len(activities)}, "
          f"Filtered activities: {len(filtered_activities)}")

    activity_list.extend(filtered_activities)

    if remaining == 0:
        break
    else:
        cursor += len(activities) # Move the cursor to the position of next result

print(activity_list)
return activity_list

```

---

<div class="post-metadata">

**Author:** ![georgecollier](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/georgecollier/32/182327_2.png) [@georgecollier](https://forum.bubble.io/u/georgecollier)\
**Post date:** [February 12, 2024, 1:24pm UTC](https://forum.bubble.io/t/accessing-the-data-api-using-a-token/307123/4 "2024-02-12T13:24:42Z")

</div>

Where are you providing the authentication / admin token? That’s the relevant part 🙂

---

<div class="post-metadata">

**Author:** ![christina.sandberg](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/christina.sandberg/32/138547_2.png) [@christina.sandberg](https://forum.bubble.io/u/christina.sandberg)\
**Post date:** [February 12, 2024, 1:25pm UTC](https://forum.bubble.io/t/accessing-the-data-api-using-a-token/307123/5 "2024-02-12T13:25:54Z")

</div>

headers = {  
“Authorization”: f"Bearer xxxxxxxxxxxxxxxxxxxx",  
“Content-Type”: “application/json”,  
}

I guess this is what you mean 🙂

---

<div class="post-metadata">

**Author:** ![georgecollier](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/georgecollier/32/182327_2.png) [@georgecollier](https://forum.bubble.io/u/georgecollier)\
**Post date:** [February 12, 2024, 1:32pm UTC](https://forum.bubble.io/t/accessing-the-data-api-using-a-token/307123/6 "2024-02-12T13:32:16Z")

</div>

Hmmm, looks good to me 🤷‍♂️ Other things might be to check you’re calling the test version, and to triple check your admin API key is valid (though I think Bubble returns an error if it’s not)

---

<div class="post-metadata">

**Author:** ![christina.sandberg](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/christina.sandberg/32/138547_2.png) [@christina.sandberg](https://forum.bubble.io/u/christina.sandberg)\
**Post date:** [February 12, 2024, 1:40pm UTC](https://forum.bubble.io/t/accessing-the-data-api-using-a-token/307123/7 "2024-02-12T13:40:08Z")

</div>

I have worked with this API for a long time so and it used to work.  
I have triple checked the API Key and I know I am calling the version-test endpoint.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [February 26, 2024, 1:12pm UTC](https://forum.bubble.io/t/accessing-the-data-api-using-a-token/307123/8 "2024-02-26T13:12:22Z")

</div>

This topic was automatically closed after 14 days. New replies are no longer allowed.
