Documentation
¶
Overview ¶
Package rapidworkers is the official Go client for RapidWorkers: hire real people for microtasks, app testing, surveys and AI data collection (photos, audio, video, text). People do the work on their own devices; you pay in USD from your account balance and approve only the work that meets your brief.
Create an API key at https://www.rapidworkers.io/dashboard/api-management/ and set it as RAPIDWORKERS_API_KEY.
rw, err := rapidworkers.NewClientFromEnv()
if err != nil {
log.Fatal(err)
}
account, err := rw.GetAccount(ctx) // balance, deposit status, AI task access
Tools ¶
Every tool of the hosted RapidWorkers MCP server is a method on Client that takes a context and, when the tool has arguments, a Params struct: account, platform rules, cost quotes, jobs, prefilled jobs, AI tasks, submissions and worker blocking. Answers are the server's JSON as map[string]any; print one to see its shape. Client.CallTool calls any tool by name and Client.ListTools returns the live definitions.
Required arguments are plain fields. Optional ones are pointers, set with String, Int, Float, Bool or Ptr, except enums and lists, which are unset at their zero value:
jobs, err := rw.ListJobs(ctx, rapidworkers.ListJobsParams{
Kind: rapidworkers.KindAITask,
PageSize: rapidworkers.Int(50),
})
Money is never moved twice ¶
Calls that spend or pay out (CreateJob, CreatePrefilledJob, CreateAITask, ExtendJob, CancelJob, ApproveSubmission, RejectSubmission and ApproveAllPending) get an idempotency key automatically when Params.IdempotencyKey is empty, and a call that times out is resent with the same key. Set IdempotencyKey yourself to retry safely across processes.
429 and 503 answers are retried for every call. Network errors, 502 and 504 are retried only for calls that are safe to resend: read-only tools, idempotent tools and tools with an idempotency key. GetDepositLink is not resent. The wait is 0.5s, 1s, 2s... (at most 30s) or the server's Retry-After; see WithMaxRetries and WithTimeout.
Errors ¶
A refused call returns a *ToolError whose Message says how to fix it (for example a low balance or an expired quote_id). *AuthenticationError, *RateLimitError, *ServiceUnavailableError and *APIError cover HTTP and JSON-RPC errors, and *ConnectionError covers the network. Use errors.As:
var toolErr *rapidworkers.ToolError
if errors.As(err, &toolErr) {
fmt.Println(toolErr.Code, toolErr.Message)
}
Rules worth knowing ¶
Pay at least $0.05 per worker ($0.10 for AI tasks, $0.50 per survey response) and at least 10 workers per job. A first deposit (minimum $20) is required before posting; GetDepositLink returns a checkout URL for a person to pay. Create calls need a quote_id from PreviewJobCost and Confirm: true. Approving pays the worker and cannot be undone; pending submissions are approved automatically after 2 days. AI tasks need access approved by the RapidWorkers team (RequestAITaskAccess).
Example ¶
Quote an AI data-collection task, create it once the cost is approved, then review the work. (Examples without an Output comment are compiled but not run, so this never calls the API.)
package main
import (
"context"
"fmt"
"log"
rapidworkers "github.com/RapidWorkers-io/rapidworkers/go"
)
func main() {
ctx := context.Background()
rw, err := rapidworkers.NewClientFromEnv() // reads RAPIDWORKERS_API_KEY
if err != nil {
log.Fatal(err)
}
// 1. Get a quote (nothing is charged).
quote, err := rw.PreviewJobCost(ctx, rapidworkers.PreviewJobCostParams{
Kind: rapidworkers.KindAITask,
PayRate: 0.25,
Quantity: 100,
})
if err != nil {
log.Fatal(err)
}
fmt.Println(quote["total"], quote["expires_at"]) // show the total and get a yes first
// 2. Create the task with that quote_id once the cost is approved.
task, err := rw.CreateAITask(ctx, rapidworkers.CreateAITaskParams{
TaskType: rapidworkers.AITaskTypeImageCollection,
Title: "Photo of a paper receipt",
Description: "Take a clear photo of one paper receipt from a recent purchase.",
SubmissionInstructions: "Upload one photo. The whole receipt must be visible and readable.",
RequiredFileCount: rapidworkers.Int(1),
PayRate: 0.25,
Quantity: 100,
LengthInMinutes: 5,
Countries: []string{"All"},
QuoteID: quote["quote_id"].(string),
Confirm: true,
})
if err != nil {
log.Fatal(err)
}
jobID := task["job_id"].(string)
// 3. Review the work.
subs, err := rw.ListSubmissions(ctx, rapidworkers.ListSubmissionsParams{
JobID: jobID,
Kind: rapidworkers.KindAITask,
Status: rapidworkers.SubmissionStatusPending,
})
if err != nil {
log.Fatal(err)
}
for _, s := range subs["submissions"].([]any) {
sub := s.(map[string]any)
_, err := rw.ApproveSubmission(ctx, rapidworkers.ApproveSubmissionParams{
JobID: jobID,
Kind: rapidworkers.KindAITask,
SubmissionID: int(sub["submission_id"].(float64)),
})
if err != nil {
log.Fatal(err)
}
}
}
Output:
Index ¶
- Constants
- Variables
- func Bool(v bool) *bool
- func Float(v float64) *float64
- func Int(v int) *int
- func Ptr[T any](v T) *T
- func String(v string) *string
- type AITaskType
- type APIError
- type ApproveAllPendingParams
- type ApproveSubmissionParams
- type Audience
- type AuthenticationError
- type BlockWorkerParams
- type CancelJobParams
- type CaptureMode
- type Client
- func (c *Client) ApproveAllPending(ctx context.Context, p ApproveAllPendingParams) (map[string]any, error)
- func (c *Client) ApproveSubmission(ctx context.Context, p ApproveSubmissionParams) (map[string]any, error)
- func (c *Client) BlockWorker(ctx context.Context, p BlockWorkerParams) (map[string]any, error)
- func (c *Client) CallTool(ctx context.Context, name string, args map[string]any) (map[string]any, error)
- func (c *Client) CancelJob(ctx context.Context, p CancelJobParams) (map[string]any, error)
- func (c *Client) CreateAITask(ctx context.Context, p CreateAITaskParams) (map[string]any, error)
- func (c *Client) CreateJob(ctx context.Context, p CreateJobParams) (map[string]any, error)
- func (c *Client) CreatePrefilledJob(ctx context.Context, p CreatePrefilledJobParams) (map[string]any, error)
- func (c *Client) CreateSurvey(ctx context.Context, p CreateSurveyParams) (map[string]any, error)
- func (c *Client) ExtendJob(ctx context.Context, p ExtendJobParams) (map[string]any, error)
- func (c *Client) GetAccount(ctx context.Context) (map[string]any, error)
- func (c *Client) GetDepositLink(ctx context.Context, p GetDepositLinkParams) (map[string]any, error)
- func (c *Client) GetJob(ctx context.Context, p GetJobParams) (map[string]any, error)
- func (c *Client) GetPlatformInfo(ctx context.Context, p GetPlatformInfoParams) (map[string]any, error)
- func (c *Client) GetSurveyResults(ctx context.Context, p GetSurveyResultsParams) (map[string]any, error)
- func (c *Client) ListBlockedWorkers(ctx context.Context) (map[string]any, error)
- func (c *Client) ListJobs(ctx context.Context, p ListJobsParams) (map[string]any, error)
- func (c *Client) ListSubmissions(ctx context.Context, p ListSubmissionsParams) (map[string]any, error)
- func (c *Client) ListTools(ctx context.Context) ([]map[string]any, error)
- func (c *Client) ListTransactions(ctx context.Context) (map[string]any, error)
- func (c *Client) PreviewJobCost(ctx context.Context, p PreviewJobCostParams) (map[string]any, error)
- func (c *Client) RejectSubmission(ctx context.Context, p RejectSubmissionParams) (map[string]any, error)
- func (c *Client) RequestAITaskAccess(ctx context.Context, p RequestAITaskAccessParams) (map[string]any, error)
- func (c *Client) UnblockWorker(ctx context.Context, p UnblockWorkerParams) (map[string]any, error)
- type ConnectionError
- type CreateAITaskParams
- type CreateJobParams
- type CreatePrefilledJobParams
- type CreateSurveyParams
- type CreateSurveyType
- type DepositMethod
- type Education
- type ExtendJobParams
- type Genders
- type GetDepositLinkParams
- type GetJobParams
- type GetPlatformInfoParams
- type GetSurveyResultsParams
- type Include
- type JobStatus
- type Kind
- type ListJobsParams
- type ListSubmissionsParams
- type Occupations
- type OnlyQualityBand
- type Operator
- type Option
- type PlatformInfoSection
- type PrefilledJobType
- type Preset
- type PreviewJobCostParams
- type QualityBand
- type Question
- type RateLimitError
- type RejectSubmissionParams
- type RequestAITaskAccessParams
- type Scale
- type ServiceUnavailableError
- type ShowIf
- type SubmissionField
- type SubmissionFieldType
- type SubmissionStatus
- type Template
- type ToolError
- type UnblockWorkerParams
Examples ¶
Constants ¶
const ( // APIKeyEnv is the environment variable [NewClientFromEnv] reads the API // key from. APIKeyEnv = "RAPIDWORKERS_API_KEY" // BaseURLEnv is the environment variable that overrides the endpoint in // [NewClientFromEnv]. BaseURLEnv = "RAPIDWORKERS_MCP_URL" // APIKeysURL is the dashboard page where API keys are created. APIKeysURL = "https://www.rapidworkers.io/dashboard/api-management/" // ProtocolVersion is the MCP protocol version the client speaks. ProtocolVersion = "2025-06-18" // DefaultTimeout bounds each HTTP attempt. DefaultTimeout = 60 * time.Second // DefaultMaxRetries is how many times a failed call is resent by default. DefaultMaxRetries = 2 )
const ServerURL = "https://www.rapidworkers.io/api/mcp/"
ServerURL is the hosted RapidWorkers MCP endpoint and the default base URL.
const Version = "0.1.0"
Version is the version of this module, sent in the User-Agent header. Bump it before tagging a release (tag go/vX.Y.Z).
Variables ¶
var ErrNoAPIKey = errors.New("rapidworkers: no API key: pass one to NewClient or set " + APIKeyEnv + "; create a key at " + APIKeysURL)
ErrNoAPIKey is returned by NewClient and NewClientFromEnv when there is no API key.
Functions ¶
Types ¶
type AITaskType ¶
type AITaskType string
AITaskType is a value of the "task_type" argument.
image_collection, video_collection or audio_collection (workers upload files), text_collection (written answers) or custom_data_collection (a form you define in submission_fields). For a questionnaire use create_survey instead.
const ( AITaskTypeImageCollection AITaskType = "image_collection" AITaskTypeVideoCollection AITaskType = "video_collection" AITaskTypeAudioCollection AITaskType = "audio_collection" AITaskTypeTextCollection AITaskType = "text_collection" AITaskTypeCustomDataCollection AITaskType = "custom_data_collection" )
Values of AITaskType.
type APIError ¶
type APIError struct {
// StatusCode is the HTTP status of the answer.
StatusCode int
// Code is the JSON-RPC error code, or 0 when the answer had none.
Code int
// Message describes the error.
Message string
// Data is the JSON-RPC error data, if any.
Data any
}
APIError is an HTTP or JSON-RPC error answer from RapidWorkers.
AuthenticationError, RateLimitError and ServiceUnavailableError wrap an APIError, so errors.As(err, &apiErr) with apiErr of type *APIError matches all of them.
type ApproveAllPendingParams ¶
type ApproveAllPendingParams struct {
// Required. Id of the job, survey or AI task (job_id from list_jobs or from
// the create tool).
JobID string `json:"job_id"`
// Required. Must be true, and only after the user explicitly approved this
// action and its cost.
Confirm bool `json:"confirm"`
// "job" (default) for regular and prefilled jobs, "survey" for surveys made
// with create_survey, "ai_task" for AI data-collection tasks.
Kind Kind `json:"kind,omitempty"`
// Surveys only: "good" approves only the Pending responses in the good quality
// band; the ones to check or likely bad stay Pending for review.
OnlyQualityBand OnlyQualityBand `json:"only_quality_band,omitempty"`
// Optional. Created automatically when empty and reused on retries. A new
// unique string for this action (e.g. a UUID; letters, digits, _ . : - only,
// up to 128). Send the same key again only to retry a call that timed out or
// could not reach the API, so it is never done twice. After an error answer,
// fix the cause and use a new key: the API replays its stored answer to a
// reused key.
IdempotencyKey string `json:"idempotency_key,omitempty"`
}
ApproveAllPendingParams are the arguments of Client.ApproveAllPending.
type ApproveSubmissionParams ¶
type ApproveSubmissionParams struct {
// Required. Id of the job, survey or AI task (job_id from list_jobs or from
// the create tool).
JobID string `json:"job_id"`
// Required. submission_id from list_submissions.
SubmissionID int `json:"submission_id"`
// "job" (default) for regular and prefilled jobs, "survey" for surveys made
// with create_survey, "ai_task" for AI data-collection tasks.
Kind Kind `json:"kind,omitempty"`
// Optional tip in USD (0.01 to 50.00) paid from the balance to the worker in
// full.
Tip *float64 `json:"tip,omitempty"`
// Optional note the worker sees.
Notes *string `json:"notes,omitempty"`
// Optional. Created automatically when empty and reused on retries. A new
// unique string for this action (e.g. a UUID; letters, digits, _ . : - only,
// up to 128). Send the same key again only to retry a call that timed out or
// could not reach the API, so it is never done twice. After an error answer,
// fix the cause and use a new key: the API replays its stored answer to a
// reused key.
IdempotencyKey string `json:"idempotency_key,omitempty"`
}
ApproveSubmissionParams are the arguments of Client.ApproveSubmission.
type Audience ¶
type Audience struct {
// Youngest age (16 to 99).
MinAge *int `json:"min_age,omitempty"`
// Oldest age (16 to 99).
MaxAge *int `json:"max_age,omitempty"`
// Only workers whose profile gender is one of these.
Genders []Genders `json:"genders,omitempty"`
// Only workers with one of these native languages: codes such as "en", "es" or
// "hi" (get_platform_info section survey_builder lists them).
NativeLanguages []string `json:"native_languages,omitempty"`
// Only workers whose profile highest education is one of these.
Education []Education `json:"education,omitempty"`
// Only workers whose profile occupation is one of these.
Occupations []Occupations `json:"occupations,omitempty"`
}
Audience is one element of the "audience" argument.
Optional: who may answer, on top of countries. Leave out for everyone. Only workers with a completed profile match a filter, so every filter shrinks the pool: set only what the user asked for.
type AuthenticationError ¶
type AuthenticationError struct {
APIError
}
AuthenticationError means the API key is missing, invalid or revoked, or the account cannot use it (HTTP 401).
func (*AuthenticationError) Unwrap ¶
func (e *AuthenticationError) Unwrap() error
Unwrap returns the underlying APIError.
type BlockWorkerParams ¶
type BlockWorkerParams struct {
// Required. worker_id of a submission on a regular job or a survey (from
// list_submissions).
WorkerID int `json:"worker_id"`
}
BlockWorkerParams are the arguments of Client.BlockWorker.
type CancelJobParams ¶
type CancelJobParams struct {
// Required. Id of the job, survey or AI task (job_id from list_jobs or from
// the create tool).
JobID string `json:"job_id"`
// Required. Must be true, and only after the user explicitly approved this
// action and its cost.
Confirm bool `json:"confirm"`
// "job" (default) for regular and prefilled jobs, "survey" for surveys made
// with create_survey, "ai_task" for AI data-collection tasks.
Kind Kind `json:"kind,omitempty"`
// Optional. Created automatically when empty and reused on retries. A new
// unique string for this action (e.g. a UUID; letters, digits, _ . : - only,
// up to 128). Send the same key again only to retry a call that timed out or
// could not reach the API, so it is never done twice. After an error answer,
// fix the cause and use a new key: the API replays its stored answer to a
// reused key.
IdempotencyKey string `json:"idempotency_key,omitempty"`
}
CancelJobParams are the arguments of Client.CancelJob.
type CaptureMode ¶
type CaptureMode string
CaptureMode is a value of the "capture_mode" argument.
Audio and video only: "upload" files, "record" in the browser, or "both" (default).
const ( CaptureModeBoth CaptureMode = "both" CaptureModeUpload CaptureMode = "upload" CaptureModeRecord CaptureMode = "record" )
Values of CaptureMode.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client calls the hosted RapidWorkers MCP server. Every tool is a method; see the package documentation for an example.
Each call is one JSON-RPC tools/call POST to the stateless endpoint, so the client gets exactly the validation, cost quotes, safeguards and error messages the server gives AI agents. A Client is safe for concurrent use.
func NewClient ¶
NewClient returns a client that authenticates with apiKey. Create a key at APIKeysURL. It returns ErrNoAPIKey when apiKey is empty.
func NewClientFromEnv ¶
NewClientFromEnv returns a client that reads its API key from RAPIDWORKERS_API_KEY. RAPIDWORKERS_MCP_URL, when set, overrides the endpoint; a WithBaseURL option overrides both.
func (*Client) ApproveAllPending ¶
func (c *Client) ApproveAllPending(ctx context.Context, p ApproveAllPendingParams) (map[string]any, error)
ApproveAllPending approves every Pending submission on the job and pays the workers; this cannot be undone. For a survey, only_quality_band "good" approves only the Pending responses in the good quality band and leaves the rest for review. Requires confirm=true and an idempotency_key. Set kind to "survey" for surveys made with create_survey or "ai_task" for AI data-collection tasks; the default "job" covers regular and prefilled jobs.
It calls the "approve_all_pending" tool. An empty p.IdempotencyKey is replaced by a new key, which is reused when the call is retried, so the action never happens twice.
func (*Client) ApproveSubmission ¶
func (c *Client) ApproveSubmission(ctx context.Context, p ApproveSubmissionParams) (map[string]any, error)
ApproveSubmission approves a submission and pays the worker from the job budget; this cannot be undone. Optional tip $0.01 to $50.00 from the balance, paid to the worker in full. Requires an idempotency_key. Set kind to "survey" for surveys made with create_survey or "ai_task" for AI data-collection tasks; the default "job" covers regular and prefilled jobs.
It calls the "approve_submission" tool. An empty p.IdempotencyKey is replaced by a new key, which is reused when the call is retried, so the action never happens twice.
func (*Client) BlockWorker ¶
BlockWorker blocks a worker (worker_id from list_submissions of a regular job or a survey) from all of the account's jobs and rejects their pending submissions.
It calls the "block_worker" tool.
func (*Client) CallTool ¶
func (c *Client) CallTool(ctx context.Context, name string, args map[string]any) (map[string]any, error)
CallTool calls any tool by name. args are the tool's arguments as its JSON schema names them; nil values are left out. When the tool takes an idempotency_key and args has none, a new one is created and reused on retries.
A refused call returns a *ToolError whose Message says how to fix it.
Example ¶
package main
import (
"context"
"fmt"
"log"
rapidworkers "github.com/RapidWorkers-io/rapidworkers/go"
)
func main() {
ctx := context.Background()
rw, err := rapidworkers.NewClientFromEnv()
if err != nil {
log.Fatal(err)
}
info, err := rw.CallTool(ctx, "get_platform_info", map[string]any{"section": "limits"})
if err != nil {
log.Fatal(err)
}
fmt.Println(info)
}
Output:
func (*Client) CancelJob ¶
CancelJob cancels a job and refunds the unspent budget to the balance. Pending (not yet live) jobs are refunded in full; live jobs pay a $0.20 fee and cannot be canceled while submissions await review. Requires confirm=true. Set kind to "survey" for surveys made with create_survey or "ai_task" for AI data-collection tasks; the default "job" covers regular and prefilled jobs.
It calls the "cancel_job" tool. An empty p.IdempotencyKey is replaced by a new key, which is reused when the call is retried, so the action never happens twice.
func (*Client) CreateAITask ¶
CreateAITask posts an AI data-collection task (image, video, audio or text collection, or a custom form) and charges pay_rate x quantity + commission. Requires approved AI task access (see request_ai_task_access), quote_id from preview_job_cost with kind "ai_task", confirm=true and an idempotency_key. pay_rate >= 0.10, quantity 10 to 20,000, countries required. Optional image_prompt: a detailed description of one example image we generate with AI and attach as a reference file.
It calls the "create_ai_task" tool. An empty p.IdempotencyKey is replaced by a new key, which is reused when the call is retried, so the action never happens twice.
func (*Client) CreateJob ¶
CreateJob posts a custom job that real workers complete and prove with a screenshot or text. Charges pay_rate x quantity + commission from the balance immediately. Requires quote_id from preview_job_cost, confirm=true after the user approved the total, and an idempotency_key (a new unique string; reuse it only to retry after a timeout). pay_rate >= 0.05 in every category, quantity >= 10. New jobs may be held for a short moderation review before going live. Optional image_prompt: a detailed description of one image we generate with AI and show workers on the job page.
It calls the "create_job" tool. An empty p.IdempotencyKey is replaced by a new key, which is reused when the call is retried, so the action never happens twice.
func (*Client) CreatePrefilledJob ¶
func (c *Client) CreatePrefilledJob(ctx context.Context, p CreatePrefilledJobParams) (map[string]any, error)
CreatePrefilledJob posts a ready-made job from a link, e.g. Instagram followers or YouTube likes; get_platform_info lists the types and the link each expects. Charges pay_rate x quantity + commission. Requires quote_id from preview_job_cost (kind "job"), confirm=true and an idempotency_key. pay_rate >= 0.05 (default 0.05), quantity >= 10. Set approve_once_full=true to approve all submissions automatically once the job is full. Optional image_prompt: a detailed description of one image we generate with AI and show workers.
It calls the "create_prefilled_job" tool. An empty p.IdempotencyKey is replaced by a new key, which is reused when the call is retried, so the action never happens twice.
func (*Client) CreateSurvey ¶
CreateSurvey posts a survey that real workers answer on RapidWorkers, built from your questions (choice, dropdown, rating with stars, agree scales or NPS, matrix, ranking, text, number, date, consent, text blocks and attention checks), and charges pay_rate x quantity + commission. No extra access is needed. Requires quote_id from preview_job_cost with kind "survey", confirm=true and an idempotency_key. pay_rate >= 0.50 per response, quantity 10 to 20,000, countries required. Questions are keyed q_1, q_2, ... by position (text blocks count): show_if may only point at an earlier question. Up to 5 screening questions must come first; screened-out workers are not paid and free their slot. Add 1 attention check (2 for surveys over 5 minutes). Every response gets a quality score; failed attention checks, impossible speed and repeat devices are rejected automatically. Optional image_prompt: one image we generate with AI and show workers with the survey intro.
It calls the "create_survey" tool. An empty p.IdempotencyKey is replaced by a new key, which is reused when the call is retried, so the action never happens twice.
func (*Client) ExtendJob ¶
ExtendJob adds worker slots to a job and charges pay_rate x additional_quantity + commission. Regular jobs can only be extended once completed; surveys and AI tasks can have at most 20,000 slots in total. Requires confirm=true and an idempotency_key. Set kind to "survey" for surveys made with create_survey or "ai_task" for AI data-collection tasks; the default "job" covers regular and prefilled jobs.
It calls the "extend_job" tool. An empty p.IdempotencyKey is replaced by a new key, which is reused when the call is retried, so the action never happens twice.
func (*Client) GetAccount ¶
GetAccount returns the account balance (USD), whether the account has made a deposit (required before posting jobs), AI task access status and the commission rate added to job costs.
It calls the "get_account" tool.
func (*Client) GetDepositLink ¶
func (c *Client) GetDepositLink(ctx context.Context, p GetDepositLinkParams) (map[string]any, error)
GetDepositLink creates a hosted checkout page and returns its URL for the account owner to open and pay. It does not charge anything by itself. Minimum $20. method "card" (Stripe; a 4% processing fee is deducted from the credited amount) or "crypto". The balance is credited only after payment completes; check get_account afterwards.
It calls the "get_deposit_link" tool. It is not resent after a network or gateway error, because it may already have run.
func (*Client) GetJob ¶
GetJob returns one job, survey or AI task by id with its brief, pay, targeting and progress; for a survey also its questions (keys q_1, q_2, ... with option ids), audience, response counts and quality bands. Set kind to "survey" for surveys made with create_survey or "ai_task" for AI data-collection tasks; the default "job" covers regular and prefilled jobs.
It calls the "get_job" tool.
func (*Client) GetPlatformInfo ¶
func (c *Client) GetPlatformInfo(ctx context.Context, p GetPlatformInfoParams) (map[string]any, error)
GetPlatformInfo returns platform rules (minimum pay $0.05 per task, $0.10 for AI tasks, $0.50 per survey response, at least 10 workers per job, $20 minimum deposit, commission and fees), job categories with sub-category codes, the prefilled job types with the link each one expects, AI task types, the survey builder options (question types, scale presets, attention check templates, limits and audience codes) and the allowed ISO country codes. Call it before creating a job or survey.
It calls the "get_platform_info" tool.
func (*Client) GetSurveyResults ¶
func (c *Client) GetSurveyResults(ctx context.Context, p GetSurveyResultsParams) (map[string]any, error)
GetSurveyResults returns the aggregated results of a survey (job_id from create_survey or list_jobs with kind "survey"): the response funnel (started, screened out, submitted, pending, approved, rejected), median time and effective hourly pay, quality bands, and per question the answer counts and percentages, means and medians, the NPS score, rankings, number ranges and the latest text answers. include "valid" (default: pending and approved responses), "approved" or "all" (adds rejected); screened-out workers never count. For each response in full use list_submissions with kind "survey".
It calls the "get_survey_results" tool.
func (*Client) ListBlockedWorkers ¶
ListBlockedWorkers lists the workers this account has blocked.
It calls the "list_blocked_workers" tool.
func (*Client) ListJobs ¶
ListJobs lists the account's jobs with status (Pending, Active, Completed, Canceled, Rejected), progress and pending submission counts, newest first. Set kind to "survey" for surveys made with create_survey or "ai_task" for AI data-collection tasks; the default "job" covers regular and prefilled jobs.
It calls the "list_jobs" tool.
func (*Client) ListSubmissions ¶
func (c *Client) ListSubmissions(ctx context.Context, p ListSubmissionsParams) (map[string]any, error)
ListSubmissions lists submissions for a job, newest first, filtered by status (Pending, Approved, Rejected). Each has the proof text, proof image links and the worker's approval rate. For kind "survey" each response has its answers (question key, label and the answer as text), a quality score (0-100), a quality band (good, check, likely_bad) with the flags behind it, and whether it was rejected automatically; quality_band filters by band. Paginated with page and page_size (max 100). Pending submissions are approved automatically after 2 days if not reviewed. Set kind to "survey" for surveys made with create_survey or "ai_task" for AI data-collection tasks; the default "job" covers regular and prefilled jobs.
It calls the "list_submissions" tool.
func (*Client) ListTools ¶
ListTools returns the live tool definitions (name, title, description, inputSchema, annotations).
func (*Client) ListTransactions ¶
ListTransactions returns the 20 most recent balance transactions (deposits, job charges, refunds).
It calls the "list_transactions" tool.
func (*Client) PreviewJobCost ¶
func (c *Client) PreviewJobCost(ctx context.Context, p PreviewJobCostParams) (map[string]any, error)
PreviewJobCost calculates the exact charge for a job, survey or AI task before creating it: pay rate x quantity + commission (+ $10 if a regular job is pinned), whether the balance covers it, and a quote_id valid for 10 minutes. Every create tool requires this quote_id, so call this first with the kind you will create ("job", "survey" or "ai_task") and show the total to the user. Rules: pay_rate >= 0.05 (>= 0.10 for kind "ai_task", >= 0.50 for kind "survey"), quantity >= 10 (at most 20,000 for AI tasks and surveys), pin only for kind "job".
It calls the "preview_job_cost" tool.
func (*Client) RejectSubmission ¶
func (c *Client) RejectSubmission(ctx context.Context, p RejectSubmissionParams) (map[string]any, error)
RejectSubmission rejects a Pending submission; the worker is not paid and sees the reason. Never reject an Approved submission: it has already been paid, and rejecting it does not take the payment back. reason is required and should say exactly what was missing. Requires an idempotency_key. Set kind to "survey" for surveys made with create_survey or "ai_task" for AI data-collection tasks; the default "job" covers regular and prefilled jobs.
It calls the "reject_submission" tool. An empty p.IdempotencyKey is replaced by a new key, which is reused when the call is retried, so the action never happens twice.
func (*Client) RequestAITaskAccess ¶
func (c *Client) RequestAITaskAccess(ctx context.Context, p RequestAITaskAccessParams) (map[string]any, error)
RequestAITaskAccess sends a request to enable AI data-collection tasks for this account, or returns the current status. An admin reviews requests; until approved, create_ai_task fails.
It calls the "request_ai_task_access" tool.
func (*Client) UnblockWorker ¶
UnblockWorker removes a worker from the block list.
It calls the "unblock_worker" tool.
type ConnectionError ¶
type ConnectionError struct {
// Err is the transport error.
Err error
}
ConnectionError means the request did not reach RapidWorkers or got no answer in time. When the context was canceled or timed out, errors.Is(err, context.Canceled) or context.DeadlineExceeded is true.
A call that moves money may still have run: resend it with the same idempotency key (set Params.IdempotencyKey yourself to control it).
func (*ConnectionError) Error ¶
func (e *ConnectionError) Error() string
func (*ConnectionError) Unwrap ¶
func (e *ConnectionError) Unwrap() error
Unwrap returns the transport error.
type CreateAITaskParams ¶
type CreateAITaskParams struct {
// Required. image_collection, video_collection or audio_collection (workers
// upload files), text_collection (written answers) or custom_data_collection
// (a form you define in submission_fields). For a questionnaire use
// create_survey instead.
TaskType AITaskType `json:"task_type"`
// Required. Short title workers see in the job list (up to 200 characters).
Title string `json:"title"`
// Required. What the data is for and what to capture, in plain words workers
// understand.
Description string `json:"description"`
// Required. Exact rules each submission must meet (count, framing, length,
// quality); used to review the work.
SubmissionInstructions string `json:"submission_instructions"`
// Required. USD paid to each worker, at least 0.10, at most 2 decimals.
PayRate float64 `json:"pay_rate"`
// Required. Number of workers (one submission each). At least 10; AI tasks and
// surveys at most 20,000.
Quantity int `json:"quantity"`
// Required. Honest estimate of the minutes one worker needs to finish the
// task.
LengthInMinutes int `json:"length_in_minutes"`
// Required. ISO 3166-1 alpha-2 codes of the countries workers must be in, e.g.
// ["US", "GB"], or ["All"] for every country. get_platform_info lists the
// allowed codes. Required for AI tasks.
Countries []string `json:"countries"`
// Required. quote_id from preview_job_cost for exactly this kind, pay rate,
// quantity and pin. Valid for 10 minutes.
QuoteID string `json:"quote_id"`
// Required. Must be true, and only after the user explicitly approved this
// action and its cost.
Confirm bool `json:"confirm"`
// Files each worker uploads (1 to 200). Required for image, video and audio
// collection; ignored otherwise.
RequiredFileCount *int `json:"required_file_count,omitempty"`
// Audio and video only: "upload" files, "record" in the browser, or "both"
// (default).
CaptureMode CaptureMode `json:"capture_mode,omitempty"`
// custom_data_collection only: the form workers fill in, in order. Fields get
// keys field_1, field_2, ... by position.
SubmissionFields []SubmissionField `json:"submission_fields,omitempty"`
// Optional: minutes a worker holds a slot while working (1 to 4320). Leave out
// for the default.
ReservationMinutes *int `json:"reservation_minutes,omitempty"`
// Only with countries ["All"] (or omitted): country codes to leave out.
ExcludedCountries []string `json:"excluded_countries,omitempty"`
// Optional, recommended when a picture would help workers. Describe ONE image
// we generate with AI (no extra cost) and show workers next to the
// instructions; it appears a minute or two after creation. We expand your
// description into a full design brief using the job details, so focus on
// intent and specifics: what the image is for (e.g. an example of a correct
// submission), photo or illustration, the exact layout and count (a grid of 2,
// 3, 4, 6 or 9 works best), what each part shows, and any exact text in quotes
// (a title, short labels). Example: "Photorealistic 3x3 grid of the same adult
// from nine angles (front, left 45, right 45, left profile, right profile,
// looking up, looking down, tilt left, tilt right), plain light background, a
// label under each photo, title "Required face angles"". If you do not know
// what the image should show (the product, page or expected result), ask the
// user before creating. Leave out if no image is wanted.
ImagePrompt *string `json:"image_prompt,omitempty"`
// Optional. Created automatically when empty and reused on retries. A new
// unique string for this action (e.g. a UUID; letters, digits, _ . : - only,
// up to 128). Send the same key again only to retry a call that timed out or
// could not reach the API, so it is never done twice. After an error answer,
// fix the cause and use a new key: the API replays its stored answer to a
// reused key.
IdempotencyKey string `json:"idempotency_key,omitempty"`
}
CreateAITaskParams are the arguments of Client.CreateAITask.
type CreateJobParams ¶
type CreateJobParams struct {
// Required. Short title workers see in the job list (up to 200 characters).
Title string `json:"title"`
// Required. Step-by-step instructions for the worker: what to do, where, and
// any rules. Plain text: put each step on its own line starting with "1.",
// "2." (or "-" for bullets); workers see them as a list and web addresses as
// links. HTML tags are not needed.
Description string `json:"description"`
// Required. What the worker must submit as proof, e.g. "Screenshot of your
// comment showing your username".
ProofRequired string `json:"proof_required"`
// Required. Category name from get_platform_info, e.g. "Social Media".
Category string `json:"category"`
// Required. Sub-category code from get_platform_info within that category,
// e.g. "2301".
SubCategory string `json:"sub_category"`
// Required. USD paid to each worker, at most 2 decimals. At least 0.05 (0.10
// for AI tasks, 0.50 for surveys).
PayRate float64 `json:"pay_rate"`
// Required. Number of workers (one submission each). At least 10; AI tasks and
// surveys at most 20,000.
Quantity int `json:"quantity"`
// Required. Honest estimate of the minutes one worker needs to finish the
// task.
LengthInMinutes int `json:"length_in_minutes"`
// Required. quote_id from preview_job_cost for exactly this kind, pay rate,
// quantity and pin. Valid for 10 minutes.
QuoteID string `json:"quote_id"`
// Required. Must be true, and only after the user explicitly approved this
// action and its cost.
Confirm bool `json:"confirm"`
// ISO 3166-1 alpha-2 codes of the countries workers must be in, e.g. ["US",
// "GB"], or ["All"] for every country. get_platform_info lists the allowed
// codes.
Countries []string `json:"countries,omitempty"`
// Only with countries ["All"] (or omitted): country codes to leave out.
ExcludedCountries []string `json:"excluded_countries,omitempty"`
// Pin the job to the top of the job list for $10 (must match the quote).
// Default false.
Pin *bool `json:"pin,omitempty"`
// true approves and pays every submission automatically once all slots are
// filled, without review. Default false: review them with list_submissions
// (unreviewed ones are approved after 2 days).
ApproveOnceFull *bool `json:"approve_once_full,omitempty"`
// Optional, recommended when a picture would help workers. Describe ONE image
// we generate with AI (no extra cost) and show workers next to the
// instructions; it appears a minute or two after creation. We expand your
// description into a full design brief using the job details, so focus on
// intent and specifics: what the image is for (e.g. an example of a correct
// submission), photo or illustration, the exact layout and count (a grid of 2,
// 3, 4, 6 or 9 works best), what each part shows, and any exact text in quotes
// (a title, short labels). Example: "Photorealistic 3x3 grid of the same adult
// from nine angles (front, left 45, right 45, left profile, right profile,
// looking up, looking down, tilt left, tilt right), plain light background, a
// label under each photo, title "Required face angles"". If you do not know
// what the image should show (the product, page or expected result), ask the
// user before creating. Leave out if no image is wanted.
ImagePrompt *string `json:"image_prompt,omitempty"`
// Optional. Created automatically when empty and reused on retries. A new
// unique string for this action (e.g. a UUID; letters, digits, _ . : - only,
// up to 128). Send the same key again only to retry a call that timed out or
// could not reach the API, so it is never done twice. After an error answer,
// fix the cause and use a new key: the API replays its stored answer to a
// reused key.
IdempotencyKey string `json:"idempotency_key,omitempty"`
}
CreateJobParams are the arguments of Client.CreateJob.
type CreatePrefilledJobParams ¶
type CreatePrefilledJobParams struct {
// Required. Prefilled job type. get_platform_info (section
// prefilled_job_types) shows the link each type expects.
Type PrefilledJobType `json:"type"`
// Required. Full URL of the post, profile or page, on the platform the type is
// for.
Link string `json:"link"`
// Required. Number of workers (one submission each). At least 10; AI tasks and
// surveys at most 20,000.
Quantity int `json:"quantity"`
// Required. quote_id from preview_job_cost for exactly this kind, pay rate,
// quantity and pin. Valid for 10 minutes.
QuoteID string `json:"quote_id"`
// Required. Must be true, and only after the user explicitly approved this
// action and its cost.
Confirm bool `json:"confirm"`
// USD paid to each worker, at least 0.05 (default 0.05), at most 2 decimals.
PayRate *float64 `json:"pay_rate,omitempty"`
// ISO 3166-1 alpha-2 codes of the countries workers must be in, e.g. ["US",
// "GB"], or ["All"] for every country. get_platform_info lists the allowed
// codes.
Countries []string `json:"countries,omitempty"`
// Only with countries ["All"] (or omitted): country codes to leave out.
ExcludedCountries []string `json:"excluded_countries,omitempty"`
// true approves and pays every submission automatically once all slots are
// filled, without review. Default false: review them with list_submissions
// (unreviewed ones are approved after 2 days).
ApproveOnceFull *bool `json:"approve_once_full,omitempty"`
// Optional, recommended when a picture would help workers. Describe ONE image
// we generate with AI (no extra cost) and show workers next to the
// instructions; it appears a minute or two after creation. We expand your
// description into a full design brief using the job details, so focus on
// intent and specifics: what the image is for (e.g. an example of a correct
// submission), photo or illustration, the exact layout and count (a grid of 2,
// 3, 4, 6 or 9 works best), what each part shows, and any exact text in quotes
// (a title, short labels). Example: "Photorealistic 3x3 grid of the same adult
// from nine angles (front, left 45, right 45, left profile, right profile,
// looking up, looking down, tilt left, tilt right), plain light background, a
// label under each photo, title "Required face angles"". If you do not know
// what the image should show (the product, page or expected result), ask the
// user before creating. Leave out if no image is wanted.
ImagePrompt *string `json:"image_prompt,omitempty"`
// Optional. Created automatically when empty and reused on retries. A new
// unique string for this action (e.g. a UUID; letters, digits, _ . : - only,
// up to 128). Send the same key again only to retry a call that timed out or
// could not reach the API, so it is never done twice. After an error answer,
// fix the cause and use a new key: the API replays its stored answer to a
// reused key.
IdempotencyKey string `json:"idempotency_key,omitempty"`
}
CreatePrefilledJobParams are the arguments of Client.CreatePrefilledJob.
type CreateSurveyParams ¶
type CreateSurveyParams struct {
// Required. Short title workers see in the survey list (up to 200 characters).
Title string `json:"title"`
// Required. Intro workers read before they start: what the survey is about and
// anything they should know. Plain text (up to 5,000 characters), each
// paragraph on its own line. Say nothing about which answers screen people
// out.
Description string `json:"description"`
// Required. The survey items in order: 1 to 60, at most 50 that take an
// answer. Their keys are q_1, q_2, ... by position (text blocks count);
// show_if refers to them. Example: [{"type":"single_choice","label":"Do you
// drive a car at least once a
// week?","options":["Yes","No"],"screener":true,"disqualify":["No"]},{"type":"rating","label":"How
// likely are you to recommend your car brand to a
// friend?","scale":{"preset":"nps"}},{"type":"long_text","label":"What would
// make you more likely to recommend
// it?","show_if":[{"question":"q_2","operator":"lte","value":"6"}]},{"type":"attention_check","template":"select_option"}]
Questions []Question `json:"questions"`
// Required. USD paid for each completed response, at least 0.50, at most 2
// decimals. Workers see the effective hourly pay (pay_rate x 60 / minutes).
PayRate float64 `json:"pay_rate"`
// Required. Number of responses wanted (one per worker), 10 to 20,000.
Quantity int `json:"quantity"`
// Required. ISO 3166-1 alpha-2 codes of the countries workers must be in, e.g.
// ["US", "GB"], or ["All"] for every country. get_platform_info lists the
// allowed codes. Required for surveys.
Countries []string `json:"countries"`
// Required. quote_id from preview_job_cost for exactly this kind, pay rate,
// quantity and pin. Valid for 10 minutes.
QuoteID string `json:"quote_id"`
// Required. Must be true, and only after the user explicitly approved this
// action and its cost.
Confirm bool `json:"confirm"`
// Optional: honest minutes one response takes. Leave out for our estimate from
// the questions (about 8 seconds per closed question, 30 per short text and 60
// per long text answer).
LengthInMinutes *int `json:"length_in_minutes,omitempty"`
// Only with countries ["All"] (or omitted): country codes to leave out.
ExcludedCountries []string `json:"excluded_countries,omitempty"`
// Optional: who may answer, on top of countries. Leave out for everyone. Only
// workers with a completed profile match a filter, so every filter shrinks the
// pool: set only what the user asked for.
Audience *Audience `json:"audience,omitempty"`
// true stops workers pasting into text answers, so they must type them.
// Default false; pasted answers are flagged either way.
BlockPaste *bool `json:"block_paste,omitempty"`
// Optional, recommended when a picture would help workers. Describe ONE image
// we generate with AI (no extra cost) and show workers next to the
// instructions; it appears a minute or two after creation. We expand your
// description into a full design brief using the job details, so focus on
// intent and specifics: what the image is for (e.g. an example of a correct
// submission), photo or illustration, the exact layout and count (a grid of 2,
// 3, 4, 6 or 9 works best), what each part shows, and any exact text in quotes
// (a title, short labels). Example: "Photorealistic 3x3 grid of the same adult
// from nine angles (front, left 45, right 45, left profile, right profile,
// looking up, looking down, tilt left, tilt right), plain light background, a
// label under each photo, title "Required face angles"". If you do not know
// what the image should show (the product, page or expected result), ask the
// user before creating. Leave out if no image is wanted.
ImagePrompt *string `json:"image_prompt,omitempty"`
// Optional. Created automatically when empty and reused on retries. A new
// unique string for this action (e.g. a UUID; letters, digits, _ . : - only,
// up to 128). Send the same key again only to retry a call that timed out or
// could not reach the API, so it is never done twice. After an error answer,
// fix the cause and use a new key: the API replays its stored answer to a
// reused key.
IdempotencyKey string `json:"idempotency_key,omitempty"`
}
CreateSurveyParams are the arguments of Client.CreateSurvey.
type CreateSurveyType ¶
type CreateSurveyType string
CreateSurveyType is a value of the "type" field of Question.
single_choice (pick one), multiple_choice (pick several), dropdown (pick one from a long list), rating (one scale), matrix (several statements on one scale), ranking (order every option), short_text, long_text, number, date, consent (agree to a statement), statement (a text block, no answer) or attention_check (a platform check with its own wording).
const ( CreateSurveyTypeSingleChoice CreateSurveyType = "single_choice" CreateSurveyTypeMultipleChoice CreateSurveyType = "multiple_choice" CreateSurveyTypeDropdown CreateSurveyType = "dropdown" CreateSurveyTypeRating CreateSurveyType = "rating" CreateSurveyTypeMatrix CreateSurveyType = "matrix" CreateSurveyTypeRanking CreateSurveyType = "ranking" CreateSurveyTypeShortText CreateSurveyType = "short_text" CreateSurveyTypeLongText CreateSurveyType = "long_text" CreateSurveyTypeNumber CreateSurveyType = "number" CreateSurveyTypeDate CreateSurveyType = "date" CreateSurveyTypeConsent CreateSurveyType = "consent" CreateSurveyTypeStatement CreateSurveyType = "statement" CreateSurveyTypeAttentionCheck CreateSurveyType = "attention_check" )
Values of CreateSurveyType.
type DepositMethod ¶
type DepositMethod string
DepositMethod is a value of the "method" argument.
"card" (Stripe checkout; a 4% processing fee is deducted from the credited amount) or "crypto" (crypto invoice).
const ( DepositMethodCard DepositMethod = "card" DepositMethodCrypto DepositMethod = "crypto" )
Values of DepositMethod.
type Education ¶
type Education string
Education is a value of the "education" field of Audience.
Only workers whose profile highest education is one of these.
const ( EducationNone Education = "none" EducationPrimary Education = "primary" EducationSecondary Education = "secondary" EducationVocational Education = "vocational" EducationSomeUniversity Education = "some_university" EducationAssociate Education = "associate" EducationBachelor Education = "bachelor" EducationMaster Education = "master" EducationDoctorate Education = "doctorate" EducationProfessional Education = "professional" )
Values of Education.
type ExtendJobParams ¶
type ExtendJobParams struct {
// Required. Id of the job, survey or AI task (job_id from list_jobs or from
// the create tool).
JobID string `json:"job_id"`
// Required. Worker slots to add; the cost is pay_rate x additional_quantity +
// commission. AI tasks and surveys can have at most 20,000 slots in total.
AdditionalQuantity int `json:"additional_quantity"`
// Required. Must be true, and only after the user explicitly approved this
// action and its cost.
Confirm bool `json:"confirm"`
// "job" (default) for regular and prefilled jobs, "survey" for surveys made
// with create_survey, "ai_task" for AI data-collection tasks.
Kind Kind `json:"kind,omitempty"`
// Optional. Created automatically when empty and reused on retries. A new
// unique string for this action (e.g. a UUID; letters, digits, _ . : - only,
// up to 128). Send the same key again only to retry a call that timed out or
// could not reach the API, so it is never done twice. After an error answer,
// fix the cause and use a new key: the API replays its stored answer to a
// reused key.
IdempotencyKey string `json:"idempotency_key,omitempty"`
}
ExtendJobParams are the arguments of Client.ExtendJob.
type Genders ¶
type Genders string
Genders is a value of the "genders" field of Audience.
Only workers whose profile gender is one of these.
type GetDepositLinkParams ¶
type GetDepositLinkParams struct {
// Required. Amount in USD to deposit, at least 20.00, at most 2 decimals.
Amount float64 `json:"amount"`
// "card" (Stripe checkout; a 4% processing fee is deducted from the credited
// amount) or "crypto" (crypto invoice).
Method DepositMethod `json:"method,omitempty"`
}
GetDepositLinkParams are the arguments of Client.GetDepositLink.
type GetJobParams ¶
type GetJobParams struct {
// Required. Id of the job, survey or AI task (job_id from list_jobs or from
// the create tool).
JobID string `json:"job_id"`
// "job" (default) for regular and prefilled jobs, "survey" for surveys made
// with create_survey, "ai_task" for AI data-collection tasks.
Kind Kind `json:"kind,omitempty"`
}
GetJobParams are the arguments of Client.GetJob.
type GetPlatformInfoParams ¶
type GetPlatformInfoParams struct {
// Return only one part: limits (pay, quantity, deposit, fees), categories
// (with sub-category codes), prefilled_job_types, ai_task_types,
// survey_builder (question types, scale presets, attention check templates,
// survey limits and audience codes) or countries. Default all.
Section PlatformInfoSection `json:"section,omitempty"`
}
GetPlatformInfoParams are the arguments of Client.GetPlatformInfo.
type GetSurveyResultsParams ¶
type GetSurveyResultsParams struct {
// Required. Id of the survey (job_id from create_survey, or list_jobs with
// kind "survey").
JobID string `json:"job_id"`
// Which responses count: "valid" (default) pending and approved ones,
// "approved" only approved ones, "all" also the rejected ones. Screened-out
// workers never count.
Include Include `json:"include,omitempty"`
// Latest written answers to show per text question and "Other" box (0 to 50,
// default 10), each cut to 500 characters. list_submissions has every answer
// in full.
TextSamples *int `json:"text_samples,omitempty"`
}
GetSurveyResultsParams are the arguments of Client.GetSurveyResults.
type Include ¶
type Include string
Include is a value of the "include" argument.
Which responses count: "valid" (default) pending and approved ones, "approved" only approved ones, "all" also the rejected ones. Screened-out workers never count.
type JobStatus ¶
type JobStatus string
JobStatus is a value of the "status" argument.
Only jobs with this status.
type Kind ¶
type Kind string
Kind is a value of the "kind" argument.
"job" (default) for regular and prefilled jobs, "survey" for surveys made with create_survey, "ai_task" for AI data-collection tasks.
type ListJobsParams ¶
type ListJobsParams struct {
// "job" (default) for regular and prefilled jobs, "survey" for surveys made
// with create_survey, "ai_task" for AI data-collection tasks.
Kind Kind `json:"kind,omitempty"`
// Only jobs with this status.
Status JobStatus `json:"status,omitempty"`
// Regular jobs only: text to find in the title or description.
Search *string `json:"search,omitempty"`
// Page number, starting at 1.
Page *int `json:"page,omitempty"`
// Items per page, 1 to 100 (default 20).
PageSize *int `json:"page_size,omitempty"`
}
ListJobsParams are the arguments of Client.ListJobs.
type ListSubmissionsParams ¶
type ListSubmissionsParams struct {
// Required. Id of the job, survey or AI task (job_id from list_jobs or from
// the create tool).
JobID string `json:"job_id"`
// "job" (default) for regular and prefilled jobs, "survey" for surveys made
// with create_survey, "ai_task" for AI data-collection tasks.
Kind Kind `json:"kind,omitempty"`
// Only submissions with this status, e.g. "Pending" to review.
Status SubmissionStatus `json:"status,omitempty"`
// Surveys only: only responses in this quality band, e.g. "likely_bad" to
// check the weakest first.
QualityBand QualityBand `json:"quality_band,omitempty"`
// Page number, starting at 1.
Page *int `json:"page,omitempty"`
// Items per page, 1 to 100 (default 25).
PageSize *int `json:"page_size,omitempty"`
}
ListSubmissionsParams are the arguments of Client.ListSubmissions.
type Occupations ¶
type Occupations string
Occupations is a value of the "occupations" field of Audience.
Only workers whose profile occupation is one of these.
const ( OccupationsStudent Occupations = "student" OccupationsUnemployed Occupations = "unemployed" OccupationsHomemaker Occupations = "homemaker" OccupationsRetired Occupations = "retired" OccupationsFreelancer Occupations = "freelancer" OccupationsTechnology Occupations = "technology" OccupationsHealthcare Occupations = "healthcare" OccupationsEducation Occupations = "education" OccupationsFinance Occupations = "finance" OccupationsLegal Occupations = "legal" OccupationsEngineering Occupations = "engineering" OccupationsSales Occupations = "sales" OccupationsHospitality Occupations = "hospitality" OccupationsTransport Occupations = "transport" OccupationsConstruction Occupations = "construction" OccupationsAgriculture Occupations = "agriculture" OccupationsGovernment Occupations = "government" OccupationsMedia Occupations = "media" OccupationsScience Occupations = "science" OccupationsOther Occupations = "other" )
Values of Occupations.
type OnlyQualityBand ¶
type OnlyQualityBand string
OnlyQualityBand is a value of the "only_quality_band" argument.
Surveys only: "good" approves only the Pending responses in the good quality band; the ones to check or likely bad stay Pending for review.
const (
OnlyQualityBandGood OnlyQualityBand = "good"
)
Values of OnlyQualityBand.
type Operator ¶
type Operator string
Operator is a value of the "operator" field of ShowIf.
single_choice and dropdown: is, is_not; multiple_choice: includes, excludes; rating and number: eq, gte, lte; any of them: answered, not_answered.
const ( OperatorIs Operator = "is" OperatorIsNot Operator = "is_not" OperatorAnswered Operator = "answered" OperatorNotAnswered Operator = "not_answered" OperatorIncludes Operator = "includes" OperatorExcludes Operator = "excludes" OperatorEq Operator = "eq" OperatorGte Operator = "gte" OperatorLte Operator = "lte" )
Values of Operator.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithBaseURL ¶
WithBaseURL sets the MCP endpoint. The default is ServerURL.
func WithHTTPClient ¶
WithHTTPClient sets the HTTP client used for requests, for example to add a proxy or custom transport. The default is a new &http.Client{}.
func WithMaxRetries ¶
WithMaxRetries sets how many times a failed call is resent (default DefaultMaxRetries). 0 disables retries.
func WithTimeout ¶
WithTimeout bounds each HTTP attempt (default DefaultTimeout); retries get a fresh timeout. 0 or less means no per-attempt limit: the context passed to each call still applies.
type PlatformInfoSection ¶
type PlatformInfoSection string
PlatformInfoSection is a value of the "section" argument.
Return only one part: limits (pay, quantity, deposit, fees), categories (with sub-category codes), prefilled_job_types, ai_task_types, survey_builder (question types, scale presets, attention check templates, survey limits and audience codes) or countries. Default all.
const ( PlatformInfoSectionAll PlatformInfoSection = "all" PlatformInfoSectionLimits PlatformInfoSection = "limits" PlatformInfoSectionCategories PlatformInfoSection = "categories" PlatformInfoSectionPrefilledJobTypes PlatformInfoSection = "prefilled_job_types" PlatformInfoSectionAITaskTypes PlatformInfoSection = "ai_task_types" PlatformInfoSectionSurveyBuilder PlatformInfoSection = "survey_builder" PlatformInfoSectionCountries PlatformInfoSection = "countries" )
Values of PlatformInfoSection.
type PrefilledJobType ¶
type PrefilledJobType string
PrefilledJobType is a value of the "type" argument.
Prefilled job type. get_platform_info (section prefilled_job_types) shows the link each type expects.
const ( PrefilledJobTypeFacebookLikes PrefilledJobType = "facebook_likes" PrefilledJobTypeInstagramLikes PrefilledJobType = "instagram_likes" PrefilledJobTypeInstagramFollowers PrefilledJobType = "instagram_followers" PrefilledJobTypeTwitterLikes PrefilledJobType = "twitter_likes" PrefilledJobTypeTwitterFollowers PrefilledJobType = "twitter_followers" PrefilledJobTypeTwitterRetweets PrefilledJobType = "twitter_retweets" PrefilledJobTypeNinegagUpvotes PrefilledJobType = "ninegag_upvotes" PrefilledJobTypeYoutubeLikes PrefilledJobType = "youtube_likes" )
Values of PrefilledJobType.
type Preset ¶
type Preset string
Preset is a value of the "preset" field of Scale.
stars_5 (1-5 stars), agree_5 (1 strongly disagree to 5 strongly agree), agree_7 (1-7), nps (0-10, rating only) or custom (set min, max and the end labels).
type PreviewJobCostParams ¶
type PreviewJobCostParams struct {
// Required. USD paid to each worker, at most 2 decimals. At least 0.05 (0.10
// for AI tasks, 0.50 for surveys).
PayRate float64 `json:"pay_rate"`
// Required. Number of workers (one submission each). At least 10; AI tasks and
// surveys at most 20,000.
Quantity int `json:"quantity"`
// "job" (default) for regular and prefilled jobs, "survey" for surveys made
// with create_survey, "ai_task" for AI data-collection tasks.
Kind Kind `json:"kind,omitempty"`
// Regular jobs only: pin the job to the top of the job list for $10. Default
// false.
Pin *bool `json:"pin,omitempty"`
}
PreviewJobCostParams are the arguments of Client.PreviewJobCost.
type QualityBand ¶
type QualityBand string
QualityBand is a value of the "quality_band" argument.
Surveys only: only responses in this quality band, e.g. "likely_bad" to check the weakest first.
const ( QualityBandGood QualityBand = "good" QualityBandCheck QualityBand = "check" QualityBandLikelyBad QualityBand = "likely_bad" )
Values of QualityBand.
type Question ¶
type Question struct {
// Required. single_choice (pick one), multiple_choice (pick several), dropdown
// (pick one from a long list), rating (one scale), matrix (several statements
// on one scale), ranking (order every option), short_text, long_text, number,
// date, consent (agree to a statement), statement (a text block, no answer) or
// attention_check (a platform check with its own wording).
Type CreateSurveyType `json:"type"`
// The question as workers see it, plain text (up to 500 characters). Required
// except for attention_check. statement: the heading; consent: what the worker
// agrees to.
Label *string `json:"label,omitempty"`
// Optional note under the question (up to 1,000 characters); for a statement,
// its body text.
HelpText *string `json:"help_text,omitempty"`
// Whether an answer is needed (default true). Screening questions and
// attention checks are always required.
Required *bool `json:"required,omitempty"`
// single_choice and multiple_choice: 2 to 20 choices; dropdown: 2 to 100;
// ranking: 2 to 10 items to put in order. Unique texts up to 200 characters.
// Leave "Other" and "None of the above" out: use allow_other and none_option.
Options []string `json:"options,omitempty"`
// single_choice and multiple_choice: add "Other (please specify)" with a
// write-in box.
AllowOther *bool `json:"allow_other,omitempty"`
// multiple_choice: text of an exclusive choice that clears the others, e.g.
// "None of the above".
NoneOption *string `json:"none_option,omitempty"`
// single_choice, multiple_choice and ranking: shuffle the options for each
// worker (Other and None stay last), against order bias in unordered lists.
RandomizeOptions *bool `json:"randomize_options,omitempty"`
// multiple_choice: fewest choices a worker must tick.
MinChoices *int `json:"min_choices,omitempty"`
// multiple_choice: most choices a worker may tick.
MaxChoices *int `json:"max_choices,omitempty"`
// rating and matrix: the answer scale. Default stars_5 for rating, agree_5 for
// matrix.
Scale *Scale `json:"scale,omitempty"`
// matrix: 2 to 10 statements, each rated on the shared scale.
Rows []string `json:"rows,omitempty"`
// short_text and long_text: fewest characters.
MinLength *int `json:"min_length,omitempty"`
// short_text (up to 500, default 500) and long_text (up to 10,000, default
// 2,000): most characters.
MaxLength *int `json:"max_length,omitempty"`
// number: smallest allowed answer.
Min *float64 `json:"min,omitempty"`
// number: largest allowed answer.
Max *float64 `json:"max,omitempty"`
// number: whole numbers only.
Integer *bool `json:"integer,omitempty"`
// Show this item only when every condition holds (up to 3). Not on screening
// questions or attention checks. Hidden questions are skipped and never
// required.
ShowIf []ShowIf `json:"show_if,omitempty"`
// Screening question (single_choice, multiple_choice or dropdown; up to 5, all
// before any other question). A worker who picks a disqualify answer leaves
// the survey unpaid, without a rejection, and the slot reopens.
Screener *bool `json:"screener,omitempty"`
// Screening questions only: the exact option texts that screen a worker out
// (at least one option must let them continue). Never shown to workers.
Disqualify []string `json:"disqualify,omitempty"`
// Start a new page at this item. A page break always follows the screening
// questions.
PageBreakBefore *bool `json:"page_break_before,omitempty"`
// attention_check only: select_option (pick the named colour), agree_scale
// (pick the named agreement level) or nonsense_statement (disagree with an
// absurd statement). The platform writes the wording and the right answer for
// each worker.
Template Template `json:"template,omitempty"`
}
Question is one element of the "questions" argument.
type RateLimitError ¶
type RateLimitError struct {
APIError
// RetryAfter is the wait the server asked for in its Retry-After
// header, or 0 when it sent none.
RetryAfter time.Duration
}
RateLimitError means too many requests were sent with this API key (HTTP 429). It is returned once the retries are used up.
func (*RateLimitError) Unwrap ¶
func (e *RateLimitError) Unwrap() error
Unwrap returns the underlying APIError.
type RejectSubmissionParams ¶
type RejectSubmissionParams struct {
// Required. Id of the job, survey or AI task (job_id from list_jobs or from
// the create tool).
JobID string `json:"job_id"`
// Required. submission_id from list_submissions.
SubmissionID int `json:"submission_id"`
// Required. Shown to the worker: exactly what was missing or wrong compared
// with the instructions.
Reason string `json:"reason"`
// "job" (default) for regular and prefilled jobs, "survey" for surveys made
// with create_survey, "ai_task" for AI data-collection tasks.
Kind Kind `json:"kind,omitempty"`
// Optional. Created automatically when empty and reused on retries. A new
// unique string for this action (e.g. a UUID; letters, digits, _ . : - only,
// up to 128). Send the same key again only to retry a call that timed out or
// could not reach the API, so it is never done twice. After an error answer,
// fix the cause and use a new key: the API replays its stored answer to a
// reused key.
IdempotencyKey string `json:"idempotency_key,omitempty"`
}
RejectSubmissionParams are the arguments of Client.RejectSubmission.
type RequestAITaskAccessParams ¶
type RequestAITaskAccessParams struct {
// Optional: what data you plan to collect, so the team can approve faster.
Note *string `json:"note,omitempty"`
}
RequestAITaskAccessParams are the arguments of Client.RequestAITaskAccess.
type Scale ¶
type Scale struct {
// stars_5 (1-5 stars), agree_5 (1 strongly disagree to 5 strongly agree),
// agree_7 (1-7), nps (0-10, rating only) or custom (set min, max and the end
// labels).
Preset Preset `json:"preset,omitempty"`
// custom only: the first point, 0 or 1.
Min *int `json:"min,omitempty"`
// custom only: the last point; 2 to 11 points in all (a matrix 2 to 7).
Max *int `json:"max,omitempty"`
// custom only: text at the low end, e.g. "Not at all".
MinLabel *string `json:"min_label,omitempty"`
// custom only: text at the high end, e.g. "Very much".
MaxLabel *string `json:"max_label,omitempty"`
}
Scale is one element of the "scale" argument.
rating and matrix: the answer scale. Default stars_5 for rating, agree_5 for matrix.
type ServiceUnavailableError ¶
type ServiceUnavailableError struct {
}
ServiceUnavailableError means RapidWorkers is temporarily unavailable (HTTP 502, 503 or 504). It is returned once the retries are used up, or at once after a 502 or 504 for a call that is not safe to resend.
func (*ServiceUnavailableError) Unwrap ¶
func (e *ServiceUnavailableError) Unwrap() error
Unwrap returns the underlying APIError.
type ShowIf ¶
type ShowIf struct {
// Required. Key of an EARLIER single_choice, multiple_choice, dropdown,
// rating, number, text, date or consent question, e.g. "q_2".
Question string `json:"question"`
// Required. single_choice and dropdown: is, is_not; multiple_choice: includes,
// excludes; rating and number: eq, gte, lte; any of them: answered,
// not_answered.
Operator Operator `json:"operator"`
// is, is_not, includes, excludes: the exact option text (or "other", or the
// none_option text). eq, gte, lte: a number written as text, e.g. "7". Leave
// out for answered and not_answered.
Value *string `json:"value,omitempty"`
}
ShowIf is one element of the "show_if" argument.
type SubmissionField ¶
type SubmissionField struct {
// Required. Field type.
Type SubmissionFieldType `json:"type"`
// Required. Question or label shown to the worker.
Label string `json:"label"`
// Optional extra instructions for this field.
HelpText *string `json:"help_text,omitempty"`
// Whether the worker must answer (default true).
Required *bool `json:"required,omitempty"`
// image/audio/video fields: fewest files.
MinFiles *int `json:"min_files,omitempty"`
// image/audio/video fields: most files (default 1).
MaxFiles *int `json:"max_files,omitempty"`
// select fields: the choices (2 to 100).
Options []string `json:"options,omitempty"`
// Dependent select only: key of an earlier plain select (e.g. "field_1").
ParentKey *string `json:"parent_key,omitempty"`
// Dependent select only: for every option of the parent, the list of choices,
// e.g. {"Cars": ["Sedan", "SUV"]}.
OptionsByParent map[string]any `json:"options_by_parent,omitempty"`
}
SubmissionField is one element of the "submission_fields" argument.
type SubmissionFieldType ¶
type SubmissionFieldType string
SubmissionFieldType is a value of the "type" field of SubmissionField.
Field type.
const ( SubmissionFieldTypeShortText SubmissionFieldType = "short_text" SubmissionFieldTypeLongText SubmissionFieldType = "long_text" SubmissionFieldTypeSelect SubmissionFieldType = "select" SubmissionFieldTypeDatetime SubmissionFieldType = "datetime" SubmissionFieldTypeConsent SubmissionFieldType = "consent" SubmissionFieldTypeImage SubmissionFieldType = "image" SubmissionFieldTypeAudio SubmissionFieldType = "audio" SubmissionFieldTypeVideo SubmissionFieldType = "video" )
Values of SubmissionFieldType.
type SubmissionStatus ¶
type SubmissionStatus string
SubmissionStatus is a value of the "status" argument.
Only submissions with this status, e.g. "Pending" to review.
const ( SubmissionStatusPending SubmissionStatus = "Pending" SubmissionStatusApproved SubmissionStatus = "Approved" SubmissionStatusRejected SubmissionStatus = "Rejected" )
Values of SubmissionStatus.
type Template ¶
type Template string
Template is a value of the "template" field of Question.
attention_check only: select_option (pick the named colour), agree_scale (pick the named agreement level) or nonsense_statement (disagree with an absurd statement). The platform writes the wording and the right answer for each worker.
type ToolError ¶
type ToolError struct {
// Tool is the name of the tool, such as "create_job".
Tool string
// Message says what was wrong and how to fix the call.
Message string
// Code is the machine-readable error code, such as
// "insufficient_balance", or "" when the server sent none.
Code string
// Details is the structured error the server sent, without its message
// (for example code, fields or replayed).
Details map[string]any
}
ToolError means the tool ran and refused the call. Message says how to fix it.
Typical causes are a validation error, an insufficient balance, a stale quote_id or a job in the wrong state.
Example ¶
package main
import (
"context"
"errors"
"fmt"
"log"
rapidworkers "github.com/RapidWorkers-io/rapidworkers/go"
)
func main() {
ctx := context.Background()
rw, err := rapidworkers.NewClient("your-api-key")
if err != nil {
log.Fatal(err)
}
_, err = rw.CreateJob(ctx, rapidworkers.CreateJobParams{ /* ... */ })
var toolErr *rapidworkers.ToolError
if errors.As(err, &toolErr) {
// The tool refused the call; Message says how to fix it.
fmt.Println(toolErr.Code, toolErr.Message)
}
}
Output:
type UnblockWorkerParams ¶
type UnblockWorkerParams struct {
// Required. worker_id from list_blocked_workers.
WorkerID int `json:"worker_id"`
}
UnblockWorkerParams are the arguments of Client.UnblockWorker.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
rapidworkers-mcp
command
Command rapidworkers-mcp is a stdio MCP server that relays every request to the hosted RapidWorkers MCP server.
|
Command rapidworkers-mcp is a stdio MCP server that relays every request to the hosted RapidWorkers MCP server. |
|
internal
|
|
|
jsonrpc
Package jsonrpc finds the JSON-RPC answer in a response from the hosted RapidWorkers MCP server.
|
Package jsonrpc finds the JSON-RPC answer in a response from the hosted RapidWorkers MCP server. |