Skip to content

Commit

Permalink
Update REST pagination guide (#33197)
Browse files Browse the repository at this point in the history
Co-authored-by: Jess Hosman <[email protected]>
  • Loading branch information
skedwards88 and jhosman authored Dec 8, 2022
1 parent d630294 commit f97c163
Show file tree
Hide file tree
Showing 10 changed files with 190 additions and 422 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ For more information about the audit log REST API, see "[Enterprise administrati

### Example 1: All events in an enterprise, for a specific date, with pagination

You can use page-based pagination or cursor based pagination. For more information, see "[Traversing with Pagination](/rest/guides/traversing-with-pagination)."
You can use page-based pagination or cursor based pagination. For more information about pagination, see "[Using pagination in the REST API](/rest/guides/using-pagination-in-the-rest-api)."

#### Example with page-based pagination

The query below searches for audit log events created on Jan 1st, 2022 in the `avocado-corp` enterprise, and return the first page with a maximum of 100 items per page using [REST API pagination](/rest/overview/resources-in-the-rest-api#pagination):
The query below searches for audit log events created on Jan 1st, 2022 in the `avocado-corp` enterprise, and return the first page with a maximum of 100 items per page using pagination. For more information about pagination, see "[Using pagination in the REST API](/rest/guides/using-pagination-in-the-rest-api)."

```shell
curl -H "Authorization: Bearer TOKEN" \
Expand All @@ -131,7 +131,7 @@ curl -H "Authorization: Bearer TOKEN" \

#### Example with cursor-based pagination

The query below searches for audit log events created on Jan 1st, 2022 in the `avocado-corp` enterprise, and returns the first page with a maximum of 100 items per page using [REST API pagination](/rest/overview/resources-in-the-rest-api#pagination). The `--include` flag causes the headers to be returned along with the response.
The query below searches for audit log events created on Jan 1st, 2022 in the `avocado-corp` enterprise, and returns the first page with a maximum of 100 items per page using pagination. For more information about pagination, see "[Using pagination in the REST API](/rest/guides/using-pagination-in-the-rest-api)." The `--include` flag causes the headers to be returned along with the response.

```
curl --include -H "Authorization: Bearer TOKEN" \
Expand Down
2 changes: 1 addition & 1 deletion content/rest/guides/best-practices-for-integrators.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Often, API responses contain data in the form of URLs. For example, when request

For the stability of your app, you shouldn't try to parse this data or try to guess and construct the format of future URLs. Your app is liable to break if we decide to change the URL.

For example, when working with paginated results, it's often tempting to construct URLs that append `?page=<number>` to the end. Avoid that temptation. [Our guide on pagination](/guides/traversing-with-pagination) offers some safe tips on dependably following paginated results.
For example, when working with paginated results, it's often tempting to construct URLs that append `?page=<number>` to the end. Avoid that temptation. For more information about dependably following paginated results, see "[Using pagination in the REST API](/rest/guides/using-pagination-in-the-rest-api)."

## Check the event type and action before processing the event

Expand Down
5 changes: 2 additions & 3 deletions content/rest/guides/discovering-resources-for-a-user.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ In addition to having their own personal repositories, a user may be a collabora

[OAuth scopes][scopes] and [organization application policies][oap] determine which of those repositories your app can access for a user. Use the workflow below to discover those repositories.

As always, first we'll require [GitHub's Octokit.rb][octokit.rb] Ruby library. Then we'll configure Octokit.rb to automatically handle [pagination][pagination] for us.
As always, first we'll require [GitHub's Octokit.rb][octokit.rb] Ruby library. Then we'll configure Octokit.rb to automatically handle pagination for us. For more information about pagination, see "[Using pagination in the REST API](/rest/guides/using-pagination-in-the-rest-api)."

``` ruby
require 'octokit'
Expand Down Expand Up @@ -67,7 +67,7 @@ end

Applications can perform all sorts of organization-related tasks for a user. To perform these tasks, the app needs an [OAuth authorization][scopes] with sufficient permission. For example, the `read:org` scope allows you to [list teams][list-teams], and the `user` scope lets you [publicize the user’s organization membership][publicize-membership]. Once a user has granted one or more of these scopes to your app, you're ready to fetch the user’s organizations.

Just as we did when discovering repositories above, we'll start by requiring [GitHub's Octokit.rb][octokit.rb] Ruby library and configuring it to take care of [pagination][pagination] for us:
Just as we did when discovering repositories above, we'll start by requiring [GitHub's Octokit.rb][octokit.rb] Ruby library and configuring it to take care of pagination for us. For more information about pagination, see "[Using pagination in the REST API](/rest/guides/using-pagination-in-the-rest-api)."

``` ruby
require 'octokit'
Expand Down Expand Up @@ -105,7 +105,6 @@ As an application, you typically want all of the user's organizations that your
[make-authenticated-request-for-user]: /rest/guides/basics-of-authentication#making-authenticated-requests
[oap]: https://developer.github.com/changes/2015-01-19-an-integrators-guide-to-organization-application-policies/
[octokit.rb]: https://github.com/octokit/octokit.rb
[pagination]: /rest#pagination
[platform samples]: https://github.com/github/platform-samples/tree/master/api/ruby/discovering-resources-for-a-user
[publicize-membership]: /rest/reference/orgs#set-public-organization-membership-for-the-authenticated-user
[register-oauth-app]: /rest/guides/basics-of-authentication#registering-your-app
Expand Down
2 changes: 1 addition & 1 deletion content/rest/guides/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ children:
- /delivering-deployments
- /rendering-data-as-graphs
- /working-with-comments
- /traversing-with-pagination
- /using-pagination-in-the-rest-api
- /building-a-ci-server
- /best-practices-for-integrators
- /getting-started-with-the-git-database-api
Expand Down
Loading

0 comments on commit f97c163

Please sign in to comment.