title: Handling different response data types of REST APIs
body: <p>The requirement for my application is to do a GET on the GitHub API </p>
  
  <blockquote>
    <p><a href="https://api.github.com/repos/" rel="nofollow noreferrer">https://api.github.com/repos/</a>{full_name}/commits</p>
  </blockquote>
  
  <p>In the ideal case, this REST API returns a list of dictionaries. Then the application has to fetch the first element of the result. </p>
  
  <p>However, the REST API might also return a dictionary in the non-ideal case(empty repository with no commits). In this case, if the first element is fetched, it will throw a keyerror.</p>
  
  <p>Right now, I have wrapped the code in try..catch. So if an exception is raised in the non-ideal case, the application bails out.</p>
  
  <p>Is there a better way to handle the ideal and non-ideal case?</p>