<?xml version="1.0"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>CKAN: Ticket #336: Resource extension to REST API</title>
    <link>http://localhost/ticket/336</link>
    <description>&lt;h2 id="Asa"&gt;As a&lt;/h2&gt;
&lt;p&gt;
CKAN client such as ScraperWiki
&lt;/p&gt;
&lt;h2 id="Iwantto"&gt;I want to&lt;/h2&gt;
&lt;p&gt;
search for Package Resources, either by URL or other field, or just get them all. I want to be able to get all the resource's fields, such as URL.
&lt;/p&gt;
&lt;h2 id="Proposedimplementation"&gt;Proposed implementation&lt;/h2&gt;
&lt;p&gt;
Add resource search API at:
&lt;/p&gt;
&lt;p&gt;
/api/search/resource
&lt;/p&gt;
&lt;p&gt;
AND resource added to model API at:
&lt;/p&gt;
&lt;p&gt;
api/rest/resource
&lt;/p&gt;
&lt;p&gt;
Functional differences from the ScraperWiki suggested patch:
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;URL is not normalised
&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;URLs are not grouped
&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;All fields of the resource object are returned, not just the URL
&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Package is identified by its ID, not name or full URL. (This is for consistency in the API - you can simple prepend '&lt;a class="ext-link" href="http://ckan.net/package/"&gt;&lt;span class="icon"&gt;​&lt;/span&gt;http://ckan.net/package/&lt;/a&gt;' to the package ID)
&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;
This is to make our API more general, simple and consistent. It means that the ScraperWiki client has to do a bit more processing to get exactly what it needs. Is this ok?
&lt;/p&gt;
&lt;h3 id="Examplesearch"&gt;Example search&lt;/h3&gt;
&lt;p&gt;
POST
&lt;/p&gt;
&lt;pre class="wiki"&gt;{"url": "scraperwiki.com/", "all_fields": 1}
&lt;/pre&gt;&lt;p&gt;
to: /api/2/search/resource
&lt;/p&gt;
&lt;p&gt;
returns JSON:
&lt;/p&gt;
&lt;pre class="wiki"&gt; [{"id": "a3dd8f64-9078-4f04-845c-e3f047125028",
   "package_id": "b8a325c8-af2a-43f3-8245-9db7d73dfbfe",
   "URL": "http://scraperwiki.com/lincolnshire-councillors",
   "format": "CSV",
   "Description": "Scrape of www.lincs.gov/councillors.pdf by ScraperWiki.",
   "hash": "",
   "position": 2
 }]
&lt;/pre&gt;&lt;p&gt;
Note use of package_id instead of package_name is something we're moving towards in the API, since names can change. When we've done &lt;a class="closed ticket" href="http://localhost/ticket/341" title="enhancement: Web UI accepts package IDs in URLs (closed: fixed)"&gt;ticket:341&lt;/a&gt; then ckan.net/package/lincs-councillors will be a synonym of ckan.net/package/b8a325c8-af2a-43f3-8245-9db7d73dfbfe
&lt;/p&gt;
&lt;h3 id="Examplemodelrequest"&gt;Example model request&lt;/h3&gt;
&lt;p&gt;
GET to: /api/2/rest/resource/a3dd8f64-9078-4f04-845c-e3f047125028
&lt;/p&gt;
&lt;p&gt;
returns:
&lt;/p&gt;
&lt;pre class="wiki"&gt; [{"id": "a3dd8f64-9078-4f04-845c-e3f047125028",
   "package_id": "b8a325c8-af2a-43f3-8245-9db7d73dfbfe",
   "URL": "http://scraperwiki.com/lincolnshire-councillors",
   "format": "CSV",
   "Description": "Scrape of www.lincs.gov/councillors.pdf by ScraperWiki.",
   "hash": "",
   "position": 2
 }]
&lt;/pre&gt;&lt;h3 id="SearchParameters"&gt;Search Parameters&lt;/h3&gt;
&lt;pre class="wiki"&gt;Key:  q
Description: Search all resource fields for the value
Key: url / description / format /
Description: Search particular field for the value
Key: all_fields
Value: 0 or 1 (0 is default)
Description: If 1 (true), the full record of the package resource
(and it's package reference) are returned, rather than just the
PackageResource ID.
&lt;/pre&gt;&lt;p&gt;
May also choose to introduce 'offset' and 'limit' to page through a large number of results.
&lt;/p&gt;
&lt;p&gt;
JSONP achieved through API-wide parameter - see &lt;a class="closed ticket" href="http://localhost/ticket/342" title="enhancement: JSONP parameter in API (closed: fixed)"&gt;ticket:342&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Search is case insensitive.
&lt;/p&gt;
&lt;h2 id="Originalrequest"&gt;Original request&lt;/h2&gt;
&lt;p&gt;
Hi,
have attached a patch for adding a resource list api call. Have also added a JSONP compatible callback section, along the lines of &lt;a class="closed ticket" href="http://localhost/ticket/388" title="task: Reply to &amp;#34;two projects&amp;#34; question from RS (closed: fixed)"&gt;#388&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Could also add a search version. Not sure what the best url would be for that though.
&lt;/p&gt;
&lt;p&gt;
Haven't written a test as the structure seems to follow a functional spec. Is that document around somewhere?
&lt;/p&gt;
&lt;p&gt;
Donovan
&lt;/p&gt;
</description>
    <language>en-us</language>
    <image>
      <title>CKAN</title>
      <url>http://assets.okfn.org/p/ckan/img/ckan_logo_shortname.png</url>
      <link>http://localhost/ticket/336</link>
    </image>
    <generator>Trac 0.12.3</generator>
    <item>
      
        <dc:creator>donovanhide</dc:creator>

      <pubDate>Tue, 01 Jun 2010 17:02:58 GMT</pubDate>
      <title>attachment set</title>
      <link>http://localhost/ticket/336</link>
      <guid isPermaLink="false">http://localhost/ticket/336</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;attachment&lt;/strong&gt;
                set to &lt;em&gt;resource.patch&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Thu, 10 Jun 2010 09:36:41 GMT</pubDate>
      <title>description changed; owner set</title>
      <link>http://localhost/ticket/336#comment:1</link>
      <guid isPermaLink="false">http://localhost/ticket/336#comment:1</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;owner&lt;/strong&gt;
              set to &lt;em&gt;dread&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;description&lt;/strong&gt;
              modified (&lt;a href="/ticket/336?action=diff&amp;amp;version=1"&gt;diff&lt;/a&gt;)
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Thu, 10 Jun 2010 09:37:10 GMT</pubDate>
      <title>description changed</title>
      <link>http://localhost/ticket/336#comment:2</link>
      <guid isPermaLink="false">http://localhost/ticket/336#comment:2</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;description&lt;/strong&gt;
              modified (&lt;a href="/ticket/336?action=diff&amp;amp;version=2"&gt;diff&lt;/a&gt;)
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Thu, 10 Jun 2010 09:40:46 GMT</pubDate>
      <title>description changed</title>
      <link>http://localhost/ticket/336#comment:3</link>
      <guid isPermaLink="false">http://localhost/ticket/336#comment:3</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;description&lt;/strong&gt;
              modified (&lt;a href="/ticket/336?action=diff&amp;amp;version=3"&gt;diff&lt;/a&gt;)
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Thu, 10 Jun 2010 09:56:57 GMT</pubDate>
      <title>description changed</title>
      <link>http://localhost/ticket/336#comment:4</link>
      <guid isPermaLink="false">http://localhost/ticket/336#comment:4</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;description&lt;/strong&gt;
              modified (&lt;a href="/ticket/336?action=diff&amp;amp;version=4"&gt;diff&lt;/a&gt;)
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Thu, 10 Jun 2010 10:35:15 GMT</pubDate>
      <title>description changed</title>
      <link>http://localhost/ticket/336#comment:5</link>
      <guid isPermaLink="false">http://localhost/ticket/336#comment:5</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;description&lt;/strong&gt;
              modified (&lt;a href="/ticket/336?action=diff&amp;amp;version=5"&gt;diff&lt;/a&gt;)
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Thu, 10 Jun 2010 10:40:37 GMT</pubDate>
      <title>description changed</title>
      <link>http://localhost/ticket/336#comment:6</link>
      <guid isPermaLink="false">http://localhost/ticket/336#comment:6</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;description&lt;/strong&gt;
              modified (&lt;a href="/ticket/336?action=diff&amp;amp;version=6"&gt;diff&lt;/a&gt;)
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Thu, 10 Jun 2010 10:43:13 GMT</pubDate>
      <title>description changed</title>
      <link>http://localhost/ticket/336#comment:7</link>
      <guid isPermaLink="false">http://localhost/ticket/336#comment:7</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;description&lt;/strong&gt;
              modified (&lt;a href="/ticket/336?action=diff&amp;amp;version=7"&gt;diff&lt;/a&gt;)
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Fri, 25 Jun 2010 16:28:10 GMT</pubDate>
      <title>description changed</title>
      <link>http://localhost/ticket/336#comment:8</link>
      <guid isPermaLink="false">http://localhost/ticket/336#comment:8</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;description&lt;/strong&gt;
              modified (&lt;a href="/ticket/336?action=diff&amp;amp;version=8"&gt;diff&lt;/a&gt;)
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Mon, 28 Jun 2010 10:37:13 GMT</pubDate>
      <title>summary changed</title>
      <link>http://localhost/ticket/336#comment:9</link>
      <guid isPermaLink="false">http://localhost/ticket/336#comment:9</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;summary&lt;/strong&gt;
                changed from &lt;em&gt;Resource extension to REST API&lt;/em&gt; to &lt;em&gt;Resource Search API&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Fri, 09 Jul 2010 18:27:01 GMT</pubDate>
      <title>status changed; resolution set</title>
      <link>http://localhost/ticket/336#comment:10</link>
      <guid isPermaLink="false">http://localhost/ticket/336#comment:10</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;status&lt;/strong&gt;
                changed from &lt;em&gt;new&lt;/em&gt; to &lt;em&gt;closed&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;resolution&lt;/strong&gt;
                set to &lt;em&gt;fixed&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;p&gt;
Done in cset:742adebb707c and cset:1748e6554e77.
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Fri, 09 Jul 2010 18:31:06 GMT</pubDate>
      <title></title>
      <link>http://localhost/ticket/336#comment:11</link>
      <guid isPermaLink="false">http://localhost/ticket/336#comment:11</guid>
      <description>
        &lt;p&gt;
Took 0.75 days.
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>Donny</dc:creator>

      <pubDate>Sat, 17 Jul 2010 12:09:04 GMT</pubDate>
      <title>priority, status, type changed; resolution deleted</title>
      <link>http://localhost/ticket/336#comment:12</link>
      <guid isPermaLink="false">http://localhost/ticket/336#comment:12</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;priority&lt;/strong&gt;
                changed from &lt;em&gt;awaiting triage&lt;/em&gt; to &lt;em&gt;blocker&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;status&lt;/strong&gt;
                changed from &lt;em&gt;closed&lt;/em&gt; to &lt;em&gt;reopened&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;resolution&lt;/strong&gt;
                &lt;em&gt;fixed&lt;/em&gt; deleted
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;type&lt;/strong&gt;
                changed from &lt;em&gt;enhancement&lt;/em&gt; to &lt;em&gt;defect&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;p&gt;
&lt;a class="ext-link" href="http://ckan.net/api/search/resource?url=http://scraperwiki.com&amp;amp;all_fields=1&amp;amp;callback=ckantest"&gt;&lt;span class="icon"&gt;​&lt;/span&gt;http://ckan.net/api/search/resource?url=http://scraperwiki.com&amp;amp;all_fields=1&amp;amp;callback=ckantest&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
yields
&lt;/p&gt;
&lt;p&gt;
Bad search option: Field "callback" not recognised in Resource search.
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>dread</dc:creator>

      <pubDate>Sat, 17 Jul 2010 13:37:22 GMT</pubDate>
      <title>status changed; resolution set</title>
      <link>http://localhost/ticket/336#comment:13</link>
      <guid isPermaLink="false">http://localhost/ticket/336#comment:13</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;status&lt;/strong&gt;
                changed from &lt;em&gt;reopened&lt;/em&gt; to &lt;em&gt;closed&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;resolution&lt;/strong&gt;
                set to &lt;em&gt;fixed&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;p&gt;
Fixed in cset:e719f449bc74
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item>
 </channel>
</rss>