Limited page_size at past dashboard meetings

Hi developers, by using a business account on ZOOM, My company asks me for a project to handle the course meetings per day at the zoom platform, but I have a problem with the (page-size) because sometimes I have more than 300 meetings per day.
please help me ASAP.

it’s JWT App

documentation Source: https://marketplace.zoom.us/docs/api-reference/zoom-api/dashboards/dashboardmeetings

The Endpoint :frowning:https://api.zoom.us/v2/metrics/meetings)

const superagent = require("superagent")

exports.handleMeetingsId = (req, res) => {
    let now = new Date();
    let nowDate = now.getDate()
    let nowMonth = now.getMonth()+1;
    let nowYear = now.getFullYear();
    let yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1, 0, 0, 0)
    let yesterdayDate = yesterday.getDate();
    let yesterdayMonth = yesterday.getMonth();
    let yesterdayYear = yesterday.getFullYear();

    let meetingIdArr = [];

    superagent
        .get('https://api.zoom.us/v2/metrics/meetings')
        .auth(process.env.JWT, { type: 'bearer' })
        .query({
            type: 'past',
            from: `${yesterdayYear}-${yesterdayMonth}-${yesterdayDate}`,
            to: `${yesterdayYear}-${yesterdayMonth}-${yesterdayDate}`,
            page_size: 300,
        })
        .then(response => {
            response.body.meetings.map(meeting => {
            let durationTime = meeting.duration;
            let durationInMilliSecands = durationTime.split(":").reduce((acc,durationTime) => ((60 * acc) + +durationTime) *1000);
         // ((60 * ((60 * HHHH) + MM)) + SS)*1000 // basically what happened
                    if(durationInMilliSecands > 600000){ // more than 10 min
                        meetingIdArr.push(meeting.id)
                    }
            })
        })
        .then(() => {
            res.send(meetingIdArr)
        })
}

Regards
As-har

Hi @asharoran96,

It sounds like the issue you’re running into is that you’re not able to see all your meetings in the response if there are more than 300 (your page_size)—is that right?

If so, I should clarify that you can use the next_page_token to page through the API results:

This parameter will be returned in your API response, and then you will need to make a subsequent request, appending the value from the first request as a query parameter to a second request. This will then return the next set of records.

Let me know if this helps to clarify,
Will

1 Like

Hi @will.zoom
yes I think your solution is very helpful
but I don’t know how to create a subsequent request
if you have any recourse, share it with me, please.

My code :

const handleMeetingsId = (req, res) => {

    let now = new Date();

    let nowDate = now.getDate()

    let nowMonth = now.getMonth();

    let nowYear = now.getFullYear();

    let yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1, 0, 0, 0)

    let yesterdayDate = yesterday.getDate();

    let yesterdayMonth = yesterday.getMonth();

    let yesterdayYear = yesterday.getFullYear();

    let meetingIdArr = [];

    let nextPageToken;

    console.log(nextPageToken)

    superagent

        .get('https://api.zoom.us/v2/metrics/meetings')

        .auth(process.env.JWT, { type: 'bearer' })

        .query({

            type: 'past',

            from: `${2020}-${10}-${27}`,

            to: `${2020}-${10}-${27}`,

            page_size: 300, // the maximam page number (ERROR)

            next_page_token: `${nextPageToken}`

        })

        .then(response => {

            nextPageToken = response.body.next_page_token

            // console.log(response.body.next_page_token).

            console.log("Data from-To" , response.body.from , "- to ", response.body.to);

            console.log(response.body.meetings.length)

            response.body.meetings.map(meeting => {

                let durationTime = meeting.duration;

                let durationInMilliSecands = durationTime.split(":").reduce((acc, durationTime) => ((60 * acc) + +durationTime) * 1000);

                // ((60 * ((60 * HHHH) + MM)) + SS)*1000 // basically what happened

                if (durationInMilliSecands > 600000) { // more than 10 min

                    meetingIdArr.push(meeting.id)

                }

            })

        })

        .then(() => {

            console.log(meetingIdArr.length)

            handleCoursesMeetings(meetingIdArr)

        })

        .catch(e => {

            console.log(e)

        })

}

Regards
As-har

Hi @asharoran96,

I would recommend doing a quick StackOverflow search to for pagination. For example, you might find this helpful:

Thanks,
Will

1 Like

@will.zoom @tommy

I did a research.

I’m using cron job in google cloud to get the data so my functionality should be dynamic.

but the thing is that how to pass next_page_token value from the body response (response.body.next_page_token) as a query parameter in API URL??
also each time we did a hit the token is changed ??!!

please help, I shared my code with you guys.

const handleMeetingsId = (req, res) => {

    let now = new Date();

    let nowDate = now.getDate()

    let nowMonth = now.getMonth();

    let nowYear = now.getFullYear();

    let yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1, 0, 0, 0)

    let yesterdayDate = yesterday.getDate();

    let yesterdayMonth = yesterday.getMonth();

    let yesterdayYear = yesterday.getFullYear();

    let meetingIdArr = [];

    let nextPageToken;

    console.log(nextPageToken)

    superagent

        .get('https://api.zoom.us/v2/metrics/meetings')

        .auth(process.env.JWT, { type: 'bearer' })

        .query({

            type: 'past',

            from: `${2020}-${10}-${27}`,

            to: `${2020}-${10}-${27}`,

            page_size: 300, // the maximam page number (ERROR)

            next_page_token: `${nextPageToken}`

        })

        .then(response => {

            nextPageToken = response.body.next_page_token

            // console.log(response.body.next_page_token).

            console.log("Data from-To" , response.body.from , "- to ", response.body.to);

            console.log(response.body.meetings.length)

            response.body.meetings.map(meeting => {

                let durationTime = meeting.duration;

                let durationInMilliSecands = durationTime.split(":").reduce((acc, durationTime) => ((60 * acc) + +durationTime) * 1000);

                // ((60 * ((60 * HHHH) + MM)) + SS)*1000 // basically what happened

                if (durationInMilliSecands > 600000) { // more than 10 min

                    meetingIdArr.push(meeting.id)

                }

            })

        })

        .then(() => {

            console.log(meetingIdArr.length)

            handleCoursesMeetings(meetingIdArr)

        })

        .catch(e => {

            console.log(e)

        })

}

Hi @asharoran96,

A new next_page_token value will be returned each time you call the API, so you will need to dynamically update this in your code with each request. You’ll need to append the new value each time to your request URL. For example:
https://api.zoom.us/v2/metrics/meetings?next_page_token={tokenValue}

I hope this helps to clarify!
Will

@will.zoom
yes, I tried this before.
It gave me undefined because.
the token value comes on the response body,
so how to pass value from the response as a path parameter

Note: we send API with it’s Parameters then we receive the response after hit the API.
the value of next_page_token on the response ??!!
so the value comes after hit API, this makes me confused
I tried to call the API twice as a subsequence request but the token changes every time we call the API !!
How to handle it ?? this is my point.

const handleMeetingsId = (req, res) => {
    // console.log(res)
    let now = new Date();
    let nowDate = now.getDate()
    let nowMonth = now.getMonth();
    let nowYear = now.getFullYear();
    let yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1, 0, 0, 0)
    let yesterdayDate = yesterday.getDate();
    let yesterdayMonth = yesterday.getMonth();
    let yesterdayYear = yesterday.getFullYear();

    let meetingIdArr = [];
    let pageSize = 300;
    let nextPageToken;

    request({
        method: "GET",
        url: `https://api.zoom.us/v2/metrics/meetings?next_page_token=${nextPageToken}`,
        headers: {
            'Authorization': `Bearer ${process.env.JWT}`,
        },
        qs: {
            type: 'past',
            from: `${2020}-${11}-${12}`,
            to: `${2020}-${11}-${12}`,
            page_size: 300, // the maximam page number (ERROR)
            
        }
    }, (e, res, body) => {
        // console.log(res.req.path)
        res = JSON.parse(body);
        nextPageToken = res.next_page_token
        // console.log()
        console.log(res)
    })
}

image
Now I receive this when I used this piece of code.

Regards

Hi @asharoran96,

I would recommend that when you parse the request response, you store the value of the next_page_token as a variable with a broader scope. It looks like your nextPageToken isn’t getting set correctly. When you console log this, is the value null?

Thanks,
Will

@will.zoom
if I put it on the border scope it will give me this

okay @will.zoom
I tried a different way of writing code :

require("dotenv").config();
const superagent = require("superagent")

const handleMeetingsId = (req, res) => {

    let meetingIdArr = [];
    let nextPageToken;
    superagent
        .get('https://api.zoom.us/v2/metrics/meetings')
        .auth(process.env.JWT, { type: 'bearer' })
        .query({
            type: 'past',
            from: `${2020}-${10}-${27}`,
            to: `${2020}-${10}-${27}`,
            page_size: 300
        })
        .then(response => {
            // console.log(response.body)
            nextPageToken = response.body.next_page_token;
            console.log(nextPageToken)
            superagent
                .get(`https://api.zoom.us/v2/metrics/meetings?next_page_token=${nextPageToken}`)
                .auth(process.env.JWT, { type: 'bearer' })
                .query({
                    type: 'past',
                    from: `${2020}-${10}-${27}`,
                    to: `${2020}-${10}-${27}`,
                    page_size: 300
                })
                .then(ress => {
                    console.log("secand token(): ", ress.body.next_page_token)
                    console.log(ress.body.meetings.length);
                    ress.body.meetings.map(meeting => {
                        let durationTime = meeting.duration;
                        let durationInMilliSecands = durationTime.split(":").reduce((acc, durationTime) => ((60 * acc) + +durationTime) * 1000);
                        // ((60 * ((60 * HHHH) + MM)) + SS)*1000 // basically what happened
                        if (durationInMilliSecands > 600000) { // more than 10 min
                            meetingIdArr.push(meeting.id)
                        }
                    })
                })
                .then(() => {
                    console.log(meetingIdArr.length)
                })
        })

}

handleMeetingsId()

i get this
image

on ZOOM documentation there is a point that each next_page_token takes 15 min to change but I noticed that it change each time i call the API.

please help me with my code because I tried a lot of ways and nothing helps.
I have to give my manager an answer if this problem can be solved or not ASAP.
the answer depends on your help.

Best regards
As-har

Hi @asharoran96,

on ZOOM documentation there is a point that each next_page_token takes 15 min to change but I noticed that it change each time i call the API.

The next page token is updated each time you call this endpoint. In the response, each time, a unique token is provided to help you access the next page of results. Each individual token will last 15 minutes before expiring. You should be storing the new token with each consecutive call and then passing that to the next request’s URL as a parameter.

If you’re still having trouble paging through the API results with the logic you currently have, I recommend posting your question on StackOverflow or another community forum where they can assist you with this best.

Thanks,
Will

Thanks, I Found the solution

I’m glad you were able to figure it out, @asharoran96! :100: