title: How best to design a REST API with multiple filters?
body: <p>As a personal programming project, I am working on scraping my University's course catalog and providing the data as a REST API. I have successfully scraped all the data and stored it in a database, and am now working on the API.</p>
  
  <p>The courses can be filtered on the basis  of many criteria: instructor, college, credits, time, day etc.</p>
  
  <p>What is the best way to provide an API in this situation?</p>
  
  <p><strong>Option 1</strong></p>
  
  <p>Provide numerous URLs such as</p>
  
  <pre><code>example.com/api/byinstructor/&lt;instructorcode&gt;
  example.come/api/bycollege/&lt;collegecode&gt;
  example.com/api/bycollegeandinstructor/&lt;collegecode&gt;/&lt;instructorcode&gt;
  ...and so on
  </code></pre>
  
  <p>I would need to have a URL for all permutations. This seems very cumbersome, both for me and the API consumers, and very un-DRY. </p>
  
  <p><strong>Option 2</strong></p>
  
  <p>Only provide APIs for the major options like:</p>
  
  <pre><code>example.com/api/byinstructor/&lt;instructorcode&gt;
  example.come/api/bycollege/&lt;collegecode&gt;
  </code></pre>
  
  <p>And if the consumer wants <code>bycollegeandinstructor</code>, he does the filtering on his end.</p>
  
  <p><strong>Option 3</strong></p>
  
  <p>The user passes a JSON string to me, and I use that to get the filtering criteria</p>
  
  <pre><code>example.com/api/getcourses/&lt;jsonstring&gt;
  
  jsonstring = 
  { 
    instructor:&lt;instructorcode&gt;,
    college:&lt;collegecode&gt;,
    ...and so on
  }
  </code></pre>
  
  <p>I suppose instead of the Json string, I could also require a POST array, but that seems un-inituitive for the consumer since he is GETing data.</p>
  
  <p>Or is there another way of doing this I am not aware of? If it is the third option that is the best option, could you provide a short summary best to prepare a SQL query on the basis of a JSOn string that may have variable number of values?</p>