Uploading Data
CrowdFlower currently provides three import options:
- Bulk Upload (JSON)
- Data Feeds (RSS, Atom, XML, JSON)
- Spreadsheets (.csv, .tsv, .xls, .xlsx, .ods)
Methods
| Action | URL / Params | Verb |
|---|---|---|
| Upload | /jobs/upload | POST, PUT |
| Update | /jobs/:job_id/upload | POST, PUT |
Bulk Upload (JSON)
The JSON bulk upload action is the preferred method for importing data into a CrowdFlower job. You can upload a collection of JSON objects in the same way that you would upload a spreadsheet, and the JSON file can contain any number of JSON objects. Each of these JSON objects will be imported into your CrowdFlower job as one unit of work (this is the equivalent of one row of data in a spreadsheet import).
Content Type
When uploading JSON data in bulk, set your Content_Type header to application/json.
Parameters
If you specify a :job_id, the data submitted will be appended to the existing job. If you don’t specify a :job_id in the request, a new job will be created.
Response
A successful request will return a newly created job structure.
Sample JSON File
In this example, the first JSON object has three columns and the second only object has two. When a CrowdFlower job is created, the first object will be used to set the column headers. If any object after the first has a key-value pair whose key does not match one of the first object’s keys, that pair will not be included. If an object after the first is missing a key that was in the first object, you will see a blank cell.
{
"column_1":"You say goodbye",
"column_2":"And I say hello",
"column_3":"Hello, hello"
}
{
"column_1":"I don't know why you say goodbye",
"column_3":"I say hello"
}
cURL Examples
Create a new job by uploading a JSON file:
curl -T 'sampledata.json' -H 'Content-Type: application/json' http://api.crowdflower.com/v1/jobs/upload.json?key=XXX
Add data to an existing job by uploading a JSON file:
curl -T 'sampledata.json' -H 'Content-Type: application/json' http://api.crowdflower.com/v1/jobs/XXXX/upload.json?key=XXX
Result
This job was created by uploading the sample JSON file.
Data Feeds
If your data is accessible by a public URL, CrowdFlower can pull the data and load it into a job for you. This is a great way to analyze public RSS feeds or data in Google Data Protocol’s JSON format. Currently supported formats are RSS 1.0, RSS 2.0, Atom, generic XML, and JSON.
Parameters
You can submit a feed for seeding your job with data by setting the following post parameter:
- job[uri]
- A publicly accessible URL to a structured data feed.
If you specify a :job_id, the data submitted will be appended to the existing job. If you don’t specify a :job_id in the request, a new job will be created.
Response
A successful request will return the job that the data was loaded into.
cURL Examples
Pull data from a Twitter feed and add it to a new job:
curl -d 'job[uri]=http://search.twitter.com/search.atom?q=helloworld' http://api.crowdflower.com/v1/jobs/upload.json?key=XXX
Pull data from the Twitter feed and add it to an existing job:
curl -d 'job[uri]=http://search.twitter.com/search.atom?q=helloworld' http://api.crowdflower.com/v1/jobs/XXXX/upload.json?key=XXX
Spreadsheets
Content Type
You can upload a spreadsheet by setting the body of the request to the spreadsheet content and setting the Content_Type header to one of the following supported formats:
application/vnd.oasis.opendocument.spreadsheetapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheetapplication/vnd.ms-exceltext/csvtext/plain
Parameters
If you specify a :job_id, the data submitted will be appended to the existing job. If you don’t specify a :job_id in the request, a new job will be created.
Response
A successful request will return the job that the data was loaded into.
cURL Examples
Create a new job by uploading a CSV file:
curl -T 'sampledata.csv' -H 'Content-Type: text/csv' http://api.crowdflower.com/v1/jobs/upload.json?key=XXX
Add data to an existing job by uploading a CSV file:
curl -T 'sampledata.csv' -H 'Content-Type: text/csv' http://api.crowdflower.com/v1/jobs/XXXX/upload.json?key=XXX