구현: 페이지로 나누기
다음 예는 YouTube Data API (v3) 쿼리에 대한 결과 세트를 추가로 검색하는 방법을 보여줍니다.
API는 maxResults
매개변수를 사용하여 API 응답에 포함해야 하는 항목 수를 나타냅니다. 거의 모든 API의 list
메서드 (videos.list
, playlists.list
등)가 이 매개변수를 지원합니다.
쿼리에 추가 결과를 사용할 수 있는 경우 API 응답에 nextPageToken
속성, prevPageToken
속성 또는 둘 다 포함됩니다. 그런 다음 이러한 속성 값을 사용하여 pageToken
매개변수를 설정하여 결과 페이지를 추가로 가져올 수 있습니다.
예를 들어 다음 쿼리는 '스케이트보딩 강아지' 검색어와 일치하는 조회수가 가장 높은 동영상 10개의 검색 결과를 가져옵니다.
https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?
part=snippet
&maxResults=10
&order=viewCount
&q=skateboarding+dog
&type=video
API 응답에는 검색어의 첫 번째 10개 일치 항목과 다음 10개 결과를 검색하는 데 사용할 수 있는 nextPageToken
속성이 포함됩니다.
아래 쿼리는 쿼리의 다음 10개 결과를 검색합니다.
https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?
part=snippet
&maxResults=10
&order=viewCount
&pageToken=CAoQAA
&q=skateboarding+dog
&type=video
참고: API 탐색기에서 이 요청을 완료하려면 pageToken
매개변수의 값을 업데이트해야 할 수 있습니다. 첫 10개의 결과를 검색하는 쿼리를 실행하여 올바른 pageToken
매개변수 값을 가져옵니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2024-11-23(UTC)
[null,null,["최종 업데이트: 2024-11-23(UTC)"],[[["The YouTube Data API (v3) uses the `maxResults` parameter to determine the number of items returned in a query response."],["API `list` methods, such as `videos.list` and `playlists.list`, support the `maxResults` parameter for pagination."],["If more results are available, the API response includes `nextPageToken` and/or `prevPageToken` properties."],["These token values can be used to set the `pageToken` parameter to retrieve additional result pages."],["The initial request fetches the first page of results, and subsequent requests use the `pageToken` from the previous response to get the next page of results."]]],["The YouTube Data API (v3) uses `maxResults` to specify the number of items in a response. `list` methods support this, and responses with additional results include `nextPageToken` or `prevPageToken`. These tokens, used with the `pageToken` parameter, retrieve further result sets. For instance, a query can get 10 most viewed videos, and a `nextPageToken` in the response allows fetching the next 10 by adding this value in the `pageToken` parameter.\n"]]