Learn R Programming

MTurkR (version 0.2)

genericmturkr: Make Arbitrary MTurk API Requests

Description

A function designed for advanced users to be able to make arbitrary requests to the MTurk API. Most users do not need this.

Usage

genericmturkr(operation, parameters = NULL, keypair = credentials(), print = TRUE, 
			browser = FALSE, log.requests = TRUE, sandbox = FALSE, xml.parse = TRUE)

makeGETparameters(parameter, value)

Arguments

operation
The MTurk API operation to be performed.
parameters
A character string containing URL query parameters, possibly as returned by makeGETparameters.
keypair
A two-item character vector containing an AWS Access Key ID in the first position and the corresponding Secret Access Key in the second position. Set default with credentials.
print
Optionally print the results of the API request to the standard output. Default is TRUE.
browser
Optionally open the request in the default web browser, rather than opening in R. Default is FALSE.
log.requests
A logical specifying whether API requests should be logged. Default is TRUE. See readlogfile for details.
sandbox
Optionally execute the request in the MTurk sandbox rather than the live server. Default is FALSE.
xml.parse
Whether the returned list should contain parsed XML.
parameter
A character string containing a parameter name, or a vector of character strings containing parameter names.
value
A character string containing a value for a parameter, or a vector of character strings containing the value for each of the parameters specified in parameter.

Value

  • A list containing the URL of the MTurk API REST request (request.url), the Request ID created by the API reqest (request.id), a logical indicating whether or not the request was valid and thus executed as intended (valid), and a character string containing the XML-formatted API response (xml).

Details

A simple wrapper for authenticate and request to provide advanced users with generic access to the MTurk API. genericmturkr executes arbitrary MTurk API requests for the specified MTurk API operation and any parameters. makeGETparameters provides a convenience function to generate these. Though this function does not underly the other MTurkR functions, it can produce similar effects (though response information is returned unformatted).

References

http://docs.amazonwebservices.com/AWSMechTurk/latest/AWSMechanicalTurkRequester/MakingRequests_MakingRESTRequestsArticle.html{API Reference: Making REST Requests}

Examples

Run this code
genericmturkr("GetAccountBalance")
a <- makeGETparameters("AssignmentId","26XXH0JPPSI23H54YVG7BKLEXAMPLE")
data <- genericmturkr("GetAssignment",a)

Run the code above in your browser using DataLab