npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mturk-api

v3.0.2

Published

JS implementation of Amazon Mechanical Turk (mturk) API

Downloads

859

Readme

NPM version Downloads

alt text

Install

npm install mturk-api

Basic usage

var mturk = require('mturk-api');

var config = {
    access : 'ACCESS_KEY_GOES_HERE',
    secret : 'SECRET_KEY_GOES_HERE',
    sandbox: true
}


mturk.createClient(config).then(function(api){


  api.req('GetAccountBalance').then(function(res){
    //Do something
  }).catch(console.error);


  //Example operation, with params
  api.req('SearchHITs', { PageSize: 100 }).then(function(res){
     //Do something
  }).catch(console.error)


  //MTurk limits the velocity of requests. Normally,
  //if you exceed their request rate-limit, you will receive a
  //'503 Service Unavailable' response. As of v2.0, our interface
  //automatically throttles your requests to 3 per second.
  for(var i=0; i < 20; i++){
    //These requests will be queued and executed at a rate of 3 per second
    api.req('SearchHITs', { PageNumber: i }).then(function(res){
      //Do something
    }).catch(console.error);
  }


}).catch(console.error);

###Create HIT Example


//Import an XML file. You can use one of our examples in the templates folder *
fs.readFile('./templates/HTMLQuestion.xml', 'utf8', function(err, unescapedXML){
  if(err){console.error(err);return}
  
  //HIT options
  var params = {
    Title: "Create HIT Example",
    Description: "An example of how to create a HIT",
    Question: _.escape(unescapedXML),//IMPORTANT: XML NEEDS TO BE ESCAPED!
    AssignmentDurationInSeconds: 180, // Allow 3 minutes to answer
    AutoApprovalDelayInSeconds: 86400 * 1, // 1 day auto approve
    MaxAssignments: 100, // 100 worker responses
    LifetimeInSeconds: 86400 * 3, // Expire in 3 days
    Reward: {CurrencyCode:'USD', Amount:0.50}
  };
  
  api.req('CreateHIT', params).then(function(res){
    //DO SOMETHING
  }).catch(console.error);
  
})

* To see the all available Question templates, go to our templates folder

Supported API Operations

Operation | Required Parameters | Unit test ------------- | ------------- | -------------- ApproveAssignment | { AssignmentId:String } ApproveRejectedAssignment | { AssignmentId:String } AssignQualification | { QualificationTypeId:String, WorkerId:String } | ✓ BlockWorker | { WorkerId:String, Reason:String } | ✓ ChangeHITTypeOfHIT | { HITId:String, HITTypeId:String} CreateHIT | { Title:String, Description:String, AssignmentDurationInSeconds:Number, LifetimeInSeconds:Number } OR {HITTypeId:String, LifetimeInSeconds:Number } | ✓ CreateQualificationType | { Name:String, Description:String, QualificationTypeStatus:String } | ✓ DisableHIT | { HITId:String } DisposeHIT | { HITId:String } DisposeQualificationType | {QualificationTypeId:String} | ✓ ExtendHIT | { HITId:String } ForceExpireHIT | { HITId:String } | ✓ GetAccountBalance | None | ✓ GetAssignment | { AssignmentId:String } GetAssignmentsForHIT | { HITId:String } GetBlockedWorkers | None | ✓ GetBonusPayments | { HITId:String } OR { AssignmentId:String } GetFileUploadURL | { AssignmentId:String, QuestionIdentifier:String } GetHIT | { HITId:String } | ✓ GetHITsForQualificationType | { QualificationTypeId:String } GetQualificationsForQualificationType | { QualificationTypeId:String } GetQualificationRequests | None GetQualificationScore | { QualificationTypeId:String, SubjectId:String} GetQualificationType | { QualificationTypeId:String } GetRequesterStatistic | { Statistic:String, TimePeriod:String } GetRequesterWorkerStatistic | {Statistic:String, WorkerId:String, TimePeriod:String } GetReviewableHITs | None GetReviewResultsForHIT | { HITId:String } GrantBonus | { WorkerId:String, AssignmentId:String, BonusAmount:Object, Reason:String } GrantQualification | { QualificationRequestId:String } NotifyWorkers | { Subject:String, MessageText:String, WorkerId:Array} RegisterHITType | { Title:String, Description:String, Reward:Object, AssignmentDurationInSeconds:Number } RejectAssignment | { AssignmentId:String } RejectQualificationRequest | { QualificationRequestId:String } RevokeQualification | { Subject:String, QualificationTypeId:String, Reason:String } SearchHITs | None | ✓ SearchQualificationTypes | { MustBeRequestable:Boolean } SendTestEventNotification | { Notification:Object, TestEventType:Object } | ✓ SetHITAsReviewing | { HITId:String } SetHITTypeNotification | { HITTypeId:String, Notification:Object, } UnblockWorker | { WorkerId:String, } | ✓ UpdateQualificationScore | { QualificationTypeId:String, SubjectId:String, IntegerValue:Number } UpdateQualificationType | { QualificationTypeId:String }

License

MIT © Jose Barrios

Banner derived from Cosmin Cuciureanu's BrainUP