title: How can I get the list of the active users and their commits in the repository in the given time period via github API?
body: <p>I need to get the logins of the active users (max 30) and the number of their commits in a given period of time in a particular branch of the repository using github API v3 (<a href="https://developer.github.com/v3/" rel="nofollow noreferrer">https://developer.github.com/v3/</a>) and the standard python libraries. I studied general api documentation, and <a href="https://developer.github.com/v3/repos/" rel="nofollow noreferrer">https://developer.github.com/v3/repos/</a> and <a href="https://developer.github.com/v3/search/" rel="nofollow noreferrer">https://developer.github.com/v3/search/</a> articles in particular, but I couldn't find how to do that. It's possible to find commits through
  <code>GET /search/commits</code> (by specifying the repository via the repo parameter: <code>https://api.github.com/search/commits?q=repo:octocat/Spoon-Knife</code>), but there will be neither time period nor the repository branch specified.</p>
  
  <p>As a result, I was able to get the logins and contributions, but only for the whole time: </p>
  
  <pre><code>https://api.github.com/repos/octocat/Spoon-Knife/contributors
  </code></pre>
  
  <p>Also, in order to make search commits work, it's neccesary to provide a custom media type in the <code>Accept</code> header: <code>application/vnd.github.cloak-preview</code>
  I've reworked an example from the documentation of how the <code>urlib</code> library works, but it returns <code>HTTP error 422</code>:</p>
  
  <pre><code>import urllib.request
  
  API_URL = "https://api.github.com/"
  
  q = urllib.request.Request('API_URL' + "search/commits?q=repo:octocat/Spoon-Knife")  
  
  https://api.github.com/search/commits?q=repo:fastlane/fastlane
  q.add_header('application/vnd.github.cloak-preview', 'Accept')
  print(q)
  a = urllib.request.urlopen(q)
  a = a.read()
  print(a)
  </code></pre>