---
title: Paginated Requests
slug: docs/paginated-requests
docTags: 
createdAt: 2022-04-13T19:21:54.000Z
---

Several calls in the API return large lists of items. In order to moderate bandwidth, the API will break up these returns into smaller sets, and you will have to make multiple calls in order to collect all of the information. The limit per page is 50 items.&#x20;

# Code Samples

The code samples below will show you how to paginate through a `get_user_list` call.&#x20;

## Inspecting the basic return

First, if you're unsure of the amount of users which will be included in the return, you can begin by making the call with `starting_position` not included in `doc`.  This will give you information on what you can expect from the return.&#x20;

```python
import requests
import json
users_endpoint = https://www.regpack.com/reg/api2/users/
headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Api-Id": "15263",
    "Api-user": "api_admin@regpacks.com",
    "Api-Token": "cd2e514f-7gab-3cde-62fg-51abcd4e7362",
}
payload = {
    "action": "get_user_list",
    "group_id": 100909072,
    "doc": {
    }
}

get_user_list_json = json.dumps(payload)
get_user_list_response = requests.post(url=users_endpoint, 
                               data=get_user_list_json, 
                               headers=headers, 
                               timeout=10)
```

In the top of the response, `total_users` will show you the total number of users in the return, while `records_per_page` will tell you how many will be included in each page.

```json
{
    "totals": {
        "total_users": 222,
        "total_order": "0.00",
        "total_paid": "0.00",
        "total_balance": "0.00",
        "records_per_page": "50",
        "balance": 0,
        "total_children": 8,
        "label": "families",
        "group_type": 1
    }
}

```

## Making the paginated call

The things to note here are that you need to increment `starting_position` for each call. Inside the loop, this variable is updated within `payload`, and the parent and child users are added to the dictionary `final_return`. total users is the continuationof the previous code snippet.&#x20;

```python
import requests
import json

group_id = 100908752
api_id = "23366"
api_user = "rpapi+roger_1@regpacks.com"
api_token = "17387d82-e648-479d-89ca-0f4df7e0c0b8"
users_endpoint = 'https://www.regpack.com/reg/api2/users/'
status_endpoint = 'https://www.regpack.com/reg/api2/statuses/'
headers = {'Content-Type': 'application/json',
           'Accept': 'application/json',
           'Api-Id': api_id,
           'Api-user': api_user,
           'Api-Token': api_token}

payload = {
    "action": "get_user_list",
    "group_id": group_id,
    "doc": {
        "starting_position": 1
    }
}

total_users = 222
records_per_page = 50
calls_required_to_get_complete_list = total_users // records_per_page + 1  # // is the Floor division operator
pages = range(1, calls_required_to_get_complete_list+1) # range's in python are exclusive, so add one

parent_users = []
child_users = []
final_return = {}

for page in pages:
    if page == 1:
        payload["doc"]["starting_position"] = 0
    if page != 1:
        payload["doc"]["starting_position"] = payload["doc"]["starting_position"] + records_per_page
    
    get_user_list_json = json.dumps(payload)
    get_user_list_response = requests.post(url=users_endpoint,
                                    data=get_user_list_json,
                                    headers=headers,
                                    timeout=10)
    json_results = get_user_list_response.json()
    if "users" in json_results.keys():
        parent_users.extend(json_results["users"])
    if "children" in json_results.keys():
        child_users.extend(json_results["children"])

final_return.update({"users": parent_users, "children": child_users})

print(json.dumps(final_return, indent=4))

```

And here would be the ouput (truncated).

```json
{
    "users": [
        {
            "u_name": "Miles Davis Quintet",
            "total_forms": "2",
            "completed_forms": "0",
            "total_user_forms": "2",
            "total_completed_user_forms": "0",
            "total_user_mandatory_forms": "2",
            "total_completed_user_mandatory_forms": "0",
            "total_order": "0.00",
            "total_paid": "0.00",
            "total_balance": "0.00",
            "user_has_saved_payment_method": "-1",
            "total_items_in_cart": "-1",
            "status_id": "75771",
            "status_name": "confirmed attending",
            "status_color": "#89bb1f",
            "application_date": "Oct 23rd 2021 20:28",
            "application_date_raw": "2021-10-23 20:28:21",
            "u_comments": "0",
            "group_id": "100908752",
            "uid": "4030267",
            "clogin_id": "102670540",
            "excluded": "0",
            "connected_to": "102670540",
            "total_user_tags": "0",
            "user_tag_ids": null,
            "total_non_excluded_children": "5",
            "star": "0",
            "admin_initials": null,
            "admin_color": null,
            "assigned_admin_id": null
        },
        {
            "u_name": "Ed Bickert Trio",
            "total_forms": "2",
            "completed_forms": "0",
            "total_user_forms": "2",
            "total_completed_user_forms": "0",
            "total_user_mandatory_forms": "2",
            "total_completed_user_mandatory_forms": "0",
            "total_order": "0.00",
            "total_paid": "0.00",
            "total_balance": "0.00",
            "user_has_saved_payment_method": "-1",
            "total_items_in_cart": "-1",
            "status_id": "0",
            "status_name": null,
            "status_color": null,
            "application_date": "Oct 23rd 2021 20:22",
            "application_date_raw": "2021-10-23 20:22:58",
            "u_comments": "0",
            "group_id": "100908752",
            "uid": "4030262",
            "clogin_id": "102670535",
            "excluded": "0",
            "connected_to": "102670535",
            "total_user_tags": "0",
            "user_tag_ids": null,
            "total_non_excluded_children": "3",
            "star": "0",
            "admin_initials": null,
            "admin_color": null,
            "assigned_admin_id": null
        }
    ],
    "children": [
        {
            "u_name": "Ed Bickert",
            "total_forms": "7",
            "completed_forms": "0",
            "total_user_forms": "7",
            "total_completed_user_forms": "0",
            "total_user_mandatory_forms": "7",
            "total_completed_user_mandatory_forms": "0",
            "total_order": "0.00",
            "total_paid": "0.00",
            "total_balance": "0.00",
            "user_has_saved_payment_method": "-1",
            "total_items_in_cart": "0",
            "status_id": "0",
            "status_name": null,
            "status_color": null,
            "application_date": "Oct 23rd 2021 20:23",
            "application_date_raw": "2021-10-23 20:23:34",
            "u_comments": "0",
            "group_id": "100908752",
            "uid": "4030263",
            "clogin_id": "102670536",
            "excluded": "0",
            "connected_to": "102670535",
            "total_user_tags": "0",
            "user_tag_ids": null,
            "total_non_excluded_children": null,
            "star": "0",
            "admin_initials": null,
            "admin_color": null,
            "assigned_admin_id": null
        },
        {
            "u_name": "Don Thompson",
            "total_forms": "7",
            "completed_forms": "0",
            "total_user_forms": "7",
            "total_completed_user_forms": "0",
            "total_user_mandatory_forms": "7",
            "total_completed_user_mandatory_forms": "0",
            "total_order": "0.00",
            "total_paid": "0.00",
            "total_balance": "0.00",
            "user_has_saved_payment_method": "-1",
            "total_items_in_cart": "-1",
            "status_id": "0",
            "status_name": null,
            "status_color": null,
            "application_date": "Oct 23rd 2021 20:24",
            "application_date_raw": "2021-10-23 20:24:39",
            "u_comments": "0",
            "group_id": "100908752",
            "uid": "4030264",
            "clogin_id": "102670537",
            "excluded": "0",
            "connected_to": "102670535",
            "total_user_tags": "0",
            "user_tag_ids": null,
            "total_non_excluded_children": null,
            "star": "0",
            "admin_initials": null,
            "admin_color": null,
            "assigned_admin_id": null
        },
        {
            "u_name": "Terry Clarke",
            "total_forms": "7",
            "completed_forms": "0",
            "total_user_forms": "7",
            "total_completed_user_forms": "0",
            "total_user_mandatory_forms": "7",
            "total_completed_user_mandatory_forms": "0",
            "total_order": "0.00",
            "total_paid": "0.00",
            "total_balance": "0.00",
            "user_has_saved_payment_method": "-1",
            "total_items_in_cart": "-1",
            "status_id": "0",
            "status_name": null,
            "status_color": null,
            "application_date": "Oct 23rd 2021 20:25",
            "application_date_raw": "2021-10-23 20:25:26",
            "u_comments": "0",
            "group_id": "100908752",
            "uid": "4030265",
            "clogin_id": "102670538",
            "excluded": "0",
            "connected_to": "102670535",
            "total_user_tags": "0",
            "user_tag_ids": null,
            "total_non_excluded_children": null,
            "star": "0",
            "admin_initials": null,
            "admin_color": null,
            "assigned_admin_id": null
        },
        {
            "u_name": "Miles Davis",
            "total_forms": "7",
            "completed_forms": "0",
            "total_user_forms": "7",
            "total_completed_user_forms": "0",
            "total_user_mandatory_forms": "7",
            "total_completed_user_mandatory_forms": "0",
            "total_order": "0.00",
            "total_paid": "0.00",
            "total_balance": "0.00",
            "user_has_saved_payment_method": "-1",
            "total_items_in_cart": "-1",
            "status_id": "0",
            "status_name": null,
            "status_color": null,
            "application_date": "Oct 23rd 2021 20:28",
            "application_date_raw": "2021-10-23 20:28:59",
            "u_comments": "0",
            "group_id": "100908752",
            "uid": "4030268",
            "clogin_id": "102670541",
            "excluded": "0",
            "connected_to": "102670540",
            "total_user_tags": "0",
            "user_tag_ids": null,
            "total_non_excluded_children": null,
            "star": "0",
            "admin_initials": null,
            "admin_color": null,
            "assigned_admin_id": null
        },
        {
            "u_name": "Wayne Shorter",
            "total_forms": "7",
            "completed_forms": "0",
            "total_user_forms": "7",
            "total_completed_user_forms": "0",
            "total_user_mandatory_forms": "7",
            "total_completed_user_mandatory_forms": "0",
            "total_order": "0.00",
            "total_paid": "0.00",
            "total_balance": "0.00",
            "user_has_saved_payment_method": "-1",
            "total_items_in_cart": "-1",
            "status_id": "0",
            "status_name": null,
            "status_color": null,
            "application_date": "Oct 23rd 2021 20:31",
            "application_date_raw": "2021-10-23 20:31:13",
            "u_comments": "0",
            "group_id": "100908752",
            "uid": "4030269",
            "clogin_id": "102670542",
            "excluded": "0",
            "connected_to": "102670540",
            "total_user_tags": "0",
            "user_tag_ids": null,
            "total_non_excluded_children": null,
            "star": "0",
            "admin_initials": null,
            "admin_color": null,
            "assigned_admin_id": null
        },
        {
            "u_name": "Herbie Hancock",
            "total_forms": "7",
            "completed_forms": "0",
            "total_user_forms": "7",
            "total_completed_user_forms": "0",
            "total_user_mandatory_forms": "7",
            "total_completed_user_mandatory_forms": "0",
            "total_order": "0.00",
            "total_paid": "0.00",
            "total_balance": "0.00",
            "user_has_saved_payment_method": "-1",
            "total_items_in_cart": "-1",
            "status_id": "0",
            "status_name": null,
            "status_color": null,
            "application_date": "Oct 23rd 2021 20:31",
            "application_date_raw": "2021-10-23 20:31:14",
            "u_comments": "0",
            "group_id": "100908752",
            "uid": "4030270",
            "clogin_id": "102670543",
            "excluded": "0",
            "connected_to": "102670540",
            "total_user_tags": "0",
            "user_tag_ids": null,
            "total_non_excluded_children": null,
            "star": "0",
            "admin_initials": null,
            "admin_color": null,
            "assigned_admin_id": null
        },
        {
            "u_name": "Ron Carter",
            "total_forms": "7",
            "completed_forms": "0",
            "total_user_forms": "7",
            "total_completed_user_forms": "0",
            "total_user_mandatory_forms": "7",
            "total_completed_user_mandatory_forms": "0",
            "total_order": "0.00",
            "total_paid": "0.00",
            "total_balance": "0.00",
            "user_has_saved_payment_method": "-1",
            "total_items_in_cart": "-1",
            "status_id": "0",
            "status_name": null,
            "status_color": null,
            "application_date": "Oct 23rd 2021 20:32",
            "application_date_raw": "2021-10-23 20:32:32",
            "u_comments": "0",
            "group_id": "100908752",
            "uid": "4030271",
            "clogin_id": "102670544",
            "excluded": "0",
            "connected_to": "102670540",
            "total_user_tags": "0",
            "user_tag_ids": null,
            "total_non_excluded_children": null,
            "star": "0",
            "admin_initials": null,
            "admin_color": null,
            "assigned_admin_id": null
        },
        {
            "u_name": "Tony Williams",
            "total_forms": "7",
            "completed_forms": "0",
            "total_user_forms": "7",
            "total_completed_user_forms": "0",
            "total_user_mandatory_forms": "7",
            "total_completed_user_mandatory_forms": "0",
            "total_order": "0.00",
            "total_paid": "0.00",
            "total_balance": "0.00",
            "user_has_saved_payment_method": "-1",
            "total_items_in_cart": "-1",
            "status_id": "0",
            "status_name": null,
            "status_color": null,
            "application_date": "Oct 23rd 2021 20:33",
            "application_date_raw": "2021-10-23 20:33:10",
            "u_comments": "0",
            "group_id": "100908752",
            "uid": "4030272",
            "clogin_id": "102670545",
            "excluded": "0",
            "connected_to": "102670540",
            "total_user_tags": "0",
            "user_tag_ids": null,
            "total_non_excluded_children": null,
            "star": "0",
            "admin_initials": null,
            "admin_color": null,
            "assigned_admin_id": null
        }
    ]
}

```

