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 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.
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)
})
}
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)
})
}
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}
@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)
})
}
Now I receive this when I used this piece of code.
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?
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.
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.