Registration /entity.find Call Examples

The /entity endpoint of the Janrain RESTful API is the most direct means of querying, modifying, and deleting the user data that is stored in your database.

While some calls enable you to manage the information of a specific user—e.g. the /entity.update and /entity.create calls—sometimes it is necessary to query your entire database to find users on the basis of general attributes, such as whether or not an email address is present, whether or not the user is within a certain age demographic, and so on.

These queries can be accomplished using the /entity.find API endpoint. This endpoint is characterized by enabling you to specify a filter parameter that uses an extremely simple querying language that enables you to construct arbitrarily complex queries.

Note: All API calls to your database require a client_id and client_secret. These can be obtained within your Janrain Dashboard. All API calls in the example below will be for entities of the type user, and all client_ids and client_secrets will be used as if they were stored as environment variables:

export JANRAIN_CLIENT_ID=1234abcd1234abcd1234abcd
export JANRAIN_CLIENT_SECRET=abcd1234abcd1234abcd1234
set JANRAIN_CLIENT_ID=1234abcd1234abcd1234abcd
set JANRAIN_CLIENT_SECRET=abcd1234abcd1234abcd1234

Example 1: Find All Users within an Age Demographic

Let’s say that you want to find all female users in your Capture database that are between the ages of 25 and 50. Here’s an example API call:

curl -X POST http://{your_domain}.janraincapture.com/entity.find \
-d client_id=$JANRAIN_CLIENT_ID \
-d client_secret=$JANRAIN_CLIENT_SECRET \
-d type_name=user \
-d filter="age > 25 and age < 50 and gender='female'"

Example 2: Find the First 500 Users with Known Birthdays

curl -X POST http://{your_domain}.janraincapture.com/entity.find \
-d client_id=$JANRAIN_CLIENT_ID \
-d client_secret=$JANRAIN_CLIENT_SECRET \
-d type_name=user \
-d max_results=500 \
-d filter="birthday is not null"

Example 3: Find All 30-Year-Old Users Named Dave Born on August 2, 1975

curl -X POST http://{your_domain}.janraincapture.com/entity.find \
-d client_id=$JANRAIN_CLIENT_ID \
-d client_secret=$JANRAIN_CLIENT_SECRET \
-d type_name=user \
-d filter="age=30 and firstName is not null and firstName='Dave' and birthday='1975-08-02'"

Example 4: Find All Users Over the Age of 50, Sorted by Most Recently Updated

curl -X POST http://{your_domain}.janraincapture.com/entity.find \
-d client_id=$JANRAIN_CLIENT_ID \
-d client_secret=$JANRAIN_CLIENT_SECRET \
-d type_name=user \
-d sort_on=["-lastUpdated"] \
-d filter="age > 50"

Example 5: Find the Email Address of All Users with the Name Brenda

curl -X POST http://{your_domain}.janraincapture.com/entity.find \
-d client_id=$JANRAIN_CLIENT_ID \
-d client_secret=$JANRAIN_CLIENT_SECRET \
-d type_name=user \
-d attributes=["email"] \
-d filter="firstName='Brenda'"