# Count participants POST https://api.prolific.com/api/v1/eligibility-count/ Content-Type: application/json Count how many participants meet all the given filters. Only participants that pass **every one** of the filters are counted. Zero means that there are less than 25 participants. We do not show lower numbers to protect the privacy of the participants. To see a list of filters that may be passed to this endpoint, see the documentation for filters. Reference: https://beta-docs.prolific.com/api-reference/filters/get-eligible-count ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Count participants version: endpoint_filters.GetEligibleCount paths: /api/v1/eligibility-count/: post: operationId: get-eligible-count summary: Count participants description: >- Count how many participants meet all the given filters. Only participants that pass **every one** of the filters are counted. Zero means that there are less than 25 participants. We do not show lower numbers to protect the privacy of the participants. To see a list of filters that may be passed to this endpoint, see the documentation for filters. tags: - - subpackage_filters parameters: - name: Authorization in: header description: Header authentication of the form `undefined ` required: true schema: type: string responses: '200': description: Count content: application/json: schema: $ref: '#/components/schemas/RequirementsCount' '400': description: Error content: {} requestBody: content: application/json: schema: $ref: '#/components/schemas/RequirementsCountRequest' components: schemas: SelectFilter: type: object properties: filter_id: type: string description: ID of the "select" type filter. selected_values: type: array items: type: string description: >- This schema applies for filters of the `select` type, as defined in the [filter list response](\#tag/Filters/paths/~1api~1v1~1filters~1/get). Array of IDs matching the response IDs, from the `select` filter's `choices` (see response linked above). String format should match the `data_type` of the `select` filter's `choices` (see response linked above). weightings: type: object additionalProperties: type: number format: double description: >- Ratios to control the distribution of participants across the selected values. Integer percentages, floats, and exact quantities are valid inputs. required: - filter_id - selected_values RangeFilterSelectedRangeLower: oneOf: - type: integer - type: string - type: number format: double RangeFilterSelectedRangeUpper: oneOf: - type: integer - type: string - type: number format: double RangeFilterSelectedRange: type: object properties: lower: $ref: '#/components/schemas/RangeFilterSelectedRangeLower' description: Your selected lower bound for the range. upper: $ref: '#/components/schemas/RangeFilterSelectedRangeUpper' description: Your selected upper bound for the range. RangeFilterWeightingsSelectedRangeLower: oneOf: - type: integer - type: string - type: number format: double RangeFilterWeightingsSelectedRangeUpper: oneOf: - type: integer - type: string - type: number format: double RangeFilterWeightingsSelectedRange: type: object properties: lower: $ref: '#/components/schemas/RangeFilterWeightingsSelectedRangeLower' upper: $ref: '#/components/schemas/RangeFilterWeightingsSelectedRangeUpper' RangeFilterWeightings: type: object properties: selected_range: $ref: '#/components/schemas/RangeFilterWeightingsSelectedRange' weighting: type: number format: double required: - selected_range - weighting RangeFilter: type: object properties: filter_id: type: string description: ID of the "range" type filter. selected_range: $ref: '#/components/schemas/RangeFilterSelectedRange' description: >- This schema applies for filters of the `range` type, as defined in the [filter list response](\#tag/Filters/paths/~1api~1v1~1filters~1/get). A dictionary with two possible objects, 'lower' and 'upper'. At least one must be present and a non-null value. The expected data type for these values is defined by the `range` filter's `data_type` (see response linked above). If the data_type is a date, string format should be a parseable ISO8601 date string. Date values should be provided as a string in ISO 8601 format. Leaving a value as null will result in that bound being set to the lowest or highest possible value, depending on whether it is the upper or lower bound. weightings: $ref: '#/components/schemas/RangeFilterWeightings' description: >- Ratios to control the distribution of participants across the selected values. Integers and exact quantities are valid inputs. required: - filter_id - selected_range RequirementsCountRequestFiltersItems: oneOf: - $ref: '#/components/schemas/SelectFilter' - $ref: '#/components/schemas/RangeFilter' RequirementsCountRequest: type: object properties: filters: type: array items: $ref: '#/components/schemas/RequirementsCountRequestFiltersItems' description: >- List of filters to apply to the count. This parameter uses the new, simplified filters schema for interacting with eligibility. workspace_id: type: string description: >- The ID of the workspace you will be creating a study in. Due to US tax laws, non US residents may not participate in studies created by US researchers. For this reason, we use the country specified in the workspace to determine eligibility. If you do not specify a workspace ID, we will use the current workspace ID of the user making the request. Your eligibility count may not be accurate if you do not specify a workspace ID. organisation_id: type: string description: The ID of the workspace you will be creating a filterset in. required: - filters RequirementsCount: type: object properties: count: type: number format: double description: Number of participants passing all the requirements required: - count ``` ## SDK Code Examples ```python import requests url = "https://api.prolific.com/api/v1/eligibility-count/" payload = { "filters": [ { "field": "age", "operator": "gte", "value": 18 }, { "field": "enrollment_status", "operator": "eq", "value": "active" }, { "field": "gender", "operator": "in", "value": ["female", "non-binary"] } ], "workspace_id": "645e4403bdd06d5f66d8fbd8" } headers = { "Authorization": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.prolific.com/api/v1/eligibility-count/'; const options = { method: 'POST', headers: {Authorization: '', 'Content-Type': 'application/json'}, body: '{"filters":[{"field":"age","operator":"gte","value":18},{"field":"enrollment_status","operator":"eq","value":"active"},{"field":"gender","operator":"in","value":["female","non-binary"]}],"workspace_id":"645e4403bdd06d5f66d8fbd8"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.prolific.com/api/v1/eligibility-count/" payload := strings.NewReader("{\n \"filters\": [\n {\n \"field\": \"age\",\n \"operator\": \"gte\",\n \"value\": 18\n },\n {\n \"field\": \"enrollment_status\",\n \"operator\": \"eq\",\n \"value\": \"active\"\n },\n {\n \"field\": \"gender\",\n \"operator\": \"in\",\n \"value\": [\n \"female\",\n \"non-binary\"\n ]\n }\n ],\n \"workspace_id\": \"645e4403bdd06d5f66d8fbd8\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.prolific.com/api/v1/eligibility-count/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"filters\": [\n {\n \"field\": \"age\",\n \"operator\": \"gte\",\n \"value\": 18\n },\n {\n \"field\": \"enrollment_status\",\n \"operator\": \"eq\",\n \"value\": \"active\"\n },\n {\n \"field\": \"gender\",\n \"operator\": \"in\",\n \"value\": [\n \"female\",\n \"non-binary\"\n ]\n }\n ],\n \"workspace_id\": \"645e4403bdd06d5f66d8fbd8\"\n}" response = http.request(request) puts response.read_body ``` ```java HttpResponse response = Unirest.post("https://api.prolific.com/api/v1/eligibility-count/") .header("Authorization", "") .header("Content-Type", "application/json") .body("{\n \"filters\": [\n {\n \"field\": \"age\",\n \"operator\": \"gte\",\n \"value\": 18\n },\n {\n \"field\": \"enrollment_status\",\n \"operator\": \"eq\",\n \"value\": \"active\"\n },\n {\n \"field\": \"gender\",\n \"operator\": \"in\",\n \"value\": [\n \"female\",\n \"non-binary\"\n ]\n }\n ],\n \"workspace_id\": \"645e4403bdd06d5f66d8fbd8\"\n}") .asString(); ``` ```php request('POST', 'https://api.prolific.com/api/v1/eligibility-count/', [ 'body' => '{ "filters": [ { "field": "age", "operator": "gte", "value": 18 }, { "field": "enrollment_status", "operator": "eq", "value": "active" }, { "field": "gender", "operator": "in", "value": [ "female", "non-binary" ] } ], "workspace_id": "645e4403bdd06d5f66d8fbd8" }', 'headers' => [ 'Authorization' => '', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp var client = new RestClient("https://api.prolific.com/api/v1/eligibility-count/"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"filters\": [\n {\n \"field\": \"age\",\n \"operator\": \"gte\",\n \"value\": 18\n },\n {\n \"field\": \"enrollment_status\",\n \"operator\": \"eq\",\n \"value\": \"active\"\n },\n {\n \"field\": \"gender\",\n \"operator\": \"in\",\n \"value\": [\n \"female\",\n \"non-binary\"\n ]\n }\n ],\n \"workspace_id\": \"645e4403bdd06d5f66d8fbd8\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "", "Content-Type": "application/json" ] let parameters = [ "filters": [ [ "field": "age", "operator": "gte", "value": 18 ], [ "field": "enrollment_status", "operator": "eq", "value": "active" ], [ "field": "gender", "operator": "in", "value": ["female", "non-binary"] ] ], "workspace_id": "645e4403bdd06d5f66d8fbd8" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolific.com/api/v1/eligibility-count/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ```python import requests url = "https://api.prolific.com/api/v1/eligibility-count/" payload = { "filters": [ { "field": "age", "operator": "gte", "value": 18 }, { "field": "enrollment_status", "operator": "eq", "value": "active" }, { "field": "gender", "operator": "in", "value": ["female", "non-binary"] } ], "workspace_id": "645e4403bdd06d5f66d8fbd8" } headers = { "Authorization": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.prolific.com/api/v1/eligibility-count/'; const options = { method: 'POST', headers: {Authorization: '', 'Content-Type': 'application/json'}, body: '{"filters":[{"field":"age","operator":"gte","value":18},{"field":"enrollment_status","operator":"eq","value":"active"},{"field":"gender","operator":"in","value":["female","non-binary"]}],"workspace_id":"645e4403bdd06d5f66d8fbd8"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.prolific.com/api/v1/eligibility-count/" payload := strings.NewReader("{\n \"filters\": [\n {\n \"field\": \"age\",\n \"operator\": \"gte\",\n \"value\": 18\n },\n {\n \"field\": \"enrollment_status\",\n \"operator\": \"eq\",\n \"value\": \"active\"\n },\n {\n \"field\": \"gender\",\n \"operator\": \"in\",\n \"value\": [\n \"female\",\n \"non-binary\"\n ]\n }\n ],\n \"workspace_id\": \"645e4403bdd06d5f66d8fbd8\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.prolific.com/api/v1/eligibility-count/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"filters\": [\n {\n \"field\": \"age\",\n \"operator\": \"gte\",\n \"value\": 18\n },\n {\n \"field\": \"enrollment_status\",\n \"operator\": \"eq\",\n \"value\": \"active\"\n },\n {\n \"field\": \"gender\",\n \"operator\": \"in\",\n \"value\": [\n \"female\",\n \"non-binary\"\n ]\n }\n ],\n \"workspace_id\": \"645e4403bdd06d5f66d8fbd8\"\n}" response = http.request(request) puts response.read_body ``` ```java HttpResponse response = Unirest.post("https://api.prolific.com/api/v1/eligibility-count/") .header("Authorization", "") .header("Content-Type", "application/json") .body("{\n \"filters\": [\n {\n \"field\": \"age\",\n \"operator\": \"gte\",\n \"value\": 18\n },\n {\n \"field\": \"enrollment_status\",\n \"operator\": \"eq\",\n \"value\": \"active\"\n },\n {\n \"field\": \"gender\",\n \"operator\": \"in\",\n \"value\": [\n \"female\",\n \"non-binary\"\n ]\n }\n ],\n \"workspace_id\": \"645e4403bdd06d5f66d8fbd8\"\n}") .asString(); ``` ```php request('POST', 'https://api.prolific.com/api/v1/eligibility-count/', [ 'body' => '{ "filters": [ { "field": "age", "operator": "gte", "value": 18 }, { "field": "enrollment_status", "operator": "eq", "value": "active" }, { "field": "gender", "operator": "in", "value": [ "female", "non-binary" ] } ], "workspace_id": "645e4403bdd06d5f66d8fbd8" }', 'headers' => [ 'Authorization' => '', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp var client = new RestClient("https://api.prolific.com/api/v1/eligibility-count/"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"filters\": [\n {\n \"field\": \"age\",\n \"operator\": \"gte\",\n \"value\": 18\n },\n {\n \"field\": \"enrollment_status\",\n \"operator\": \"eq\",\n \"value\": \"active\"\n },\n {\n \"field\": \"gender\",\n \"operator\": \"in\",\n \"value\": [\n \"female\",\n \"non-binary\"\n ]\n }\n ],\n \"workspace_id\": \"645e4403bdd06d5f66d8fbd8\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "", "Content-Type": "application/json" ] let parameters = [ "filters": [ [ "field": "age", "operator": "gte", "value": 18 ], [ "field": "enrollment_status", "operator": "eq", "value": "active" ], [ "field": "gender", "operator": "in", "value": ["female", "non-binary"] ] ], "workspace_id": "645e4403bdd06d5f66d8fbd8" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolific.com/api/v1/eligibility-count/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```