API instructions for http://acme.crowdsifter.com/demo

REST API & Webhooks

The CrowdSifter REST API is the most powerful way to moderate your site. We also provide webhooks for immediate notification of image status. To use the REST API you need a unique token. Your token is:

YOU_MUST_CREATE_AN_ACCOUNT_AND_ADD_A_SITE_TO_GET_A_TOKEN

You can put the token into the header of your requests with the key TOKEN, or as a GET / POST parameter with the key token. The requests must be made through SSL to prevent potential sniffing of your token. The general format of a request to our API is:

https://company_name.crowdsifter.com/api/imgs/job_id.response_format

REST API Reference

Action / ParametersResource / ResponseVerb / Format
Add to queue https://acme.crowdsifter.com/api/imgs/0 POST
url => str (success | error) => str json | xml
Retrieve result https://acme.crowdsifter.com/api/imgs/0 GET
url => str | img_id => int rating => (float | null), id => int, url => str, created_at => datetime json | xml
Retrieve results https://acme.crowdsifter.com/api/imgs/0 GET
rating => (float | null), id => int, url => string, created_at => timestamp json | xml | csv

You can specify the format of the response by setting the HTTP_ACCEPT header to one of:

  • application/json
  • application/xml
  • application/csv

You can also append .csv, .xml, .json to any request to set the content type.

If the rating returned from a request is null, the image has not yet been judged. Otherwise the rating is a floating point between 0 and 1 where 1 is definitely inappropriate, and 0 is appropriate.


Here are some examples

GET https://acme.crowdsifter.com/api/imgs/0.xml?url=http%3A%2F%2Ffacestat.com%2Ffaces%2Fimage%2F400.jpg

<?xml version="1.0" encoding="UTF-8"?>
<image>
     <created-at type="datetime">2008-09-11T01:26:56Z</created-at>
     <id type="integer">382</id>
     <url>http://facestat.com/faces/image/400.jpg</url>
     <rating>0.00</rating>
</image>

POST https://acme.crowdsifter.com/api/imgs/0.xml
url=http%3A%2F%2Ffacestat.com%2Ffaces%2Fimage%2F400.jpg

{"success": "Image queued for processing"}

One easy way to start playing with the API is by downloading our convenient ruby class. Below are a few examples of using it.

$ sudo gem install httparty
$ irb 
>> require 'crowdsifter.rb'
=> true
>> c = CrowdSifter.new('acme', 0, 'YOU_MUST_CREATE_AN_ACCOUNT_AND_ADD_A_SITE_TO_GET_A_TOKEN')
=> #<CrowdSifter:0x112f754 @token="YOU_MUST_CREATE_AN_ACCOUNT_AND_ADD_A_SITE_TO_GET_A_TOKEN", @id=0, @company="acme">
>> c.moderate("http://acme.crowdsifter.com/demosome_image.jpg")
=> {"success"=>"Image queued for processing"}
>> c.img(:url => "http://acme.crowdsifter.com/demosome_image.jpg")
=> {"image"=>{"rating"=>nil, "url"=>"http://acme.crowdsifter.com/demosome_image.jpg",
"id"=>12693, "created_at"=>Wed Sep 08 17:35:16 +0000 2010}}

Webhooks

Setting up webhooks is extremely simple. Goto your account page and enter a url for CrowdSifter to post to. CrowdSifter will post to your url twice during the lifecycle of an image. Once after the image has been created (an image is put into a queue for processing when it is added), and once after the image has completed moderation. If the rating is null, it is a post create hook. Post create hooks can also inform you images that failed to be created for various reasons. You can test the postbacks by using the "Test webhook" link on the account page.

Here is an example successful webhook post create request:

{
   rating => null,
   id => 1,
   url => "http://acme.crowdsifter.com/imgs/good.jpg"
   created_at => "2008-09-26T18:21:49Z",
   job_id => 172
}

Here is an example unsuccessful webhook post create request:

{
   rating => null,
   failed => "Image was corrupt or of an unsupported format.",
   url => "http://acme.crowdsifter.com/imgs/bad.jpg"
   job_id => 172
  }

And here is an example post moderation request:

{
   rating => 0,
   id => 2,
   url => "http://acme.crowdsifter.com/imgs/good.jpg"
   created_at => "2008-09-26T18:21:49Z",
   job_id => 172
}

By default webhooks are sent as a post request with a key of "payload" and a value of URI escaped JSON. If you would rather have XML posted to your webhook, append .xml to your webhook url or add format=xml as a query parameter. We've created a simple Merb webhook server that you can modify for your needs.


JavaScript API

The CrowdSifter JavaScript API is the easiest way to keep your site moderated. Place the following HTML just before the </body> tag on the page(s) that display images you need to be moderated.

<script type="text/javascript" charset="utf-8" src="https://acme.crowdsifter.com/javascripts/filter.js?id=0"></script>

By default all processing happens in the background and inappropriate images are still shown until you remove them. You can configure the JavaScript API to display a "Pending approval" and "Inappropriate content" place holder for images.