From ac86bfc2fa1fd08d39b4d67ba6509a62daafb141 Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Sat, 24 Dec 2016 16:19:04 -0500 Subject: [PATCH 1/7] Draft section on ApiInfo in getting started --- docs/getting-started.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/getting-started.md b/docs/getting-started.md index e8fd5a16a9..171e74dd65 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -69,3 +69,22 @@ If you've authenticated as a given user, you can query their details directly: ``` var user = await client.User.Current(); ``` + +### Too Much of a Good Thing: Dealing with API Rate Limits +Like any popular API, Github needs to throttle some requests. The OctoKit.NET client allows you to get some insight into how many requests you have left and when you can start making requests again. It does this via the `ApiInfo` object and the `GetLastApiInfo()` method. + +Example usage: + +```csharp +var client; //Create the client up here + +// Prior to first API call, this will be null, because it only deals with the last call. +var apiInfo = client.GetLastApiInfo(); + +// If the ApiInfo isn't null, there will be a property called RateLimit +var rateLimit = apiInfo?.RateLimit; + +var howManyRequestsCanIMakePerHour = rateLimit?.Limit; +var howManyRequestsToIHaveLeft = rateLimit?.Remaining; +var whenDoesTheLimitReset = rateLimit?.Reset; +``` \ No newline at end of file From 307d4617e199cf509e17222ed2a6ba348965d2a7 Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Wed, 28 Dec 2016 16:55:14 -0500 Subject: [PATCH 2/7] typo: to --> do --- docs/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 171e74dd65..2307cca498 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -85,6 +85,6 @@ var apiInfo = client.GetLastApiInfo(); var rateLimit = apiInfo?.RateLimit; var howManyRequestsCanIMakePerHour = rateLimit?.Limit; -var howManyRequestsToIHaveLeft = rateLimit?.Remaining; +var howManyRequestsDoIHaveLeft = rateLimit?.Remaining; var whenDoesTheLimitReset = rateLimit?.Reset; ``` \ No newline at end of file From 7492a867e0dcf66c44008e1b309b3ba777e20504 Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Fri, 30 Dec 2016 08:56:09 -0500 Subject: [PATCH 3/7] Add link to github api --- docs/getting-started.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 2307cca498..7cc5dfa9b3 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -87,4 +87,6 @@ var rateLimit = apiInfo?.RateLimit; var howManyRequestsCanIMakePerHour = rateLimit?.Limit; var howManyRequestsDoIHaveLeft = rateLimit?.Remaining; var whenDoesTheLimitReset = rateLimit?.Reset; -``` \ No newline at end of file +``` + +For more information on the API and understanding rate limits, you may want to consult [the Github API docs on rate limits](https://developer.github.com/v3/rate_limit/). \ No newline at end of file From d7b35aa94f2c4fb5f482aba2e1fbd19ff210f170 Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Fri, 30 Dec 2016 08:58:39 -0500 Subject: [PATCH 4/7] Add note on authenticated client limits --- docs/getting-started.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/getting-started.md b/docs/getting-started.md index 7cc5dfa9b3..c883e0e4c9 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -89,4 +89,6 @@ var howManyRequestsDoIHaveLeft = rateLimit?.Remaining; var whenDoesTheLimitReset = rateLimit?.Reset; ``` +An authenticated client will have a higher limit than an anonymous client. + For more information on the API and understanding rate limits, you may want to consult [the Github API docs on rate limits](https://developer.github.com/v3/rate_limit/). \ No newline at end of file From 9d575a8203ce051972b8e7739fda37fe9bfc76c3 Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Sat, 31 Dec 2016 17:50:27 -0500 Subject: [PATCH 5/7] wording tweak --- docs/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index c883e0e4c9..de5039d94c 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -89,6 +89,6 @@ var howManyRequestsDoIHaveLeft = rateLimit?.Remaining; var whenDoesTheLimitReset = rateLimit?.Reset; ``` -An authenticated client will have a higher limit than an anonymous client. +An authenticated client will have a significantly higher limit than an anonymous client. For more information on the API and understanding rate limits, you may want to consult [the Github API docs on rate limits](https://developer.github.com/v3/rate_limit/). \ No newline at end of file From 4c242bddac07861eb5ab6ed923aac288e62a6216 Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Sat, 31 Dec 2016 17:50:46 -0500 Subject: [PATCH 6/7] Point to better API doc link --- docs/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index de5039d94c..23efc2fc7e 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -91,4 +91,4 @@ var whenDoesTheLimitReset = rateLimit?.Reset; An authenticated client will have a significantly higher limit than an anonymous client. -For more information on the API and understanding rate limits, you may want to consult [the Github API docs on rate limits](https://developer.github.com/v3/rate_limit/). \ No newline at end of file +For more information on the API and understanding rate limits, you may want to consult [the Github API docs on rate limits](https://developer.github.com/v3/#rate-limiting). \ No newline at end of file From c44777cec68a7187de30d12e8b2365caeb2ed947 Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Sat, 31 Dec 2016 17:53:13 -0500 Subject: [PATCH 7/7] change variable init in code sample --- docs/getting-started.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 23efc2fc7e..ce58fe6ed3 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -76,7 +76,8 @@ Like any popular API, Github needs to throttle some requests. The OctoKit.NET cl Example usage: ```csharp -var client; //Create the client up here +GithubClient client; +//Create & initialize the client here // Prior to first API call, this will be null, because it only deals with the last call. var apiInfo = client.GetLastApiInfo();