NAV Navbar

CIP

REST API JavaScript TypeScript Android Swift Objective-C PHP .NET

Introduction

The CIP API Documentation provides an easy way to connect your App to Back4App and use all the backend resources provided by Back4App Platform.

The API closely follows REST semantics, uses JSON to encode objects, relies on standard HTTP codes to signal operation outcomes, and is mostly generated through Parse Server.

The API documentation below is specifically generated for your app CIP by Back4App Platform. If you make changes to your app's backend schema (using Parse Server Dashboard, Back4App CLI or even these APIs), the API interface for those fields will change correspondingly, and those changes will be reflected here.

Getting Started

Since these are RESTful APIs, you are free to use your preferred technology to perform HTTP requests according to this documentation. Although we highly encourage you to use them through one of the Parse SDKs for a faster and better development experience. Please find below how to install each of the supported SDKs.

Installing Parse SDK

There is not a specific Parse SDK for cURL and you just need to make sure that cURL is installed in your machine. Most of the Operational Systems bring cURL installed by default, but you can also download the latest version of it in cURL Official Web-Site.

Install Parse JavaScript SDK npm module:

npm install parse

You do not need to install nor initialize JavaScript SDK when creating Cloud Code Functions since it is installed and initialized by default.

For a React Native project:

npm install @react-native-async-storage/async-storage
npm install parse/react-native

In a Node.js project:

const Parse = require('parse/node');

Parse.serverURL = 'https://parseapi.back4app.com'; // This is your Server URL
// Remember to inform BOTH the Back4App Application ID AND the JavaScript KEY
Parse.initialize(
  'OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg', // This is your Application ID
  'Clone or connect in this app to use your own keys.', // This is your Javascript key
  'For test purpose only you can use Kq7Dv4kU7SVzqequMt7EznsvzSbORNb7g7Pd1SFn. Clone or connect in this app to use your own keys.' // This is your Master key (never use it in the frontend)
);

Install Parse JavaScript SDK npm module:

npm install parse
npm install @types/parse

For a React Native project:

npm install @react-native-async-storage/async-storage
npm install parse/react-native
npm install @types/parse

In a Node.js project:

const Parse = require('parse/node');

Parse.serverURL = 'https://parseapi.back4app.com'; // This is your Server URL
// Remember to inform BOTH the Back4App Application ID AND the JavaScript KEY
Parse.initialize(
  'OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg', // This is your Application ID
  'Clone or connect in this app to use your own keys.', // This is your Javascript key
  'For test purpose only you can use Kq7Dv4kU7SVzqequMt7EznsvzSbORNb7g7Pd1SFn. Clone or connect in this app to use your own keys.' // This is your Master key (never use it in the frontend)
);

In order to install the Parse-SDK-Android as a Gradle dependency, add this in your root build.gradle file (not your module build.gradle file!)

allprojects {
  repositories {
    ...
    maven { url "https://jitpack.io" }
  }
}

And in your module build.gradle file, add the following:

dependencies {
    ...
    implementation "com.github.parse-community.Parse-SDK-Android:parse:1.18.5"
}

Notice that the version of Parse-SDK-Android was 1.18.5 when this documentation was released. To find the latest version, check here.

There are a plenty of ways to install Parse SDK:

Option 1: Using Carthage. Add the following line to your Cartfile:

github "parse-community/Parse-SDK-iOS-OSX"
github "parse-community/Parse-SDK-iOS-OSX"

Run carthage update and it should be installed in your Carthage folder.

Option 2: Using CocoaPods. Add the following line to your Podfile:

pod 'Parse'
pod 'Parse'

Run pod install and open the generated .xcworkspace on Xcode, in order to avoid the linker error.

Option 3: Downloading the latest build here.

Option 4: Cloning the project and compiling manually:

git clone https://github.com/parse-community/Parse-SDK-iOS-OSX.git
cd ./Parse-SDK-iOS-OSX

# To pull in extra dependencies (Bolts and OCMock)
git submodule update --init --recursive

# To install all the gems
bundle install

# Build & Package the Frameworks
rake package:frameworks
git clone https://github.com/parse-community/Parse-SDK-iOS-OSX.git
cd ./Parse-SDK-iOS-OSX

# To pull in extra dependencies (Bolts and OCMock)
git submodule update --init --recursive

# To install all the gems
bundle install

# Build & Package the Frameworks
rake package:frameworks

Follow these instructions below to install .NET + Xamarin SDK usign NuGet Package

// Using Package Manager
Install-Package parse -Version 1.7.0

// Using .NET CLI
dotnet add package parse --version 1.7.0

Or install a specific release from SDK repository

SDK requires Visual Studio 2012 or Xamarin Studio and targets .NET 4.5 applications, Windows Store apps, Windows Phone 8 apps, and Xamarin.iOS 6.3+ or Xamarin.Android 4.7+ apps.

In order to Parse-SDK work properly, make sure you have at least PHP 5.4 or HHVM 3.0 installed.

Installing with Composer: Create a composer.json file in your project root folder, and add the following:

{
  "require": {
    "parse/php-sdk" : "1.4.*"
  }
}

Run the following command on your terminal to install the Parse-SDK and setup the autoloader:

composer install

And then require the autoloader on your PHP script to automatically load the Parse SDK classes:

require 'vendor/autoload.php';

Installing with Git: Clone the Parse-SDK repository using your terminal:

git clone https://github.com/parse-community/parse-php-sdk.git

And then require the autoloader in your PHP script to automatically load the Parse SDK classes:

require 'autoload.php';

Please choose below one of the Parse SDKs and learn how to install it using the instructions that you can find in the right panel of this documentation.

It is not necessary to install any Parse SDK to call the API using cURL commands. To make sure that cURL is available at your machine, open a terminal window and execute a simple cURL command. If you do not have cURL available or want to use an updated version please visit their official website.

Installing JavaScript SDK

Installing JavaScript SDK using TypeScript

Installing Android SDK

Installing iOS SDK (Swift)

Installing iOS SDK (Objective-C)

Installing PHP SDK

Installing .NET SDK

Initializing Parse SDK

You do not need to do any kind of initialization when using cURL but you must send your app's credentials in the headers of all requests that you'll do. Example:

curl -X GET \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
https://parseapi.back4app.com/serverInfo

You should not use the REST API Key in client apps. If you need to send a REST API directly from your client-side code, you must use the Parse Client Key for your currently client-side platform (e.g. Client Key for iOS/Android, or .NET Key for Windows/Xamarin/Unity).

In a React Native project, in your App.js file:

import AsyncStorage from '@react-native-async-storage/async-storage';
import Parse from 'parse/react-native';

//Before using the SDK...
Parse.setAsyncStorage(AsyncStorage);
// Remember to inform BOTH the Back4App Application ID AND the JavaScript KEY
Parse.initialize('OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg', 'Clone or connect in this app to use your own keys.');
//Point to Back4App Parse API address 
Parse.serverURL = 'https://parseapi.back4app.com'

In a Web Browser (React, Angular, Vue, etc) project:

<script src="node_modules/parse/dist/parse.min.js"></script>

<script>
Parse.serverURL = 'https://parseapi.back4app.com'; // This is your Server URL
// Remember to inform BOTH the Back4App Application ID AND the JavaScript KEY
Parse.initialize(
  'OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg', // This is your Application ID
  'Clone or connect in this app to use your own keys.' // This is your Javascript key
);
</script>

In an Ionic project:

const Parse = require('parse');

Parse.serverURL = 'https://parseapi.back4app.com'; // This is your Server URL
// Remember to inform BOTH the Back4App Application ID AND the JavaScript KEY
Parse.initialize(
  'OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg', // This is your Application ID
  'Clone or connect in this app to use your own keys.' // This is your Javascript key
);

In a React Native project, in your App.tsx file:

import AsyncStorage from '@react-native-async-storage/async-storage';
import Parse from 'parse/react-native';

//Before using the SDK...
Parse.setAsyncStorage(AsyncStorage);
// Remember to inform BOTH the Back4App Application ID AND the JavaScript KEY
Parse.initialize('OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg', 'Clone or connect in this app to use your own keys.');
//Point to Back4App Parse API address 
Parse.serverURL = 'https://parseapi.back4app.com'

In a Web Browser (React, Angular, Vue, etc) project:

<script src="node_modules/parse/dist/parse.min.js"></script>

<script>
Parse.serverURL = 'https://parseapi.back4app.com'; // This is your Server URL
// Remember to inform BOTH the Back4App Application ID AND the JavaScript KEY
Parse.initialize(
  'OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg', // This is your Application ID
  'Clone or connect in this app to use your own keys.' // This is your Javascript key
);
</script>

In an Ionic project:

const Parse = require('parse');

Parse.serverURL = 'https://parseapi.back4app.com'; // This is your Server URL
// Remember to inform BOTH the Back4App Application ID AND the JavaScript KEY
Parse.initialize(
  'OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg', // This is your Application ID
  'Clone or connect in this app to use your own keys.' // This is your Javascript key
);

First of all, you need to allow your application to have access to the internet and define its name. In your AndroidManifest.xml file, add the following:

<manifest
  ...
  >
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.INTERNET" />
</manifest>

In your Application class, initialize the Parse SDK with your Parse application ID, client key, and server:

package <YOUR_PACKAGE_NAME>;

import com.parse.Parse;
import android.app.Application;

public class YOUR_ANDROID_APPLICATION extends Application {

  // Initializes Parse SDK as soon as the application is created
  @Override
  public void onCreate() {
    super.onCreate();

    Parse.initialize(new Parse.Configuration.Builder(this)
      .applicationId("OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg")
      .clientKey("Clone or connect in this app to use your own keys.")
      .server("https://parseapi.back4app.com")
      .build()
    );
  }
}

After creating our Application class, we need to define its name on the AndroidManifest.xml file, as follows:

<manifest package="<YOUR_PACKAGE_NAME>"
  ...
  >
  <application
    android:name=".YOUR_ANDROID_APPLICATION"
    ...>
    ...
  </application>

In your application, add the following code into AppDelegate.swift and initialize the Parse SDK with your Parse application ID, client key, and server:

// AppDelegate.swift
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
  let parseConfig = ParseClientConfiguration {
      $0.applicationId = "OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg"
      $0.clientKey = "Clone or connect in this app to use your own keys."
      $0.server = "https://parseapi.back4app.com"
  }
  Parse.initialize(with: parseConfig)
}

In your application, add the following code into AppDelegate.m and initialize the Parse SDK with your Parse application ID, client key, and server:

// AppDelegate.m
[Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration>  _Nonnull configuration) {
  configuration.applicationId = @"OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg";
  configuration.clientKey = @"Clone or connect in this app to use your own keys.";
  configuration.server = @"https://parseapi.back4app.com";
}]];

After including the Parse-SDK you need to initialize the ParseClient as follows:

using Parse;

ParseClient.Initialize(new ParseClient.Configuration {
    ApplicationId = "OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg",
    WindowsKey = ""
});

You can build the library from Visual Studio 2013+ or Xamarin IDE.

// In Windows:
MSBuild Parse.sln

// In Unix with Xamarin SDK installed:
xbuild Parse.sln

After including the Parse-SDK classes, you need to initialize the ParseClient as follows:

use Parse\ParseClient;

// Initializes with the <APPLICATION_ID>, <REST_KEY>, and <MASTER_KEY>
ParseClient::initialize( "OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg", "Clone or connect in this app to use your own keys.", "For test purpose only you can use Kq7Dv4kU7SVzqequMt7EznsvzSbORNb7g7Pd1SFn. Clone or connect in this app to use your own keys." );
ParseClient::setServerURL('https://parseapi.back4app.com', '/');

After installing the Parse SDK, you have to initialize the SDK using your App keys. You can copy them below from the right panel code snippets. At any time you can also find your App keys on your App dashboard under the Security & Keys menu. You don't need to initialize the SDK if you are using cURL, but you must send your app's credentials in the headers of any requests that you'll do.

Application ID

OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

Client key

Clone or connect in this app to use your own keys.

JavaScript key

Clone or connect in this app to use your own keys.

.NET key

Clone or connect in this app to use your own keys.

REST API key

Clone or connect in this app to use your own keys.

Webhook key

Clone or connect in this app to use your own keys.

File key

2dc51250-69fa-4db7-8ba6-75f83075f989

Master key

For test purpose only you can use Kq7Dv4kU7SVzqequMt7EznsvzSbORNb7g7Pd1SFn. Clone or connect in this app to use your own keys.

Objects API

Example Object:

{
  "objectId": "4BwpMWdCnm",
  "myCustomKey1Name": "myCustomKey1Value",
  "myCustomKey2Name": "myCustomKey2Value",
  "createdAt": "2018-11-06T00:52:01.520Z",
  "updatedAt": "2018-11-06T00:52:04.713Z"
}

The special keys objectId, createdAt and updatedAt are default and always automatically created by the platform.

Performing CRUD (create, read, update and delete) operations through Back4App - Parse Server Hosting - is really simple and can be done using the Objects API. Each object consists of a set of key-value pairs that are transacted through the API as a JSON document. The keys must be alphanumeric strings and the values must be anything that can be JSON-encoded. The objects are organized in classes so you can distinguish different sorts of data.

The data that represents an object is schemaless which means that you don't need to specify ahead of time a new custom class schema. You just need to send the data and Parse will learn from it. But if for any reason you prefer to specify your class schema before sending the data, you can do that using the Create a class button in the Database Browser of your app's Parse Dashboard.

For each new custom class that you create in your app's schema (either through API or just sending the data), a new endpoint is generated at the address below through which you can perform your CRUD operations:

https://parseapi.back4app.com/classes/MyCustomClassName

In addition, a new section in this documentation is automatically generated for each new custom class that you create through which you can learn how to perform the CRUD operations specifically to one class' objects.

Please note that the User class' objects is a special case and has its own API whose documentation you can find here and endpoint is the one that you can find below:

https://parseapi.back4app.com/users

Creating Objects

Example Request:

curl -X POST \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "Content-Type: application/json" \
-d '{"myCustomKey1Name":"myCustomKey1Value","myCustomKey2Name":"myCustomKey2Value"}' \
https://parseapi.back4app.com/classes/MyCustomClassName

Example Response:

{
  "objectId": "4BwpMWdCnm",
  "createdAt": "2018-11-06T00:52:01.520Z"
}

Code:

(async () => {
  const myNewObject = new Parse.Object('MyCustomClassName');
  myNewObject.set('myCustomKey1Name', 'myCustomKey1Value');
  myNewObject.set('myCustomKey2Name', 'myCustomKey2Value');
  try {
    const result = await myNewObject.save();
    // Access the Parse Object attributes using the .GET method
    console.log('object myCustomKey1Name: ', result.get('myCustomKey1Name'));
    console.log('object myCustomKey2Name: ', result.get('myCustomKey2Name'));
    console.log('ParseObject created', result);
  } catch (error) {
    console.error('Error while creating ParseObject: ', error);
  }
})();
(async () => {
  const myNewObject: Parse.Object = new Parse.Object('MyCustomClassName');
  myNewObject.set('myCustomKey1Name', 'myCustomKey1Value');
  myNewObject.set('myCustomKey2Name', 'myCustomKey2Value');
  try {
    const result: Parse.Object = await myNewObject.save();
    // Access the Parse Object attributes using the .GET method
    console.log('object myCustomKey1Name: ', result.get('myCustomKey1Name'));
    console.log('object myCustomKey2Name: ', result.get('myCustomKey2Name'));
    console.log('ParseObject created', result);
  } catch (error: any) {
    console.error('Error while creating ParseObject: ', error);
  }
})();
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.SaveCallback;

public void createObject() {
  String myCustomKey1Value = "foo";
  Integer myCustomKey2Value = 999;

  ParseObject myNewObject = new ParseObject("MyCustomClassName");
  myNewObject.put("myCustomKey1Name", myCustomKey1Value);
  myNewObject.put("myCustomKey2Name", myCustomKey2Value);

  // Saves the new object.
  // Notice that the SaveCallback is totally optional!
  myNewObject.saveInBackground(e -> {
    if (e==null){
      //Save was done
    }else{
      //Something went wrong
      Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
var parseObject = PFObject(className:"MyCustomClassName")

parseObject["myCustomKey1Name"] = "My custom value"
parseObject["myCustomKey2Name"] = 999

// Saves the new object.
parseObject.saveInBackground {
  (success: Bool, error: Error?) in
  if (success) {
    // The object has been saved.
  } else {
    // There was a problem, check error.description
  }
}
PFObject *parseObject = [PFObject objectWithClassName:@"MyCustomClassName"];
parseObject[@"myCustomKey1Name"] = @"My custom value";
parseObject[@"myCustomKey2Name"] = @999;

[parseObject saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
  if (succeeded) {
    // The object has been saved.
  } else {
    // There was a problem, check error.description
  }
}];
ParseObject myCustomClass = new ParseObject("MyCustomClassName");
myCustomClass["myCustomKey1Name"] = "My custom value";
myCustomClass["myCustomKey2Name"] = 999;
await myCustomClass.SaveAsync();
use Parse\ParseException;
use Parse\ParseObject;

$myCustomObject = new ParseObject("MyCustomClassName");

$myCustomObject->set("myCustomKey1Name", "My custom value");
$myCustomObject->set("myCustomKey2Name", 999);

try {
  $myCustomObject->save();
  echo 'New object created with objectId: ' . $myCustomObject->getObjectId();
} catch (ParseException $ex) {
  // Execute any logic that should take place if the save fails.
  // error is a ParseException object with an error code and message.
  echo 'Failed to create new object, with error message: ' . $ex->getMessage();
}

Example Output:

{
  id: 'xKue915KBG',
  _objCount: 0,
  className: 'MyCustomClassName'
}

To create a new object, you'll need to send a POST request to its class endpoint with your app's credentials in the headers and the object's data in the body. You can include as many key-value pairs as you want. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/classes/MyCustomClassName

Method

POST

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

Content-Type: application/json

Body

A JSON document with the key-value pairs that represent your object's data.

Success Response

Status

201 Created

Headers

Location: https://parseapi.back4app.com/classes/MyCustomClassName/MyNewObjectId

The Location header will contain the endpoint of the newly-created object.

Body

A JSON document with the objectId and createdAt fields of the newly-created object.

Error Response

Please check the Errors section.

Reading Objects

Example Request:

curl -X GET \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-G \
--data-urlencode "where={\"myCustomKey1Name\":\"myCustomKey1Value\"}" \
https://parseapi.back4app.com/classes/MyCustomClassName

Example Response:

{
  "results": [
    {
      "objectId": "zJxVP17mTi",
      "createdAt": "2018-10-31T14:16:13.616Z",
      "updatedAt": "2018-11-07T12:12:20.758Z",
      "myCustomKey1Name": "myCustomKey1Value",
      "myCustomKey2Name": ""
    },
    {
      "objectId": "yDbv0gKGJR",
      "createdAt": "2018-10-31T14:16:42.811Z",
      "updatedAt": "2018-11-07T12:12:18.543Z",
      "myCustomKey1Name": "myCustomKey1Value",
      "myCustomKey2Name": "myCustomKey2Value"
    },
    {
      "objectId": "xKue915KBG",
      "myCustomKey1Name": "myCustomKey1Value",
      "createdAt": "2018-11-07T12:11:58.533Z",
      "updatedAt": "2018-11-07T12:12:15.413Z",
      "myCustomKey2Name": "myCustomKey2Value"
    }
  ]
}

Without any URL parameters, this simply lists all objects in the class.

Learn more about query parameters in queries section.

Code:

(async () => {
  const query = new Parse.Query('MyCustomClassName');
  // You can also query by using a parameter of an object
  // query.equalTo('objectId', 'xKue915KBG');
  const results = await query.find();
  try {
    for (const object of results) {
      // Access the Parse Object attributes using the .GET method
      const myCustomKey1Name = object.get('myCustomKey1Name');
      const myCustomKey2Name = object.get('myCustomKey2Name');
      console.log(myCustomKey1Name);
      console.log(myCustomKey2Name);
    }
  } catch (error) {
    console.error('Error while fetching MyCustomClassName', error);
  }
})();
(async () => {
  const query: Parse.Query = new Parse.Query('MyCustomClassName');
  // You can also query by using a parameter of an object
  // query.equalTo('objectId', 'xKue915KBG');
  const results: Parse.Object[] = await query.find();
  try {
    for (const object of results) {
      // Access the Parse Object attributes using the .GET method
      const myCustomKey1Name: string = object.get('myCustomKey1Name');
      const myCustomKey2Name: string = object.get('myCustomKey2Name');
      console.log(myCustomKey1Name);
      console.log(myCustomKey2Name);
    }
  } catch (error: any) {
    console.error('Error while fetching MyCustomClassName', error);
  }
})();

Example Output:

myCustomKey1Value
myCustomKey2Value

To get the values out of the Parse.Object, use the get method.

Learn more about query parameters in queries section.

import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

public void readObject() {
  ParseQuery<ParseObject> query = ParseQuery.getQuery("MyCustomClassName");

  // The query will search for a ParseObject, given its objectId.
  // When the query finishes running, it will invoke the GetCallback
  // with either the object, or the exception thrown
  query.getInBackground("<PARSE_OBJECT_ID>", (object, e) -> {
    if (e == null) {
      //Object was successfully retrieved
    } else {
      // something went wrong
      Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
    }  
  });
}
var query = PFQuery(className:"MyCustomClassName")

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error == nil && parseObject != nil {
    print(parseObject)
  } else {
    print(error)
  }
}
PFQuery *query = [PFQuery queryWithClassName:@"MyCustomClassName"];
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>" block:^(PFObject *parseObject, NSError *error) {
    // Do something with the returned PFObject in the parseObject variable.
    NSLog(@"%@", parseObject);
}];
ParseQuery<ParseObject> query = ParseObject.GetQuery("MyCustomClassName");
ParseObject result = await query.GetAsync("<PARSE_OBJECT_ID>");
// Use the Get<T> method to get the values
string myCustomKey1 = result.Get<string>("myCustomKey1Name");
int myCustomKey2 = result.Get<int>("myCustomKey2Name");

// The same method is applied to the default properties
string objectId = result.ObjectId;
DateTime? updatedAt = result.UpdatedAt;
DateTime? createdAt = result.CreatedAt;
use Parse\ParseException;
use Parse\ParseQuery;

$query = new ParseQuery("MyCustomClassName");
try {
  $myCustomObject = $query->get("<PARSE_OBJECT_ID>");
  // The object was retrieved successfully.

  // To get attributes, you can use the "get" method, providing the attribute name:
  $myCustomKey1Value = $myCustomObject->get("myCustomKey1Name");
  echo $myCustomKey1Value;
} catch (ParseException $ex) {
  // The object was not retrieved successfully.
  // error is a ParseException with an error code and message.
}

To retrieve an object, you'll need to send a GET request to its class endpoint with your app's credentials in the headers and the query parameters in the URL parameters. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/classes/MyCustomClassName

Method

GET

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

Parameters

A where URL parameter constraining the value for keys. It should be encoded JSON.

Success Response

Status

200 OK

Headers

content-type: application/json;

Body

a JSON object that contains a results field with a JSON array that lists the objects.

Error Response

Please check the Errors section.

Updating Objects

Example Request:

curl -X PUT \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "Content-Type: application/json" \
-d '{"myCustomKeyName":"newValue"}' \
https://parseapi.back4app.com/classes/MyCustomClassName/Ed1nuqPvcm

Example Response:

{
  "updatedAt": "2011-08-21T18:02:52.248Z"
}

You can delete a single field from an object by using the Delete operation:

Example Request:


curl -X PUT \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "Content-Type: application/json" \
-d '{"myCustomKeyName":{"__op":"Delete"}}' \
https://parseapi.back4app.com/classes/MyCustomClassName/

Example Response:

{
  "updatedAt": "2011-08-21T18:02:52.248Z"
}

Code:

(async () => {
  const query = new Parse.Query('MyCustomClassName');
  try {
    // here you put the objectId that you want to update
    const object = await query.get('xKue915KBG');
    object.set('myCustomKey1Name', 'new value');
    try {
      const response = await object.save();
      // You can use the "get" method to get the value of an attribute
      // Ex: response.get("<ATTRIBUTE_NAME>")
      // Access the Parse Object attributes using the .GET method
      console.log(response.get('myCustomKey1Name'));
      console.log('MyCustomClassName updated', response);
    } catch (error) {
      console.error('Error while updating ', error);
    }
  } catch (error) {
    console.error('Error while retrieving object ', error);
  }
})();
(async () => {
  const query: Parse.Query = new Parse.Query('MyCustomClassName');
  try {
    // here you put the objectId that you want to update
    const object: Parse.Object = await query.get('xKue915KBG');
    object.set('myCustomKey1Name', 'new value');
    try {
      const response: Parse.Object = await object.save();
      // You can use the "get" method to get the value of an attribute
      // Ex: response.get("<ATTRIBUTE_NAME>")
      // Access the Parse Object attributes using the .GET method
      console.log(response.get('myCustomKey1Name'));
      console.log('MyCustomClassName updated', response);
    } catch (error: any) {
      console.error('Error while updating ', error);
    }
  } catch (error: any) {
    console.error('Error while retrieving object ', error);
  }
})();

Example Output:

myCustomKey1Name
MyCustomClassName updated
{
  className: 'MyCustomClassName',
  _objCount: 0,
  id: 'xKue915KBG'
}

You can delete a single field from an object with the unset method:

(async() => {
  const query = new Parse.Query('MyCustomClassName');
  try {
    const object = await query.get('xKue915KBG');
    // After this, the myCustomKeyName field will be empty
    object.unset('myCustomKeyName');
    try {
      const response = await object.save();
      console.log(response);
      // Access the Parse Object attributes using the .GET method
      console.log(response.get('myCustomKeyName'));
    } catch (error) {
      console.error(error);
    }
  } catch (error) {
    console.error(error);    
  }
})();

You can delete a single field from an object with the unset method:

(async() => {
  const query: Parse.Query = new Parse.Query('MyCustomClassName');
  try {
    const object: Parse.Object = await query.get('xKue915KBG');
    // After this, the myCustomKeyName field will be empty
    object.unset('myCustomKeyName');
    try {
      const response: Parse.Object = await object.save();
      console.log(response);
      // Access the Parse Object attributes using the .GET method
      console.log(response.get('myCustomKeyName'));
    } catch (error: any) {
      console.error(error);
    }
  } catch (error: any) {
    console.error(error);    
  }
})();

Example Output:

{
  className: 'MyCustomClassName',
  id: 'xKue915KBG',
  _localId: undefined,
  _objCount: 0, 
}
undefined

Please note that use of object.set(null) to remove a field from an object is not recommended and will result in unexpected functionality.

import java.util.Date;
import javax.json.JSONArray;
import javax.json.JSONObject;

import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseFile;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseRelation;

public void updateObject() {
  ParseQuery<ParseObject> query = ParseQuery.getQuery("MyCustomClassName");

  // Retrieve the object by id
  query.getInBackground("<PARSE_OBJECT_ID>", (object, e) -> {
    if (e == null) {
      // Update the fields we want to
      object.put("myCustomKey1Name", "My new value");
      object.put("myCustomKey2Name", 999);

      // All other fields will remain the same
      object.saveInBackground();

    } else {
      // something went wrong
      Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
    }  
  });

}
var query = PFQuery(className:"MyCustomClassName")

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error != nil {
    print(error)
  } else if parseObject != nil {
    parseObject["myCustomKey1Name"] = "My custom value"
    parseObject["myCustomKey2Name"] = 999

    parseObject.saveInBackground()
  }
}
PFQuery *query = [PFQuery queryWithClassName:@"MyCustomClassName"];

// Retrieve the object by id
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>"
                             block:^(PFObject *parseObject, NSError *error) {
    parseObject[@"myCustomKey1Name"] = @"My custom value";
    parseObject[@"myCustomKey2Name"] = @999;
    [parseObject saveInBackground];
}];
ParseQuery<ParseObject> query = ParseObject.GetQuery("MyCustomClassName");
ParseObject object = await query.GetAsync("<PARSE_OBJECT_ID>");
object["myCustomKey1Name"] = "My new value";
await object.SaveAsync();

You can delete a single field from an object with the Remove method:

ParseQuery<ParseObject> query = ParseObject.GetQuery("MyCustomClassName");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
// After this, the myCustomKey1Name field will be empty
myObject.Remove("myCustomKey1Name");
await object.SaveAsync();
use Parse\ParseException;
use Parse\ParseQuery;

$query = new ParseQuery("MyCustomClassName");
try {
  $myCustomObject = $query->get("<PARSE_OBJECT_ID>");
  // The object was retrieved successfully.

  // Update any data you want with the "set" method,
  // providing the attribute name and the new value
  $myCustomObject->set("myCustomKey1Name", "My new value");
  $myCustomObject->set("myCustomKey2Name", 12345);

  // And then save your changes
  $myCustomObject->save();
} catch (ParseException $ex) {
  // The object was not retrieved successfully.
  // error is a ParseException with an error code and message.
}

To update data on an object that already exists, send a PUT request to this object endpoint with your app's credentials in the headers and the query parameters in the body. Any keys you don’t specify will remain unchanged, so you can update just a subset of the object’s data. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/classes/MyCustomClassName/MyCurrentObjectId

Method

PUT

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

Content-Type: application/json

Body

A JSON document with the key-value pairs that represent the object's new data.

Success Response

Status

200 OK

Headers

content-type: application/json;

Body

a JSON object that contains a updatedAt field with the timestamp of the update.

Error Response

Please check the Errors section.

Deleting Objects

Example Request:


curl -X DELETE \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
https://parseapi.back4app.com/classes/MyCustomClassName/Ed1nuqPvcm

Example Response:

{}

Code:

(async () => {
  const query = new Parse.Query('MyCustomClassName');
  try {
    // here you put the objectId that you want to delete
    const object = await query.get('xKue915KBG');
    try {
      const response = await object.destroy();
      console.log('Deleted ParseObject', response);
    } catch (error) {
      console.error('Error while deleting ParseObject', error);
    }
  } catch (error) {
    console.error('Error while retrieving ParseObject', error);
  }
})();
(async () => {
  const query: Parse.Query = new Parse.Query('MyCustomClassName');
  try {
    // here you put the objectId that you want to delete
    const object: Parse.Object = await query.get('xKue915KBG');
    try {
      const response: any = await object.destroy();
      console.log('Deleted ParseObject', response);
    } catch (error: any) {
      console.error('Error while deleting ParseObject', error);
    }
  } catch (error: any) {
    console.error('Error while retrieving ParseObject', error);
  }
})();

Example Output:

Deleted ParseObject
{
  className: 'MyCustomClassName',
  _objCount: 0,
  id: 'xKue915KBG'
}
import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

public void deleteObject() {
// Retrieve the object by id
  ParseQuery<ParseObject> query = ParseQuery.getQuery("MyCustomClassName");
  query.getInBackground("<PARSE_OBJECT_ID>", (object, e) -> {
      if (e == null) {
          // Deletes the fetched ParseObject from the database
          object.deleteInBackground(e2 -> {
              if(e2==null){
                  Toast.makeText(this, "Delete Successful", Toast.LENGTH_SHORT).show();
              }else{
                  //Something went wrong while deleting the Object
                  Toast.makeText(this, "Error: "+e2.getMessage(), Toast.LENGTH_SHORT).show();
              }
          });
      }else{
          //Something went wrong while retrieving the Object
          Toast.makeText(this, "Error: "+e.getMessage(), Toast.LENGTH_SHORT).show();
      }
  });
}
var deleteAttributesOnly = true

var query = PFQuery(className:"")

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error != nil {
    print(error)
  } else if parseObject != nil {
    if deleteAttributesOnly {

      parseObject.saveInBackground()
    } else {
      parseObject.deleteInBackground()
    }
  }
}
PFQuery *query = [PFQuery queryWithClassName:@"MyCustomClassName"];

// Retrieve the object by id
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>" block:^(PFObject *parseObject, NSError *error) {
  // After this, the myCustomKey1Name field will be empty
  // [parseObject removeObjectForKey:@"myCustomKey1Name"];
  // Saves the field deletion to the Parse Cloud
  // [parseObject saveInBackground];

  [parseObject deleteInBackground];
}
ParseQuery<ParseObject> query = ParseObject.GetQuery("MyCustomClassName");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
await myObject.DeleteAsync();
use Parse\ParseQuery;
use Parse\ParseException;

$query = new ParseQuery("MyCustomClassName");
try {
  $myCustomObject = $query->get("<PARSE_OBJECT_ID>");
  // The object was retrieved successfully.

  // After this, the myCustomKey1Name field will be empty
  $myCustomObject->delete("myCustomKey1Name");
  // Saves any changes done to the object
  $myCustomObject->save();

  // Otherwise, you can delete the entire object from the database
  $myCustomObject->destroy();
} catch (ParseException $ex) {
  // The object was not retrieved successfully.
  // error is a ParseException with an error code and message.
}

To delete an object send a DELETE request to this object endpoint with your app's credentials in the headers. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/classes/MyCustomClassName/MyCurrentObjectId

Method

DELETE

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

Success Response

Status

200 OK

Headers

content-type: application/json;

Body

An empty JSON object.

Error Response

Please check the Errors section.

Understanding Data Types

Parse supports many types of data, from Strings to relations with other Parse Objects, users are able to store their data in our servers with great availability and low latency. Check the list aside with examples of how to define them and use on your application.

Examples:

{
  \"stringExample\": \"A string\",
  \"numberExample\": 1,
  \"booleanExample\": true,
  \"arrayExample\": [ 1, \"a string\" ],
  \"objectExample\": { \"foo\": \"bar\" },
  \"dateExample\": { \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },
  \"fileExample\": { \"__type\": \"File\", \"name\": \"resume.txt\" },
  \"pointerExample\": { \"__type\": \"Pointer\", \"className\": \"<YOUR_CLASS_NAME>\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" },
  \"relationExample\": { \"__type\": \"Relation\", \"className\": \"<YOUR_CLASS_NAME>\" },
  \"geopointExample\": { \"__type\": \"GeoPoint\", \"latitude\": 40.0, \"longitude\": -30.0 },
  \"polygonExample\": {\"__type\":\"Polygon\",\"coordinates\":[[0,0],[0,1],[1,0]]}
}

const stringExample = 'A string';

const numberExample = 1;

const booleanExample = true;

const arrayExample = [1, 'a string'];

const objectExample = { foo: 'bar' };

const dateExample = new Date();

const fileExample = new Parse.File("resume.txt", { base64: btoa("My file content") });

const pointerExample = new Parse.Object("<YOUR_CLASS_NAME>");

const relationExample = new Parse.Object("<YOUR_CLASS_NAME>");

const geopointExample = new Parse.GeoPoint({latitude: 40.0, longitude: -30.0});

const polygonExample = new Parse.Polygon([ [0,0], [0,1], [1,0] ]);

String stringExample = "A string";

int numberExample = 1;

boolean booleanExample = true;

JSONArray arrayExample = new JSONArray();

JSONObject objectExample = new JSONObject();

java.util.Date dateExample = new Date();

ParseFile fileExample = new ParseFile("resume.txt", "My string content".getBytes());

ParseObject pointerExample = new ParseObject("<YOUR_CLASS_NAME>");

ParseRelation relationExample = new ParseObject("<YOUR_CLASS_NAME>");

ParseGeoPoint geopointExample = new ParseGeoPoint(40.0, -30.0);

ParsePolygon polygonExample = new ParsePolygon(Arrays.asList(new ParseGeoPoint(0,0), new ParseGeoPoint(0,1), new ParseGeoPoint(1,0)));

var stringExample = "A string"

var numberExample = 1

var booleanExample = true

var arrayExample = [1, "a string"]

var objectExample = [ "foo": "bar" ]

var dateExample = NSDate()

var fileExample = PFFile(name:"resume.txt", data:"My string content".dataUsingEncoding(NSUTF8StringEncoding))

var pointerExample = PFObject(className:"<YOUR_CLASS_NAME>")

var relationExample = PFObject(className:"<YOUR_CLASS_NAME>")

var geopointExample = PFGeoPoint(latitude:40.0, longitude:-30.0)

var polygonExample = PFPolygon(coordinates: [ [0,0], [0,1], [1,0] ])

NSString stringExample = @"A string";

NSNumber numberExample = @1;

NSNumber booleanExample = @YES;

NSArray arrayExample = @[@1, @"a string"];

NSObject objectExample = @{ @"foo": @"bar" };

NSDate dateExample = [NSDate date];

PFFile fileExample = [PFFile fileWithName:@"resume.txt" data: [@"My string content" dataUsingEncoding:NSUTF8StringEncoding]];

PFObject pointerExample = [PFObject objectWithClassName:@"<YOUR_CLASS_NAME>"];

PFRelation relationExample = [PFObject objectWithClassName:@"<YOUR_CLASS_NAME>"];

PFGeoPoint geopointExample = [PFGeoPoint geoPointWithLatitude:40.0 longitude:-30.0];

PFPolygon polygonExample = [PFPolygon polygonWithCoordinates: @[ @[@0,@0], @[@0,@1], @[@1,@0] ] ];

$stringExample = "A string"

$numberExample = 1

$booleanExample = true

$arrayExample = [1, "a string"]

$objectExample = ["foo" => "bar"]

$dateExample = new DateTime()

$fileExample = ParseFile::createFromData("My resume content", "resume.txt")

$pointerExample = new ParseObject("<YOUR_CLASS_NAME>")

$relationExample = new ParseObject("<YOUR_CLASS_NAME>")

$geopointExample = new ParseGeoPoint(40.0, -30.0)

$polygonExample = new ParsePolygon([ new ParseGeoPoint(0, 0), new ParseGeoPoint(0, 1), new ParseGeoPoint(1, 0) ])

string stringExample = "A string";

int numberExample = 1;

bool booleanExample = true;

IList arrayExample = new List<object>{1, "a string"};

IDictionary objectExample = new Dictionary<string, object> { { "number", number }, { "string", str } };

DateTime dateExample = DateTime.Now;

ParseFile fileExample =  new ParseFile("resume.txt", System.Text.Encoding.UTF8.GetBytes("My string content"));;

ParseObject pointerExample = new ParseObject("<YOUR_CLASS_NAME>");

ParseRelation relationExample = new ParseObject("<YOUR_CLASS_NAME>");

ParseGeoPoint geopointExample = new ParseGeoPoint(40.0, -30.0);

//  polygonExample = <NOT_AVAILABLE>;

Group Class

Example JSON:

{
  "definition": "A string",
  "code": "A string",
  "title": "A string",
  "family": { "__type": "Pointer", "className": "Family", "objectId": "<THE_REFERENCED_OBJECT_ID>" },
  "programs": { "__type": "Relation", "className": "Program" }
}

Group is a custom class that was created and is specific for CIP. Please use the following documentation to learn how to perform CRUD (create, read, update and delete) operations to this specific class. A new endpoint was automatically generated at the address below to which you can send your requests:

https://parseapi.back4app.com/classes/Group

The following fields are supported by this class' schema and can be used in the operations:

Name Type Example
definition String "A string"
code String "A string"
title String "A string"
family Pointer { "__type": "Pointer", "className": "Family", "objectId": "<THE_REFERENCED_OBJECT_ID>" }
programs Relation { "__type": "Relation", "className": "Program" }

Creating Objects

Example Request:

curl -X POST \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "Content-Type: application/json" \
-d "{ \"definition\":\"A string\",\"code\":\"A string\",\"title\":\"A string\",\"family\":{ \"__type\": \"Pointer\", \"className\": \"Family\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" },\"programs\":{ \"__type\": \"Relation\", \"className\": \"Program\" } }" \
https://parseapi.back4app.com/classes/Group

Example Response:

{
  "objectId": "4BwpMWdCnm",
  "createdAt": "2018-11-06T00:52:01.520Z"
}

Code:

(async () => {
  const myNewObject = new Parse.Object('Group');
  myNewObject.set('definition', 'A string');
  myNewObject.set('code', 'A string');
  myNewObject.set('title', 'A string');
  myNewObject.set('family', new Parse.Object("Family"));
  myNewObject.set('programs', new Parse.Object("Program"));
  try {
    const result = await myNewObject.save();
    // Access the Parse Object attributes using the .GET method
    console.log('Group created', result);
  } catch (error) {
    console.error('Error while creating Group: ', error);
  }
})();
(async () => {
  const myNewObject: Parse.Object = new Parse.Object('Group');
  myNewObject.set('definition', 'A string');
  myNewObject.set('code', 'A string');
  myNewObject.set('title', 'A string');
  myNewObject.set('family', new Parse.Object("Family"));
  myNewObject.set('programs', new Parse.Object("Program"));
  try {
    const result: Parse.Object = await myNewObject.save();
    // Access the Parse Object attributes using the .GET method
    console.log('Group created', result);
  } catch (error: any) {
    console.error('Error while creating Group: ', error);
  }
})();
import java.util.Date;
import javax.json.JSONArray;
import javax.json.JSONObject;

import com.parse.ParseException;
import com.parse.ParseFile;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseRelation;
import com.parse.SaveCallback;

public void createObject() {
  ParseObject entity = new ParseObject("Group");

  entity.put("definition", "A string");
  entity.put("code", "A string");
  entity.put("title", "A string");
  entity.put("family", new ParseObject("Family"));
  entity.put("programs", new ParseObject("Program"));

  // Saves the new object.
  // Notice that the SaveCallback is totally optional!
  entity.saveInBackground(e -> {
    if (e==null){
      //Save was done
    }else{
      //Something went wrong
      Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });

}
var parseObject = PFObject(className:"Group")

parseObject["definition"] = "A string"
parseObject["code"] = "A string"
parseObject["title"] = "A string"
parseObject["family"] = PFObject(className:"Family")
parseObject["programs"] = PFObject(className:"Program")

// Saves the new object.
parseObject.saveInBackground {
  (success: Bool, error: Error?) in
  if (success) {
    // The object has been saved.
  } else {
    // There was a problem, check error.description
  }
}
PFObject *parseObject = [PFObject objectWithClassName:@"Group"];

parseObject[@"definition"] = @"A string";
parseObject[@"code"] = @"A string";
parseObject[@"title"] = @"A string";
parseObject[@"family"] = [PFObject objectWithClassName:@"Family"];
parseObject[@"programs"] = [PFObject objectWithClassName:@"Program"];

[parseObject saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
  if (succeeded) {
    // The object has been saved.
  } else {
    // There was a problem, check error.description
  }
}];
ParseObject myObject = new ParseObject("Group");
myObject["definition"] = "A string";
myObject["code"] = "A string";
myObject["title"] = "A string";
myObject["family"] = new ParseObject("Family");
myObject["programs"] = new ParseObject("Program");
await myObject.SaveAsync();
$myCustomObject = new ParseObject("Group");

$myCustomObject->set("definition", "A string");
$myCustomObject->set("code", "A string");
$myCustomObject->set("title", "A string");
$myCustomObject->set("family", new ParseObject("Family"));
$myCustomObject->set("programs", new ParseObject("Program"));

try {
  $myCustomObject->save();
  echo 'New object created with objectId: ' . $myCustomObject->getObjectId();
} catch (ParseException $ex) {
  // Execute any logic that should take place if the save fails.
  // error is a ParseException object with an error code and message.
  echo 'Failed to create new object, with error message: ' . $ex->getMessage();
}

Example Output:

{
  id: 'xKue915KBG',
  _objCount: 0,
  className: 'Group
}

To create a new object of the Group class, you'll need to send a POST request to the Group class' endpoint with your app's credentials in the headers and the object's data in the body. You can include as many key-value pairs of the supported fields as you want. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/classes/Group

Method

POST

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

Content-Type: application/json

Body

A JSON document with the key-value pairs that represent your object's data according to the supported fields.

Success Response

Status

201 Created

Headers

Location: https://parseapi.back4app.com/classes/Group/MyNewObjectId

The Location header will contain the endpoint of the newly-created object.

Body

A JSON document with the objectId and createdAt fields of the newly-created object.

Error Response

Please check the Errors section.

Reading Objects

Example Request:

curl -X GET \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-G \
--data-urlencode "where={ \"definition\":\"A string\",\"code\":\"A string\",\"title\":\"A string\",\"family\":{ \"__type\": \"Pointer\", \"className\": \"Family\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" },\"programs\":{ \"__type\": \"Relation\", \"className\": \"Program\" } }" \
https://parseapi.back4app.com/classes/Group

Example Response:

{
  "results": [
    {
      "objectId": "zJxVP17mTi",
      "createdAt": "2018-10-31T14:16:13.616Z",
      "updatedAt": "2018-11-07T12:12:20.758Z",
      "definition": \"A string\","code": \"A string\","title": \"A string\","family": { \"__type\": \"Pointer\", \"className\": \"Family\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" },"programs": { \"__type\": \"Relation\", \"className\": \"Program\" }
    },
    {
      "objectId": "yDbv0gKGJR",
      "createdAt": "2018-10-31T14:16:42.811Z",
      "updatedAt": "2018-11-07T12:12:18.543Z",
      "definition": \"A string\","code": \"A string\","title": \"A string\","family": { \"__type\": \"Pointer\", \"className\": \"Family\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" },"programs": { \"__type\": \"Relation\", \"className\": \"Program\" }
    },
    {
      "objectId": "xKue915KBG",
      "createdAt": "2018-11-07T12:11:58.533Z",
      "updatedAt": "2018-11-07T12:12:15.413Z",
      "definition": \"A string\","code": \"A string\","title": \"A string\","family": { \"__type\": \"Pointer\", \"className\": \"Family\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" },"programs": { \"__type\": \"Relation\", \"className\": \"Program\" }
    }
  ]
}

Without any URL parameters, this simply lists all objects in the class.

Learn more about query parameters in queries section.

Code:

(async () => {
  const Group = Parse.Object.extend('Group');
  const query = new Parse.Query(Group);
  // You can also query by using a parameter of an object
  // query.equalTo('objectId', 'xKue915KBG');
  try {
    const results = await query.find();
    for (const object of results) {
      // Access the Parse Object attributes using the .GET method
      const definition = object.get('definition')
      const code = object.get('code')
      const title = object.get('title')
      const family = object.get('family')
      const programs = object.get('programs')
      console.log(definition);
      console.log(code);
      console.log(title);
      console.log(family);
      console.log(programs);
    }
  } catch (error) {
    console.error('Error while fetching Group', error);
  }
})();
(async () => {
  const Group: Parse.Object = Parse.Object.extend('Group');
  const query: Parse.Query = new Parse.Query(Group);
  // You can also query by using a parameter of an object
  // query.equalTo('objectId', 'xKue915KBG');
  try {
    const results: Parse.Object[] = await query.find();
    for (const object of results) {
      // Access the Parse Object attributes using the .GET method
      const definition: string = object.get('definition')
      const code: string = object.get('code')
      const title: string = object.get('title')
      const family: string = object.get('family')
      const programs: string = object.get('programs')
      console.log(definition);
      console.log(code);
      console.log(title);
      console.log(family);
      console.log(programs);
    }
  } catch (error: any) {
    console.error('Error while fetching Group', error);
  }
})();

Example Output:

'A string' 'A string' 'A string' new Parse.Object("Family") new Parse.Object("Program") 

To get the values out of the Parse.Object, use the get method.

Learn more about query parameters in queries section.

import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

public void readObject() {
  ParseQuery<ParseObject> query = ParseQuery.getQuery("Group");

  // The query will search for a ParseObject, given its objectId.
  // When the query finishes running, it will invoke the GetCallback
  // with either the object, or the exception thrown
  query.getInBackground("<PARSE_OBJECT_ID>", (object, e) -> {
        if (e == null) {
        //Object was successfully retrieved
      } else {
        // something went wrong
        Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
      }  
  });
}
var query = PFQuery(className:"Group")

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error == nil && parseObject != nil {
    print(parseObject)
  } else {
    print(error)
  }
}
PFQuery *query = [PFQuery queryWithClassName:@"Group"];
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>" block:^(PFObject *parseObject, NSError *error) {
    // Do something with the returned PFObject in the parseObject variable.
    NSLog(@"%@", parseObject);
}];
ParseQuery<ParseObject> query = ParseObject.GetQuery("Group");
ParseObject result = await query.GetAsync("<PARSE_OBJECT_ID>");
// Use the Get<T> method to get the values
string definition = result.Get<string>("definition");
string code = result.Get<string>("code");
string title = result.Get<string>("title");
ParseObject family = result.Get<ParseObject>("family");
ParseRelation programs = result.Get<ParseRelation>("programs");
$query = new ParseQuery("Group");
try {
  $myCustomObject = $query->get("<PARSE_OBJECT_ID>");
  // The object was retrieved successfully.

  // To get attributes, you can use the "get" method, providing the attribute name:
  $definition = $myCustomObject->get("definition");
  $code = $myCustomObject->get("code");
  $title = $myCustomObject->get("title");
  $family = $myCustomObject->get("family");
  $programs = $myCustomObject->get("programs");
} catch (ParseException $ex) {
  // The object was not retrieved successfully.
  // error is a ParseException with an error code and message.
}

To retrieve an object, you'll need to send a GET request to its class endpoint with your app's credentials in the headers and the query parameters in the URL parameters. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/classes/Group

Method

GET

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

Parameters

A where URL parameter constraining the value for keys. It should be encoded JSON.

Success Response

Status

200 OK

Headers

content-type: application/json;

Body

a JSON object that contains a results field with a JSON array that lists the objects.

Error Response

Please check the Errors section.

Updating Objects

Example Request:


# Don't forget to set the OBJECT_ID parameter
curl -X PUT \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "Content-Type: application/json" \
-d "{ \"definition\": \"A string\",\"code\": \"A string\",\"title\": \"A string\",\"family\": { \"__type\": \"Pointer\", \"className\": \"Family\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" },\"programs\": { \"__type\": \"Relation\", \"className\": \"Program\" } }" \
https://parseapi.back4app.com/classes/Group/<OBJECT_ID>

Example Response:

{
  "updatedAt": "2011-08-21T18:02:52.248Z"
}

You can delete a single field from an object by using the Delete operation:

Example Request:


curl -X PUT \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "Content-Type: application/json" \
-d '{ "definition": {"__op":"Delete"},"code": {"__op":"Delete"},"title": {"__op":"Delete"},"family": {"__op":"Delete"},"programs": {"__op":"Delete"} }' \
https://parseapi.back4app.com/classes/Group

Example Response:

{
  "updatedAt": "2011-08-21T18:02:52.248Z"
}

Code:

(async () => {
  const query = new Parse.Query(Group);
  try {
    // here you put the objectId that you want to update
    const object = await query.get('xKue915KBG');
    object.set('definition', 'A string');
    object.set('code', 'A string');
    object.set('title', 'A string');
    object.set('family', new Parse.Object("Family"));
    object.set('programs', new Parse.Object("Program"));
    try {
      const response = await object.save();
      // You can use the "get" method to get the value of an attribute
      // Ex: response.get("<ATTRIBUTE_NAME>")
      // Access the Parse Object attributes using the .GET method
      console.log(response.get('definition'));
      console.log(response.get('code'));
      console.log(response.get('title'));
      console.log(response.get('family'));
      console.log(response.get('programs'));
      console.log('Group updated', response);
    } catch (error) {
      console.error('Error while updating Group', error);
      }
    } catch (error) {
      console.error('Error while retrieving object Group', error);
    }
})();
(async () => {
  const query: Parse.Query = new Parse.Query(Group);
  try {
    // here you put the objectId that you want to update
    const object: Parse.Object = await query.get('xKue915KBG');
    object.set('definition', 'A string');
    object.set('code', 'A string');
    object.set('title', 'A string');
    object.set('family', new Parse.Object("Family"));
    object.set('programs', new Parse.Object("Program"));
    try {
      const response: Parse.Object = await object.save();
      // You can use the "get" method to get the value of an attribute
      // Ex: response.get("<ATTRIBUTE_NAME>")
      // Access the Parse Object attributes using the .GET method
      console.log(response.get('definition'));
      console.log(response.get('code'));
      console.log(response.get('title'));
      console.log(response.get('family'));
      console.log(response.get('programs'));
      console.log('Group updated', response);
    } catch (error: any) {
      console.error('Error while updating Group', error);
      }
    } catch (error: any) {
      console.error('Error while retrieving object Group', error);
    }
})();

Example Output:


definition
code
title
family
programs
Group updated
{
  className: Group,
   _objCount: 0,
   id: 'xKue915KBG'
}

You can delete a single field from an object with the unset method:

(async() => {
  const query = new Parse.Query('Group');
  try {
    const object = await query.get('xKue915KBG');
    // After this, the myCustomKeyName field will be empty
    object.unset('programs');
    try {
      const response = await object.save();
      console.log(response);
      // Access the Parse Object attributes using the .GET method
      console.log(response.get('programs'));
    } catch (error) {
      console.error(error);
    }
  } catch (error) {
    console.error(error);    
  }
})();
(async() => {
  const query: Parse.Query = new Parse.Query('Group');
  try {
    const object: Parse.Object = await query.get('xKue915KBG');
    // After this, the myCustomKeyName field will be empty
    object.unset('programs');
    try {
      const response: Parse.Object = await object.save();
      console.log(response);
      // Access the Parse Object attributes using the .GET method
      console.log(response.get('programs'));
    } catch (error: any) {
      console.error(error);
    }
  } catch (error: any) {
    console.error(error);    
  }
})();

Example Output:

{
  className: Group,
  id: 'xKue915KBG',
  _localId: undefined,
  _objCount: 0, 
}
undefined

Please note that use of object.set(null) to remove a field from an object is not recommended and will result in unexpected functionality.

import java.util.Date;
import javax.json.JSONArray;
import javax.json.JSONObject;

import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseFile;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseRelation;

public void updateObject() {
  ParseQuery<ParseObject> query = ParseQuery.getQuery("Group");

  // Retrieve the object by id
  query.getInBackground("<PARSE_OBJECT_ID>", (object, e) -> {
    if (e == null) {
      //Object was successfully retrieved
      // Update the fields we want to
      object.put("definition", "A string");
      object.put("code", "A string");
      object.put("title", "A string");
      object.put("family", new ParseObject("Family"));
      object.put("programs", new ParseObject("Program"));

      //All other fields will remain the same
      object.saveInBackground();

    } else {
      // something went wrong
      Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
    }  
  });

}
var query = PFQuery(className:"Group")

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error != nil {
    print(error)
  } else if parseObject != nil {
    parseObject["definition"] = "A string"
    parseObject["code"] = "A string"
    parseObject["title"] = "A string"
    parseObject["family"] = PFObject(className:"Family")
    parseObject["programs"] = PFObject(className:"Program")

    parseObject.saveInBackground()
  }
}
PFQuery *query = [PFQuery queryWithClassName:@"Group"];

// Retrieve the object by id
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>"
                             block:^(PFObject *parseObject, NSError *error) {
    parseObject[@"definition"] = @"A string";
    parseObject[@"code"] = @"A string";
    parseObject[@"title"] = @"A string";
    parseObject[@"family"] = [PFObject objectWithClassName:@"Family"];
    parseObject[@"programs"] = [PFObject objectWithClassName:@"Program"];

    [parseObject saveInBackground];
}];
ParseQuery<ParseObject> query = ParseObject.GetQuery("Group");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
myObject["definition"] = "A string";
myObject["code"] = "A string";
myObject["title"] = "A string";
myObject["family"] = new ParseObject("Family");
myObject["programs"] = new ParseObject("Program");
await myObject.SaveAsync();

You can delete a single field from an object with the Remove method:

ParseQuery<ParseObject> query = ParseObject.GetQuery("MyCustomClassName");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
myObject.Remove("definition");
myObject.Remove("code");
myObject.Remove("title");
myObject.Remove("family");
myObject.Remove("programs");
await myObject.SaveAsync();
$query = new ParseQuery("Group");
try {
  $myCustomObject = $query->get("<PARSE_OBJECT_ID>");
  // The object was retrieved successfully.

  // Update any data you want with the "set" method,
  // providing the attribute name and the new value
  $myCustomObject->set("definition", "A string");
  $myCustomObject->set("code", "A string");
  $myCustomObject->set("title", "A string");
  $myCustomObject->set("family", new ParseObject("Family"));
  $myCustomObject->set("programs", new ParseObject("Program"));

  // And then save your changes
  $myCustomObject->save();
} catch (ParseException $ex) {
  // The object was not retrieved successfully.
  // error is a ParseException with an error code and message.
}

To update data on an object that already exists, send a PUT request to this object endpoint with your app's credentials in the headers and the query parameters in the body. Any keys you don’t specify will remain unchanged, so you can update just a subset of the object’s data. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/classes/Group/MyCurrentObjectId

Method

PUT

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

Content-Type: application/json

Body

A JSON document with the key-value pairs that represent the object's new data.

Success Response

Status

200 OK

Headers

content-type: application/json;

Body

a JSON object that contains a updatedAt field with the timestamp of the update.

Error Response

Please check the Errors section.

Deleting Objects

Example Request:

# Don't forget to set the OBJECT_ID parameter
curl -X DELETE \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
https://parseapi.back4app.com/classes/Group/<OBJECT_ID>

Example Response:

{}

Code:

(async () => {
  const query = new Parse.Query('Group');
  try {
    // here you put the objectId that you want to delete
    const object = await query.get('xKue915KBG');
    try {
      const response = await object.destroy();
      console.log('Deleted ParseObject', response);
    } catch (error) {
      console.error('Error while deleting ParseObject', error);
    }
  } catch (error) {
    console.error('Error while retrieving ParseObject', error);
  }
})();
(async () => {
  const query: Parse.Query = new Parse.Query('Group');
  try {
    // here you put the objectId that you want to delete
    const object: Parse.Object = await query.get('xKue915KBG');
    try {
      const response: any = await object.destroy();
      console.log('Deleted ParseObject', response);
    } catch (error: any) {
      console.error('Error while deleting ParseObject', error);
    }
  } catch (error: any) {
    console.error('Error while retrieving ParseObject', error);
  }
})();

Example Output:

Deleted ParseObject
{
  className: 'Group',
  _objCount: 0,
  id: 'xKue915KBG'
}
import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

public void deleteObject() {

  ParseQuery<ParseObject> query = ParseQuery.getQuery("Group");

  // Retrieve the object by id
  query.getInBackground("<PARSE_OBJECT_ID>", (object, e) -> {
    if (e == null) {
      //Object was fetched
      //Deletes the fetched ParseObject from the database
      object.deleteInBackground(e2 -> {
          if(e2==null){
              Toast.makeText(this, "Delete Successful", Toast.LENGTH_SHORT).show();
          }else{
              //Something went wrong while deleting the Object
              Toast.makeText(this, "Error: "+e2.getMessage(), Toast.LENGTH_SHORT).show();
          }
      });
    }else{
      //Something went wrong
      Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });

}
var deleteAttributesOnly = true

var query = PFQuery(className:"Group")

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error != nil {
    print(error)
  } else if parseObject != nil {
    if deleteAttributesOnly {
      parseObject.removeObjectForKey("definition")
      parseObject.removeObjectForKey("code")
      parseObject.removeObjectForKey("title")
      parseObject.removeObjectForKey("family")
      parseObject.removeObjectForKey("programs")
      parseObject.saveInBackground()
    } else {
      parseObject.deleteInBackground()
    }
  }
}
PFQuery *query = [PFQuery queryWithClassName:@"Group"];

// Retrieve the object by id
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>" block:^(PFObject *parseObject, NSError *error) {
  // When using "removeObjectForKey", the field will be empty
  // [parseObject removeObjectForKey:@"definition"];
  // [parseObject removeObjectForKey:@"code"];
  // [parseObject removeObjectForKey:@"title"];
  // [parseObject removeObjectForKey:@"family"];
  // [parseObject removeObjectForKey:@"programs"];
  // Saves the field deletion to the Parse Cloud
  // [parseObject saveInBackground];

  // Or you can delete the entire object from the database
  [parseObject deleteInBackground];
}
ParseQuery<ParseObject> query = ParseObject.GetQuery("Group");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
await myObject.DeleteAsync();
$query = new ParseQuery("Group");
try {
  $myCustomObject = $query->get("<PARSE_OBJECT_ID>");
  // The object was retrieved successfully.

  // After this, the field will be empty
  $myCustomObject->delete("definition");
  $myCustomObject->delete("code");
  $myCustomObject->delete("title");
  $myCustomObject->delete("family");
  $myCustomObject->delete("programs");
  // Saves any changes done to the object
  $myCustomObject->save();

  // Otherwise, you can delete the entire object from the database
  $myCustomObject->destroy();
} catch (ParseException $ex) {
  // The object was not retrieved successfully.
  // error is a ParseException with an error code and message.
}

To delete an object send a DELETE request to this object endpoint with your app's credentials in the headers. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/classes/Group/MyCurrentObjectId

Method

DELETE

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

Success Response

Status

200 OK

Headers

content-type: application/json;

Body

An empty JSON object.

Error Response

Please check the Errors section.

Family Class

Example JSON:

{
  "title": "A string",
  "definition": "A string",
  "code": "A string",
  "groups": { "__type": "Relation", "className": "Group" }
}

Family is a custom class that was created and is specific for CIP. Please use the following documentation to learn how to perform CRUD (create, read, update and delete) operations to this specific class. A new endpoint was automatically generated at the address below to which you can send your requests:

https://parseapi.back4app.com/classes/Family

The following fields are supported by this class' schema and can be used in the operations:

Name Type Example
title String "A string"
definition String "A string"
code String "A string"
groups Relation { "__type": "Relation", "className": "Group" }

Creating Objects

Example Request:

curl -X POST \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "Content-Type: application/json" \
-d "{ \"title\":\"A string\",\"definition\":\"A string\",\"code\":\"A string\",\"groups\":{ \"__type\": \"Relation\", \"className\": \"Group\" } }" \
https://parseapi.back4app.com/classes/Family

Example Response:

{
  "objectId": "4BwpMWdCnm",
  "createdAt": "2018-11-06T00:52:01.520Z"
}

Code:

(async () => {
  const myNewObject = new Parse.Object('Family');
  myNewObject.set('title', 'A string');
  myNewObject.set('definition', 'A string');
  myNewObject.set('code', 'A string');
  myNewObject.set('groups', new Parse.Object("Group"));
  try {
    const result = await myNewObject.save();
    // Access the Parse Object attributes using the .GET method
    console.log('Family created', result);
  } catch (error) {
    console.error('Error while creating Family: ', error);
  }
})();
(async () => {
  const myNewObject: Parse.Object = new Parse.Object('Family');
  myNewObject.set('title', 'A string');
  myNewObject.set('definition', 'A string');
  myNewObject.set('code', 'A string');
  myNewObject.set('groups', new Parse.Object("Group"));
  try {
    const result: Parse.Object = await myNewObject.save();
    // Access the Parse Object attributes using the .GET method
    console.log('Family created', result);
  } catch (error: any) {
    console.error('Error while creating Family: ', error);
  }
})();
import java.util.Date;
import javax.json.JSONArray;
import javax.json.JSONObject;

import com.parse.ParseException;
import com.parse.ParseFile;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseRelation;
import com.parse.SaveCallback;

public void createObject() {
  ParseObject entity = new ParseObject("Family");

  entity.put("title", "A string");
  entity.put("definition", "A string");
  entity.put("code", "A string");
  entity.put("groups", new ParseObject("Group"));

  // Saves the new object.
  // Notice that the SaveCallback is totally optional!
  entity.saveInBackground(e -> {
    if (e==null){
      //Save was done
    }else{
      //Something went wrong
      Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });

}
var parseObject = PFObject(className:"Family")

parseObject["title"] = "A string"
parseObject["definition"] = "A string"
parseObject["code"] = "A string"
parseObject["groups"] = PFObject(className:"Group")

// Saves the new object.
parseObject.saveInBackground {
  (success: Bool, error: Error?) in
  if (success) {
    // The object has been saved.
  } else {
    // There was a problem, check error.description
  }
}
PFObject *parseObject = [PFObject objectWithClassName:@"Family"];

parseObject[@"title"] = @"A string";
parseObject[@"definition"] = @"A string";
parseObject[@"code"] = @"A string";
parseObject[@"groups"] = [PFObject objectWithClassName:@"Group"];

[parseObject saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
  if (succeeded) {
    // The object has been saved.
  } else {
    // There was a problem, check error.description
  }
}];
ParseObject myObject = new ParseObject("Family");
myObject["title"] = "A string";
myObject["definition"] = "A string";
myObject["code"] = "A string";
myObject["groups"] = new ParseObject("Group");
await myObject.SaveAsync();
$myCustomObject = new ParseObject("Family");

$myCustomObject->set("title", "A string");
$myCustomObject->set("definition", "A string");
$myCustomObject->set("code", "A string");
$myCustomObject->set("groups", new ParseObject("Group"));

try {
  $myCustomObject->save();
  echo 'New object created with objectId: ' . $myCustomObject->getObjectId();
} catch (ParseException $ex) {
  // Execute any logic that should take place if the save fails.
  // error is a ParseException object with an error code and message.
  echo 'Failed to create new object, with error message: ' . $ex->getMessage();
}

Example Output:

{
  id: 'xKue915KBG',
  _objCount: 0,
  className: 'Family
}

To create a new object of the Family class, you'll need to send a POST request to the Family class' endpoint with your app's credentials in the headers and the object's data in the body. You can include as many key-value pairs of the supported fields as you want. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/classes/Family

Method

POST

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

Content-Type: application/json

Body

A JSON document with the key-value pairs that represent your object's data according to the supported fields.

Success Response

Status

201 Created

Headers

Location: https://parseapi.back4app.com/classes/Family/MyNewObjectId

The Location header will contain the endpoint of the newly-created object.

Body

A JSON document with the objectId and createdAt fields of the newly-created object.

Error Response

Please check the Errors section.

Reading Objects

Example Request:

curl -X GET \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-G \
--data-urlencode "where={ \"title\":\"A string\",\"definition\":\"A string\",\"code\":\"A string\",\"groups\":{ \"__type\": \"Relation\", \"className\": \"Group\" } }" \
https://parseapi.back4app.com/classes/Family

Example Response:

{
  "results": [
    {
      "objectId": "zJxVP17mTi",
      "createdAt": "2018-10-31T14:16:13.616Z",
      "updatedAt": "2018-11-07T12:12:20.758Z",
      "title": \"A string\","definition": \"A string\","code": \"A string\","groups": { \"__type\": \"Relation\", \"className\": \"Group\" }
    },
    {
      "objectId": "yDbv0gKGJR",
      "createdAt": "2018-10-31T14:16:42.811Z",
      "updatedAt": "2018-11-07T12:12:18.543Z",
      "title": \"A string\","definition": \"A string\","code": \"A string\","groups": { \"__type\": \"Relation\", \"className\": \"Group\" }
    },
    {
      "objectId": "xKue915KBG",
      "createdAt": "2018-11-07T12:11:58.533Z",
      "updatedAt": "2018-11-07T12:12:15.413Z",
      "title": \"A string\","definition": \"A string\","code": \"A string\","groups": { \"__type\": \"Relation\", \"className\": \"Group\" }
    }
  ]
}

Without any URL parameters, this simply lists all objects in the class.

Learn more about query parameters in queries section.

Code:

(async () => {
  const Family = Parse.Object.extend('Family');
  const query = new Parse.Query(Family);
  // You can also query by using a parameter of an object
  // query.equalTo('objectId', 'xKue915KBG');
  try {
    const results = await query.find();
    for (const object of results) {
      // Access the Parse Object attributes using the .GET method
      const title = object.get('title')
      const definition = object.get('definition')
      const code = object.get('code')
      const groups = object.get('groups')
      console.log(title);
      console.log(definition);
      console.log(code);
      console.log(groups);
    }
  } catch (error) {
    console.error('Error while fetching Family', error);
  }
})();
(async () => {
  const Family: Parse.Object = Parse.Object.extend('Family');
  const query: Parse.Query = new Parse.Query(Family);
  // You can also query by using a parameter of an object
  // query.equalTo('objectId', 'xKue915KBG');
  try {
    const results: Parse.Object[] = await query.find();
    for (const object of results) {
      // Access the Parse Object attributes using the .GET method
      const title: string = object.get('title')
      const definition: string = object.get('definition')
      const code: string = object.get('code')
      const groups: string = object.get('groups')
      console.log(title);
      console.log(definition);
      console.log(code);
      console.log(groups);
    }
  } catch (error: any) {
    console.error('Error while fetching Family', error);
  }
})();

Example Output:

'A string' 'A string' 'A string' new Parse.Object("Group") 

To get the values out of the Parse.Object, use the get method.

Learn more about query parameters in queries section.

import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

public void readObject() {
  ParseQuery<ParseObject> query = ParseQuery.getQuery("Family");

  // The query will search for a ParseObject, given its objectId.
  // When the query finishes running, it will invoke the GetCallback
  // with either the object, or the exception thrown
  query.getInBackground("<PARSE_OBJECT_ID>", (object, e) -> {
        if (e == null) {
        //Object was successfully retrieved
      } else {
        // something went wrong
        Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
      }  
  });
}
var query = PFQuery(className:"Family")

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error == nil && parseObject != nil {
    print(parseObject)
  } else {
    print(error)
  }
}
PFQuery *query = [PFQuery queryWithClassName:@"Family"];
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>" block:^(PFObject *parseObject, NSError *error) {
    // Do something with the returned PFObject in the parseObject variable.
    NSLog(@"%@", parseObject);
}];
ParseQuery<ParseObject> query = ParseObject.GetQuery("Family");
ParseObject result = await query.GetAsync("<PARSE_OBJECT_ID>");
// Use the Get<T> method to get the values
string title = result.Get<string>("title");
string definition = result.Get<string>("definition");
string code = result.Get<string>("code");
ParseRelation groups = result.Get<ParseRelation>("groups");
$query = new ParseQuery("Family");
try {
  $myCustomObject = $query->get("<PARSE_OBJECT_ID>");
  // The object was retrieved successfully.

  // To get attributes, you can use the "get" method, providing the attribute name:
  $title = $myCustomObject->get("title");
  $definition = $myCustomObject->get("definition");
  $code = $myCustomObject->get("code");
  $groups = $myCustomObject->get("groups");
} catch (ParseException $ex) {
  // The object was not retrieved successfully.
  // error is a ParseException with an error code and message.
}

To retrieve an object, you'll need to send a GET request to its class endpoint with your app's credentials in the headers and the query parameters in the URL parameters. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/classes/Family

Method

GET

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

Parameters

A where URL parameter constraining the value for keys. It should be encoded JSON.

Success Response

Status

200 OK

Headers

content-type: application/json;

Body

a JSON object that contains a results field with a JSON array that lists the objects.

Error Response

Please check the Errors section.

Updating Objects

Example Request:


# Don't forget to set the OBJECT_ID parameter
curl -X PUT \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "Content-Type: application/json" \
-d "{ \"title\": \"A string\",\"definition\": \"A string\",\"code\": \"A string\",\"groups\": { \"__type\": \"Relation\", \"className\": \"Group\" } }" \
https://parseapi.back4app.com/classes/Family/<OBJECT_ID>

Example Response:

{
  "updatedAt": "2011-08-21T18:02:52.248Z"
}

You can delete a single field from an object by using the Delete operation:

Example Request:


curl -X PUT \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "Content-Type: application/json" \
-d '{ "title": {"__op":"Delete"},"definition": {"__op":"Delete"},"code": {"__op":"Delete"},"groups": {"__op":"Delete"} }' \
https://parseapi.back4app.com/classes/Family

Example Response:

{
  "updatedAt": "2011-08-21T18:02:52.248Z"
}

Code:

(async () => {
  const query = new Parse.Query(Family);
  try {
    // here you put the objectId that you want to update
    const object = await query.get('xKue915KBG');
    object.set('title', 'A string');
    object.set('definition', 'A string');
    object.set('code', 'A string');
    object.set('groups', new Parse.Object("Group"));
    try {
      const response = await object.save();
      // You can use the "get" method to get the value of an attribute
      // Ex: response.get("<ATTRIBUTE_NAME>")
      // Access the Parse Object attributes using the .GET method
      console.log(response.get('title'));
      console.log(response.get('definition'));
      console.log(response.get('code'));
      console.log(response.get('groups'));
      console.log('Family updated', response);
    } catch (error) {
      console.error('Error while updating Family', error);
      }
    } catch (error) {
      console.error('Error while retrieving object Family', error);
    }
})();
(async () => {
  const query: Parse.Query = new Parse.Query(Family);
  try {
    // here you put the objectId that you want to update
    const object: Parse.Object = await query.get('xKue915KBG');
    object.set('title', 'A string');
    object.set('definition', 'A string');
    object.set('code', 'A string');
    object.set('groups', new Parse.Object("Group"));
    try {
      const response: Parse.Object = await object.save();
      // You can use the "get" method to get the value of an attribute
      // Ex: response.get("<ATTRIBUTE_NAME>")
      // Access the Parse Object attributes using the .GET method
      console.log(response.get('title'));
      console.log(response.get('definition'));
      console.log(response.get('code'));
      console.log(response.get('groups'));
      console.log('Family updated', response);
    } catch (error: any) {
      console.error('Error while updating Family', error);
      }
    } catch (error: any) {
      console.error('Error while retrieving object Family', error);
    }
})();

Example Output:


title
definition
code
groups
Family updated
{
  className: Family,
   _objCount: 0,
   id: 'xKue915KBG'
}

You can delete a single field from an object with the unset method:

(async() => {
  const query = new Parse.Query('Family');
  try {
    const object = await query.get('xKue915KBG');
    // After this, the myCustomKeyName field will be empty
    object.unset('groups');
    try {
      const response = await object.save();
      console.log(response);
      // Access the Parse Object attributes using the .GET method
      console.log(response.get('groups'));
    } catch (error) {
      console.error(error);
    }
  } catch (error) {
    console.error(error);    
  }
})();
(async() => {
  const query: Parse.Query = new Parse.Query('Family');
  try {
    const object: Parse.Object = await query.get('xKue915KBG');
    // After this, the myCustomKeyName field will be empty
    object.unset('groups');
    try {
      const response: Parse.Object = await object.save();
      console.log(response);
      // Access the Parse Object attributes using the .GET method
      console.log(response.get('groups'));
    } catch (error: any) {
      console.error(error);
    }
  } catch (error: any) {
    console.error(error);    
  }
})();

Example Output:

{
  className: Family,
  id: 'xKue915KBG',
  _localId: undefined,
  _objCount: 0, 
}
undefined

Please note that use of object.set(null) to remove a field from an object is not recommended and will result in unexpected functionality.

import java.util.Date;
import javax.json.JSONArray;
import javax.json.JSONObject;

import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseFile;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseRelation;

public void updateObject() {
  ParseQuery<ParseObject> query = ParseQuery.getQuery("Family");

  // Retrieve the object by id
  query.getInBackground("<PARSE_OBJECT_ID>", (object, e) -> {
    if (e == null) {
      //Object was successfully retrieved
      // Update the fields we want to
      object.put("title", "A string");
      object.put("definition", "A string");
      object.put("code", "A string");
      object.put("groups", new ParseObject("Group"));

      //All other fields will remain the same
      object.saveInBackground();

    } else {
      // something went wrong
      Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
    }  
  });

}
var query = PFQuery(className:"Family")

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error != nil {
    print(error)
  } else if parseObject != nil {
    parseObject["title"] = "A string"
    parseObject["definition"] = "A string"
    parseObject["code"] = "A string"
    parseObject["groups"] = PFObject(className:"Group")

    parseObject.saveInBackground()
  }
}
PFQuery *query = [PFQuery queryWithClassName:@"Family"];

// Retrieve the object by id
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>"
                             block:^(PFObject *parseObject, NSError *error) {
    parseObject[@"title"] = @"A string";
    parseObject[@"definition"] = @"A string";
    parseObject[@"code"] = @"A string";
    parseObject[@"groups"] = [PFObject objectWithClassName:@"Group"];

    [parseObject saveInBackground];
}];
ParseQuery<ParseObject> query = ParseObject.GetQuery("Family");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
myObject["title"] = "A string";
myObject["definition"] = "A string";
myObject["code"] = "A string";
myObject["groups"] = new ParseObject("Group");
await myObject.SaveAsync();

You can delete a single field from an object with the Remove method:

ParseQuery<ParseObject> query = ParseObject.GetQuery("MyCustomClassName");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
myObject.Remove("title");
myObject.Remove("definition");
myObject.Remove("code");
myObject.Remove("groups");
await myObject.SaveAsync();
$query = new ParseQuery("Family");
try {
  $myCustomObject = $query->get("<PARSE_OBJECT_ID>");
  // The object was retrieved successfully.

  // Update any data you want with the "set" method,
  // providing the attribute name and the new value
  $myCustomObject->set("title", "A string");
  $myCustomObject->set("definition", "A string");
  $myCustomObject->set("code", "A string");
  $myCustomObject->set("groups", new ParseObject("Group"));

  // And then save your changes
  $myCustomObject->save();
} catch (ParseException $ex) {
  // The object was not retrieved successfully.
  // error is a ParseException with an error code and message.
}

To update data on an object that already exists, send a PUT request to this object endpoint with your app's credentials in the headers and the query parameters in the body. Any keys you don’t specify will remain unchanged, so you can update just a subset of the object’s data. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/classes/Family/MyCurrentObjectId

Method

PUT

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

Content-Type: application/json

Body

A JSON document with the key-value pairs that represent the object's new data.

Success Response

Status

200 OK

Headers

content-type: application/json;

Body

a JSON object that contains a updatedAt field with the timestamp of the update.

Error Response

Please check the Errors section.

Deleting Objects

Example Request:

# Don't forget to set the OBJECT_ID parameter
curl -X DELETE \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
https://parseapi.back4app.com/classes/Family/<OBJECT_ID>

Example Response:

{}

Code:

(async () => {
  const query = new Parse.Query('Family');
  try {
    // here you put the objectId that you want to delete
    const object = await query.get('xKue915KBG');
    try {
      const response = await object.destroy();
      console.log('Deleted ParseObject', response);
    } catch (error) {
      console.error('Error while deleting ParseObject', error);
    }
  } catch (error) {
    console.error('Error while retrieving ParseObject', error);
  }
})();
(async () => {
  const query: Parse.Query = new Parse.Query('Family');
  try {
    // here you put the objectId that you want to delete
    const object: Parse.Object = await query.get('xKue915KBG');
    try {
      const response: any = await object.destroy();
      console.log('Deleted ParseObject', response);
    } catch (error: any) {
      console.error('Error while deleting ParseObject', error);
    }
  } catch (error: any) {
    console.error('Error while retrieving ParseObject', error);
  }
})();

Example Output:

Deleted ParseObject
{
  className: 'Family',
  _objCount: 0,
  id: 'xKue915KBG'
}
import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

public void deleteObject() {

  ParseQuery<ParseObject> query = ParseQuery.getQuery("Family");

  // Retrieve the object by id
  query.getInBackground("<PARSE_OBJECT_ID>", (object, e) -> {
    if (e == null) {
      //Object was fetched
      //Deletes the fetched ParseObject from the database
      object.deleteInBackground(e2 -> {
          if(e2==null){
              Toast.makeText(this, "Delete Successful", Toast.LENGTH_SHORT).show();
          }else{
              //Something went wrong while deleting the Object
              Toast.makeText(this, "Error: "+e2.getMessage(), Toast.LENGTH_SHORT).show();
          }
      });
    }else{
      //Something went wrong
      Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });

}
var deleteAttributesOnly = true

var query = PFQuery(className:"Family")

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error != nil {
    print(error)
  } else if parseObject != nil {
    if deleteAttributesOnly {
      parseObject.removeObjectForKey("title")
      parseObject.removeObjectForKey("definition")
      parseObject.removeObjectForKey("code")
      parseObject.removeObjectForKey("groups")
      parseObject.saveInBackground()
    } else {
      parseObject.deleteInBackground()
    }
  }
}
PFQuery *query = [PFQuery queryWithClassName:@"Family"];

// Retrieve the object by id
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>" block:^(PFObject *parseObject, NSError *error) {
  // When using "removeObjectForKey", the field will be empty
  // [parseObject removeObjectForKey:@"title"];
  // [parseObject removeObjectForKey:@"definition"];
  // [parseObject removeObjectForKey:@"code"];
  // [parseObject removeObjectForKey:@"groups"];
  // Saves the field deletion to the Parse Cloud
  // [parseObject saveInBackground];

  // Or you can delete the entire object from the database
  [parseObject deleteInBackground];
}
ParseQuery<ParseObject> query = ParseObject.GetQuery("Family");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
await myObject.DeleteAsync();
$query = new ParseQuery("Family");
try {
  $myCustomObject = $query->get("<PARSE_OBJECT_ID>");
  // The object was retrieved successfully.

  // After this, the field will be empty
  $myCustomObject->delete("title");
  $myCustomObject->delete("definition");
  $myCustomObject->delete("code");
  $myCustomObject->delete("groups");
  // Saves any changes done to the object
  $myCustomObject->save();

  // Otherwise, you can delete the entire object from the database
  $myCustomObject->destroy();
} catch (ParseException $ex) {
  // The object was not retrieved successfully.
  // error is a ParseException with an error code and message.
}

To delete an object send a DELETE request to this object endpoint with your app's credentials in the headers. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/classes/Family/MyCurrentObjectId

Method

DELETE

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

Success Response

Status

200 OK

Headers

content-type: application/json;

Body

An empty JSON object.

Error Response

Please check the Errors section.

Program Class

Example JSON:

{
  "definition": "A string",
  "code": "A string",
  "title": "A string",
  "crossReferences": "A string",
  "examples": "A string",
  "group": { "__type": "Pointer", "className": "Group", "objectId": "<THE_REFERENCED_OBJECT_ID>" }
}

Program is a custom class that was created and is specific for CIP. Please use the following documentation to learn how to perform CRUD (create, read, update and delete) operations to this specific class. A new endpoint was automatically generated at the address below to which you can send your requests:

https://parseapi.back4app.com/classes/Program

The following fields are supported by this class' schema and can be used in the operations:

Name Type Example
definition String "A string"
code String "A string"
title String "A string"
crossReferences String "A string"
examples String "A string"
group Pointer { "__type": "Pointer", "className": "Group", "objectId": "<THE_REFERENCED_OBJECT_ID>" }

Creating Objects

Example Request:

curl -X POST \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "Content-Type: application/json" \
-d "{ \"definition\":\"A string\",\"code\":\"A string\",\"title\":\"A string\",\"crossReferences\":\"A string\",\"examples\":\"A string\",\"group\":{ \"__type\": \"Pointer\", \"className\": \"Group\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" } }" \
https://parseapi.back4app.com/classes/Program

Example Response:

{
  "objectId": "4BwpMWdCnm",
  "createdAt": "2018-11-06T00:52:01.520Z"
}

Code:

(async () => {
  const myNewObject = new Parse.Object('Program');
  myNewObject.set('definition', 'A string');
  myNewObject.set('code', 'A string');
  myNewObject.set('title', 'A string');
  myNewObject.set('crossReferences', 'A string');
  myNewObject.set('examples', 'A string');
  myNewObject.set('group', new Parse.Object("Group"));
  try {
    const result = await myNewObject.save();
    // Access the Parse Object attributes using the .GET method
    console.log('Program created', result);
  } catch (error) {
    console.error('Error while creating Program: ', error);
  }
})();
(async () => {
  const myNewObject: Parse.Object = new Parse.Object('Program');
  myNewObject.set('definition', 'A string');
  myNewObject.set('code', 'A string');
  myNewObject.set('title', 'A string');
  myNewObject.set('crossReferences', 'A string');
  myNewObject.set('examples', 'A string');
  myNewObject.set('group', new Parse.Object("Group"));
  try {
    const result: Parse.Object = await myNewObject.save();
    // Access the Parse Object attributes using the .GET method
    console.log('Program created', result);
  } catch (error: any) {
    console.error('Error while creating Program: ', error);
  }
})();
import java.util.Date;
import javax.json.JSONArray;
import javax.json.JSONObject;

import com.parse.ParseException;
import com.parse.ParseFile;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseRelation;
import com.parse.SaveCallback;

public void createObject() {
  ParseObject entity = new ParseObject("Program");

  entity.put("definition", "A string");
  entity.put("code", "A string");
  entity.put("title", "A string");
  entity.put("crossReferences", "A string");
  entity.put("examples", "A string");
  entity.put("group", new ParseObject("Group"));

  // Saves the new object.
  // Notice that the SaveCallback is totally optional!
  entity.saveInBackground(e -> {
    if (e==null){
      //Save was done
    }else{
      //Something went wrong
      Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });

}
var parseObject = PFObject(className:"Program")

parseObject["definition"] = "A string"
parseObject["code"] = "A string"
parseObject["title"] = "A string"
parseObject["crossReferences"] = "A string"
parseObject["examples"] = "A string"
parseObject["group"] = PFObject(className:"Group")

// Saves the new object.
parseObject.saveInBackground {
  (success: Bool, error: Error?) in
  if (success) {
    // The object has been saved.
  } else {
    // There was a problem, check error.description
  }
}
PFObject *parseObject = [PFObject objectWithClassName:@"Program"];

parseObject[@"definition"] = @"A string";
parseObject[@"code"] = @"A string";
parseObject[@"title"] = @"A string";
parseObject[@"crossReferences"] = @"A string";
parseObject[@"examples"] = @"A string";
parseObject[@"group"] = [PFObject objectWithClassName:@"Group"];

[parseObject saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
  if (succeeded) {
    // The object has been saved.
  } else {
    // There was a problem, check error.description
  }
}];
ParseObject myObject = new ParseObject("Program");
myObject["definition"] = "A string";
myObject["code"] = "A string";
myObject["title"] = "A string";
myObject["crossReferences"] = "A string";
myObject["examples"] = "A string";
myObject["group"] = new ParseObject("Group");
await myObject.SaveAsync();
$myCustomObject = new ParseObject("Program");

$myCustomObject->set("definition", "A string");
$myCustomObject->set("code", "A string");
$myCustomObject->set("title", "A string");
$myCustomObject->set("crossReferences", "A string");
$myCustomObject->set("examples", "A string");
$myCustomObject->set("group", new ParseObject("Group"));

try {
  $myCustomObject->save();
  echo 'New object created with objectId: ' . $myCustomObject->getObjectId();
} catch (ParseException $ex) {
  // Execute any logic that should take place if the save fails.
  // error is a ParseException object with an error code and message.
  echo 'Failed to create new object, with error message: ' . $ex->getMessage();
}

Example Output:

{
  id: 'xKue915KBG',
  _objCount: 0,
  className: 'Program
}

To create a new object of the Program class, you'll need to send a POST request to the Program class' endpoint with your app's credentials in the headers and the object's data in the body. You can include as many key-value pairs of the supported fields as you want. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/classes/Program

Method

POST

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

Content-Type: application/json

Body

A JSON document with the key-value pairs that represent your object's data according to the supported fields.

Success Response

Status

201 Created

Headers

Location: https://parseapi.back4app.com/classes/Program/MyNewObjectId

The Location header will contain the endpoint of the newly-created object.

Body

A JSON document with the objectId and createdAt fields of the newly-created object.

Error Response

Please check the Errors section.

Reading Objects

Example Request:

curl -X GET \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-G \
--data-urlencode "where={ \"definition\":\"A string\",\"code\":\"A string\",\"title\":\"A string\",\"crossReferences\":\"A string\",\"examples\":\"A string\",\"group\":{ \"__type\": \"Pointer\", \"className\": \"Group\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" } }" \
https://parseapi.back4app.com/classes/Program

Example Response:

{
  "results": [
    {
      "objectId": "zJxVP17mTi",
      "createdAt": "2018-10-31T14:16:13.616Z",
      "updatedAt": "2018-11-07T12:12:20.758Z",
      "definition": \"A string\","code": \"A string\","title": \"A string\","crossReferences": \"A string\","examples": \"A string\","group": { \"__type\": \"Pointer\", \"className\": \"Group\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" }
    },
    {
      "objectId": "yDbv0gKGJR",
      "createdAt": "2018-10-31T14:16:42.811Z",
      "updatedAt": "2018-11-07T12:12:18.543Z",
      "definition": \"A string\","code": \"A string\","title": \"A string\","crossReferences": \"A string\","examples": \"A string\","group": { \"__type\": \"Pointer\", \"className\": \"Group\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" }
    },
    {
      "objectId": "xKue915KBG",
      "createdAt": "2018-11-07T12:11:58.533Z",
      "updatedAt": "2018-11-07T12:12:15.413Z",
      "definition": \"A string\","code": \"A string\","title": \"A string\","crossReferences": \"A string\","examples": \"A string\","group": { \"__type\": \"Pointer\", \"className\": \"Group\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" }
    }
  ]
}

Without any URL parameters, this simply lists all objects in the class.

Learn more about query parameters in queries section.

Code:

(async () => {
  const Program = Parse.Object.extend('Program');
  const query = new Parse.Query(Program);
  // You can also query by using a parameter of an object
  // query.equalTo('objectId', 'xKue915KBG');
  try {
    const results = await query.find();
    for (const object of results) {
      // Access the Parse Object attributes using the .GET method
      const definition = object.get('definition')
      const code = object.get('code')
      const title = object.get('title')
      const crossReferences = object.get('crossReferences')
      const examples = object.get('examples')
      const group = object.get('group')
      console.log(definition);
      console.log(code);
      console.log(title);
      console.log(crossReferences);
      console.log(examples);
      console.log(group);
    }
  } catch (error) {
    console.error('Error while fetching Program', error);
  }
})();
(async () => {
  const Program: Parse.Object = Parse.Object.extend('Program');
  const query: Parse.Query = new Parse.Query(Program);
  // You can also query by using a parameter of an object
  // query.equalTo('objectId', 'xKue915KBG');
  try {
    const results: Parse.Object[] = await query.find();
    for (const object of results) {
      // Access the Parse Object attributes using the .GET method
      const definition: string = object.get('definition')
      const code: string = object.get('code')
      const title: string = object.get('title')
      const crossReferences: string = object.get('crossReferences')
      const examples: string = object.get('examples')
      const group: string = object.get('group')
      console.log(definition);
      console.log(code);
      console.log(title);
      console.log(crossReferences);
      console.log(examples);
      console.log(group);
    }
  } catch (error: any) {
    console.error('Error while fetching Program', error);
  }
})();

Example Output:

'A string' 'A string' 'A string' 'A string' 'A string' new Parse.Object("Group") 

To get the values out of the Parse.Object, use the get method.

Learn more about query parameters in queries section.

import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

public void readObject() {
  ParseQuery<ParseObject> query = ParseQuery.getQuery("Program");

  // The query will search for a ParseObject, given its objectId.
  // When the query finishes running, it will invoke the GetCallback
  // with either the object, or the exception thrown
  query.getInBackground("<PARSE_OBJECT_ID>", (object, e) -> {
        if (e == null) {
        //Object was successfully retrieved
      } else {
        // something went wrong
        Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
      }  
  });
}
var query = PFQuery(className:"Program")

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error == nil && parseObject != nil {
    print(parseObject)
  } else {
    print(error)
  }
}
PFQuery *query = [PFQuery queryWithClassName:@"Program"];
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>" block:^(PFObject *parseObject, NSError *error) {
    // Do something with the returned PFObject in the parseObject variable.
    NSLog(@"%@", parseObject);
}];
ParseQuery<ParseObject> query = ParseObject.GetQuery("Program");
ParseObject result = await query.GetAsync("<PARSE_OBJECT_ID>");
// Use the Get<T> method to get the values
string definition = result.Get<string>("definition");
string code = result.Get<string>("code");
string title = result.Get<string>("title");
string crossReferences = result.Get<string>("crossReferences");
string examples = result.Get<string>("examples");
ParseObject group = result.Get<ParseObject>("group");
$query = new ParseQuery("Program");
try {
  $myCustomObject = $query->get("<PARSE_OBJECT_ID>");
  // The object was retrieved successfully.

  // To get attributes, you can use the "get" method, providing the attribute name:
  $definition = $myCustomObject->get("definition");
  $code = $myCustomObject->get("code");
  $title = $myCustomObject->get("title");
  $crossReferences = $myCustomObject->get("crossReferences");
  $examples = $myCustomObject->get("examples");
  $group = $myCustomObject->get("group");
} catch (ParseException $ex) {
  // The object was not retrieved successfully.
  // error is a ParseException with an error code and message.
}

To retrieve an object, you'll need to send a GET request to its class endpoint with your app's credentials in the headers and the query parameters in the URL parameters. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/classes/Program

Method

GET

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

Parameters

A where URL parameter constraining the value for keys. It should be encoded JSON.

Success Response

Status

200 OK

Headers

content-type: application/json;

Body

a JSON object that contains a results field with a JSON array that lists the objects.

Error Response

Please check the Errors section.

Updating Objects

Example Request:


# Don't forget to set the OBJECT_ID parameter
curl -X PUT \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "Content-Type: application/json" \
-d "{ \"definition\": \"A string\",\"code\": \"A string\",\"title\": \"A string\",\"crossReferences\": \"A string\",\"examples\": \"A string\",\"group\": { \"__type\": \"Pointer\", \"className\": \"Group\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" } }" \
https://parseapi.back4app.com/classes/Program/<OBJECT_ID>

Example Response:

{
  "updatedAt": "2011-08-21T18:02:52.248Z"
}

You can delete a single field from an object by using the Delete operation:

Example Request:


curl -X PUT \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "Content-Type: application/json" \
-d '{ "definition": {"__op":"Delete"},"code": {"__op":"Delete"},"title": {"__op":"Delete"},"crossReferences": {"__op":"Delete"},"examples": {"__op":"Delete"},"group": {"__op":"Delete"} }' \
https://parseapi.back4app.com/classes/Program

Example Response:

{
  "updatedAt": "2011-08-21T18:02:52.248Z"
}

Code:

(async () => {
  const query = new Parse.Query(Program);
  try {
    // here you put the objectId that you want to update
    const object = await query.get('xKue915KBG');
    object.set('definition', 'A string');
    object.set('code', 'A string');
    object.set('title', 'A string');
    object.set('crossReferences', 'A string');
    object.set('examples', 'A string');
    object.set('group', new Parse.Object("Group"));
    try {
      const response = await object.save();
      // You can use the "get" method to get the value of an attribute
      // Ex: response.get("<ATTRIBUTE_NAME>")
      // Access the Parse Object attributes using the .GET method
      console.log(response.get('definition'));
      console.log(response.get('code'));
      console.log(response.get('title'));
      console.log(response.get('crossReferences'));
      console.log(response.get('examples'));
      console.log(response.get('group'));
      console.log('Program updated', response);
    } catch (error) {
      console.error('Error while updating Program', error);
      }
    } catch (error) {
      console.error('Error while retrieving object Program', error);
    }
})();
(async () => {
  const query: Parse.Query = new Parse.Query(Program);
  try {
    // here you put the objectId that you want to update
    const object: Parse.Object = await query.get('xKue915KBG');
    object.set('definition', 'A string');
    object.set('code', 'A string');
    object.set('title', 'A string');
    object.set('crossReferences', 'A string');
    object.set('examples', 'A string');
    object.set('group', new Parse.Object("Group"));
    try {
      const response: Parse.Object = await object.save();
      // You can use the "get" method to get the value of an attribute
      // Ex: response.get("<ATTRIBUTE_NAME>")
      // Access the Parse Object attributes using the .GET method
      console.log(response.get('definition'));
      console.log(response.get('code'));
      console.log(response.get('title'));
      console.log(response.get('crossReferences'));
      console.log(response.get('examples'));
      console.log(response.get('group'));
      console.log('Program updated', response);
    } catch (error: any) {
      console.error('Error while updating Program', error);
      }
    } catch (error: any) {
      console.error('Error while retrieving object Program', error);
    }
})();

Example Output:


definition
code
title
crossReferences
examples
group
Program updated
{
  className: Program,
   _objCount: 0,
   id: 'xKue915KBG'
}

You can delete a single field from an object with the unset method:

(async() => {
  const query = new Parse.Query('Program');
  try {
    const object = await query.get('xKue915KBG');
    // After this, the myCustomKeyName field will be empty
    object.unset('group');
    try {
      const response = await object.save();
      console.log(response);
      // Access the Parse Object attributes using the .GET method
      console.log(response.get('group'));
    } catch (error) {
      console.error(error);
    }
  } catch (error) {
    console.error(error);    
  }
})();
(async() => {
  const query: Parse.Query = new Parse.Query('Program');
  try {
    const object: Parse.Object = await query.get('xKue915KBG');
    // After this, the myCustomKeyName field will be empty
    object.unset('group');
    try {
      const response: Parse.Object = await object.save();
      console.log(response);
      // Access the Parse Object attributes using the .GET method
      console.log(response.get('group'));
    } catch (error: any) {
      console.error(error);
    }
  } catch (error: any) {
    console.error(error);    
  }
})();

Example Output:

{
  className: Program,
  id: 'xKue915KBG',
  _localId: undefined,
  _objCount: 0, 
}
undefined

Please note that use of object.set(null) to remove a field from an object is not recommended and will result in unexpected functionality.

import java.util.Date;
import javax.json.JSONArray;
import javax.json.JSONObject;

import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseFile;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseRelation;

public void updateObject() {
  ParseQuery<ParseObject> query = ParseQuery.getQuery("Program");

  // Retrieve the object by id
  query.getInBackground("<PARSE_OBJECT_ID>", (object, e) -> {
    if (e == null) {
      //Object was successfully retrieved
      // Update the fields we want to
      object.put("definition", "A string");
      object.put("code", "A string");
      object.put("title", "A string");
      object.put("crossReferences", "A string");
      object.put("examples", "A string");
      object.put("group", new ParseObject("Group"));

      //All other fields will remain the same
      object.saveInBackground();

    } else {
      // something went wrong
      Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
    }  
  });

}
var query = PFQuery(className:"Program")

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error != nil {
    print(error)
  } else if parseObject != nil {
    parseObject["definition"] = "A string"
    parseObject["code"] = "A string"
    parseObject["title"] = "A string"
    parseObject["crossReferences"] = "A string"
    parseObject["examples"] = "A string"
    parseObject["group"] = PFObject(className:"Group")

    parseObject.saveInBackground()
  }
}
PFQuery *query = [PFQuery queryWithClassName:@"Program"];

// Retrieve the object by id
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>"
                             block:^(PFObject *parseObject, NSError *error) {
    parseObject[@"definition"] = @"A string";
    parseObject[@"code"] = @"A string";
    parseObject[@"title"] = @"A string";
    parseObject[@"crossReferences"] = @"A string";
    parseObject[@"examples"] = @"A string";
    parseObject[@"group"] = [PFObject objectWithClassName:@"Group"];

    [parseObject saveInBackground];
}];
ParseQuery<ParseObject> query = ParseObject.GetQuery("Program");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
myObject["definition"] = "A string";
myObject["code"] = "A string";
myObject["title"] = "A string";
myObject["crossReferences"] = "A string";
myObject["examples"] = "A string";
myObject["group"] = new ParseObject("Group");
await myObject.SaveAsync();

You can delete a single field from an object with the Remove method:

ParseQuery<ParseObject> query = ParseObject.GetQuery("MyCustomClassName");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
myObject.Remove("definition");
myObject.Remove("code");
myObject.Remove("title");
myObject.Remove("crossReferences");
myObject.Remove("examples");
myObject.Remove("group");
await myObject.SaveAsync();
$query = new ParseQuery("Program");
try {
  $myCustomObject = $query->get("<PARSE_OBJECT_ID>");
  // The object was retrieved successfully.

  // Update any data you want with the "set" method,
  // providing the attribute name and the new value
  $myCustomObject->set("definition", "A string");
  $myCustomObject->set("code", "A string");
  $myCustomObject->set("title", "A string");
  $myCustomObject->set("crossReferences", "A string");
  $myCustomObject->set("examples", "A string");
  $myCustomObject->set("group", new ParseObject("Group"));

  // And then save your changes
  $myCustomObject->save();
} catch (ParseException $ex) {
  // The object was not retrieved successfully.
  // error is a ParseException with an error code and message.
}

To update data on an object that already exists, send a PUT request to this object endpoint with your app's credentials in the headers and the query parameters in the body. Any keys you don’t specify will remain unchanged, so you can update just a subset of the object’s data. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/classes/Program/MyCurrentObjectId

Method

PUT

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

Content-Type: application/json

Body

A JSON document with the key-value pairs that represent the object's new data.

Success Response

Status

200 OK

Headers

content-type: application/json;

Body

a JSON object that contains a updatedAt field with the timestamp of the update.

Error Response

Please check the Errors section.

Deleting Objects

Example Request:

# Don't forget to set the OBJECT_ID parameter
curl -X DELETE \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
https://parseapi.back4app.com/classes/Program/<OBJECT_ID>

Example Response:

{}

Code:

(async () => {
  const query = new Parse.Query('Program');
  try {
    // here you put the objectId that you want to delete
    const object = await query.get('xKue915KBG');
    try {
      const response = await object.destroy();
      console.log('Deleted ParseObject', response);
    } catch (error) {
      console.error('Error while deleting ParseObject', error);
    }
  } catch (error) {
    console.error('Error while retrieving ParseObject', error);
  }
})();
(async () => {
  const query: Parse.Query = new Parse.Query('Program');
  try {
    // here you put the objectId that you want to delete
    const object: Parse.Object = await query.get('xKue915KBG');
    try {
      const response: any = await object.destroy();
      console.log('Deleted ParseObject', response);
    } catch (error: any) {
      console.error('Error while deleting ParseObject', error);
    }
  } catch (error: any) {
    console.error('Error while retrieving ParseObject', error);
  }
})();

Example Output:

Deleted ParseObject
{
  className: 'Program',
  _objCount: 0,
  id: 'xKue915KBG'
}
import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

public void deleteObject() {

  ParseQuery<ParseObject> query = ParseQuery.getQuery("Program");

  // Retrieve the object by id
  query.getInBackground("<PARSE_OBJECT_ID>", (object, e) -> {
    if (e == null) {
      //Object was fetched
      //Deletes the fetched ParseObject from the database
      object.deleteInBackground(e2 -> {
          if(e2==null){
              Toast.makeText(this, "Delete Successful", Toast.LENGTH_SHORT).show();
          }else{
              //Something went wrong while deleting the Object
              Toast.makeText(this, "Error: "+e2.getMessage(), Toast.LENGTH_SHORT).show();
          }
      });
    }else{
      //Something went wrong
      Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });

}
var deleteAttributesOnly = true

var query = PFQuery(className:"Program")

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error != nil {
    print(error)
  } else if parseObject != nil {
    if deleteAttributesOnly {
      parseObject.removeObjectForKey("definition")
      parseObject.removeObjectForKey("code")
      parseObject.removeObjectForKey("title")
      parseObject.removeObjectForKey("crossReferences")
      parseObject.removeObjectForKey("examples")
      parseObject.removeObjectForKey("group")
      parseObject.saveInBackground()
    } else {
      parseObject.deleteInBackground()
    }
  }
}
PFQuery *query = [PFQuery queryWithClassName:@"Program"];

// Retrieve the object by id
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>" block:^(PFObject *parseObject, NSError *error) {
  // When using "removeObjectForKey", the field will be empty
  // [parseObject removeObjectForKey:@"definition"];
  // [parseObject removeObjectForKey:@"code"];
  // [parseObject removeObjectForKey:@"title"];
  // [parseObject removeObjectForKey:@"crossReferences"];
  // [parseObject removeObjectForKey:@"examples"];
  // [parseObject removeObjectForKey:@"group"];
  // Saves the field deletion to the Parse Cloud
  // [parseObject saveInBackground];

  // Or you can delete the entire object from the database
  [parseObject deleteInBackground];
}
ParseQuery<ParseObject> query = ParseObject.GetQuery("Program");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
await myObject.DeleteAsync();
$query = new ParseQuery("Program");
try {
  $myCustomObject = $query->get("<PARSE_OBJECT_ID>");
  // The object was retrieved successfully.

  // After this, the field will be empty
  $myCustomObject->delete("definition");
  $myCustomObject->delete("code");
  $myCustomObject->delete("title");
  $myCustomObject->delete("crossReferences");
  $myCustomObject->delete("examples");
  $myCustomObject->delete("group");
  // Saves any changes done to the object
  $myCustomObject->save();

  // Otherwise, you can delete the entire object from the database
  $myCustomObject->destroy();
} catch (ParseException $ex) {
  // The object was not retrieved successfully.
  // error is a ParseException with an error code and message.
}

To delete an object send a DELETE request to this object endpoint with your app's credentials in the headers. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/classes/Program/MyCurrentObjectId

Method

DELETE

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

Success Response

Status

200 OK

Headers

content-type: application/json;

Body

An empty JSON object.

Error Response

Please check the Errors section.

User API

Example Object:

{
  "objectId": "4BwpMWdCnm",
  "username": "A string",
  "email": "A string",
  "password": "#Password123",
  "createdAt": "2018-11-06T00:52:01.520Z",
  "updatedAt": "2018-11-06T00:52:04.713Z"
}

The special keys objectId, createdAt and updatedAt are default and always automatically created by the platform.

User is a subclass of Object, what meanings that has the same properties and methods as a generic object. The difference is that Parse.User has some special additions specific to user accounts.

As others objects, users have a flexible schema, the differences are that the username and password fields are required and username and email must be unique per user.

For each new custom class that you create in your app's schema (either through API or just sending the data), a new endpoint is generated at the address below through which you can perform your CRUD operations:

https://parseapi.back4app.com/user/MyCurrentUserObjectId

Signing Up

Example Request:

# Don't forget to set your own User data!
curl -X POST \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "X-Parse-Revocable-Session: 1" \
-H "Content-Type: application/json" \
-d "{ \"password\":\"#Password123\", \"username\": \"A string\",\"email\": \"A string\" }" \
https://parseapi.back4app.com/users

Example Response:

{ "objectId":"nr7hAYS43a","createdAt":"2018-11-08T13:08:42.914Z","sessionToken":"r:35c2ae1c1def6c38a469e41ce671cb7e" }

Code:

(async () => {
  const user = new Parse.User();
  user.set('username', 'A string');
  user.set('email', 'A string');
  user.set('password', '#Password123');

  try {
    let userResult = await user.signUp();
    console.log('User signed up', userResult);
  } catch (error) {
    console.error('Error while signing up user', error);
  }
})();
(async () => {
  const user: Parse.User = new Parse.User();
  user.set('username', 'A string');
  user.set('email', 'A string');
  user.set('password', '#Password123');

  try {
    let userResult: Parse.User = await user.signUp();
    console.log('User signed up', userResult);
  } catch (error: any) {
    console.error('Error while signing up user', error);
  }
})();
import com.parse.ParseException;
import com.parse.ParseUser;
import com.parse.SignUpCallback;

public void createUser() {
  ParseUser user = new ParseUser();
  user.setUsername("my name");
  user.setPassword("my pass");
  user.setEmail("email@example.com");

  // Other fields can be set just like any other ParseObject,
  // using the "put" method, like this: user.put("attribute", "its value");
  // If this field does not exists, it will be automatically created

  user.signUpInBackground(e -> {
    if (e == null) {
        // Hooray! Let them use the app now.
    } else {
        // Sign up didn't succeed. Look at the ParseException
        // to figure out what went wrong
        Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}

func createUser() {
  var user = PFUser()
  user.username = "myUsername"
  user.password = "myPassword"
  user.email = "email@example.com"

  // Other fields can be set just like any other PFObject,
  // like this: user["attribute"] = "its value"
  // If this field does not exists, it will be automatically created

  user.signUpInBackgroundWithBlock {
    (succeeded: Bool, error: NSError?) -> Void in
    if let error = error {
      let errorString = error.userInfo["error"] as? NSString
      // Show the errorString somewhere and let the user try again.
    } else {
      // Hooray! Let them use the app now.
    }
  }
}
PFUser *user = [PFUser user];
user.username = @"my name";
user.password = @"my pass";
user.email = @"email@example.com";

// Other fields can be set just like any other PFObject,
// like this: user[@"attribute"] = @"its value";
// If this field does not exists, it will be automatically created

[user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
  if (!error) {
    // Hooray! Let them use the app now.
  } else {
    // Show the errorString somewhere and let the user try again.
    NSString *errorString = [error userInfo][@"error"];
  }
}];
public async void SignUpButton_Click(object sender, RoutedEventArgs e)
{
    var user = new ParseUser()
    {
        Username = "myname",
        Password = "MyPaSs123#",
        Email = "email@example.com"
    };

    // Other fields can be set just like any other PFObject,
    // like this: user["attribute"] = "its value"
    // If this field does not exists, it will be automatically created

    await user.SignUpAsync();
}
$user = new ParseUser();
$user->set("username", "my name");
$user->set("password", "my pass");
$user->set("email", "email@example.com");

// Other fields can be set just like any other ParseObject,
// like this: $user->set("attribute", "its value");
// If this field does not exists, it will be automatically created
// other fields can be set just like with ParseObject

try {
  $user->signUp();
  // Hooray! Let them use the app now.
} catch (ParseException $ex) {
  // Show the error message somewhere and let the user try again.
  echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
}

Example Output:

ParseUser { _objCount: 0, className: '_User', id: 'luo69YBMXi' }

To signing up a new user, you'll need to send a POST request to /users endpoint with your app's credentials in the headers and the object's data in the body. You can include as many key-value pairs as you want. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/users

Method

POST

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

X-Parse-Revocable-Session: 1

Content-Type: application/json

Body

A JSON document with the key-value pairs that represent your object's data. It must contain a valid username and password.

Success Response

Status

201 Created

Headers

Location: https://parseapi.back4app.com/users/MyNewUserId

The Location header will contain the endpoint of the newly-created user.

Body

A JSON document with the objectId, createdAt and sessionToken fields of the newly-created user.

Error Response

Please check the Errors section.

Logging In

Example Request:

# Don't forget to set the USERNAME and PASSWORD parameters!
curl -X POST \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "X-Parse-Revocable-Session: 1" \
-G \
--data-urlencode 'username=<USERNAME>' \
--data-urlencode 'password=<PASSWORD>' \
https://parseapi.back4app.com/login

Example Response:

{
  "objectId":"AHRLeYvh0d",
  "username":"newUserName",
  "createdAt":"2018-11-08T13:50:56.843Z",
  "updatedAt":"2018-11-08T13:50:56.843Z",
  "sessionToken":"r:8d975a0f207fab1211752da3be0a3c81"
}

The response could contain another custom fields.

Code:

(async () => {
  try {
    // Pass the username and password to logIn function
    let user = await Parse.User.logIn('newUserName','#Password123');
    // Do stuff after successful login
    console.log('Logged in user', user);
  } catch (error) {
    console.error('Error while logging in user', error);
  }
})();
(async () => {
  try {
    // Pass the username and password to logIn function
    let user: Parse.User = await Parse.User.logIn('newUserName','#Password123');
    // Do stuff after successful login
    console.log('Logged in user', user);
  } catch (error: any) {
    console.error('Error while logging in user', error);
  }
})();

Example Output:

ParseUser { _objCount: 0, className: '_User', id: 'M2Uln6C4vk' }
import com.parse.LogInCallback;
import com.parse.ParseException;
import com.parse.ParseUser;

public void loginUser() {
  ParseUser.logInInBackground("<userName>", "<password>", (user, e) -> {
    if (user != null) {
        // Hooray! The user is logged in.
    } else {
        // Login failed. Look at the ParseException to see what happened.
        Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
PFUser.logInWithUsernameInBackground("<userName>", password:"<password>") {
  (user: PFUser?, error: NSError?) -> Void in
  if user != nil {
    // Do stuff after successful login.
  } else {
    // The login failed. Check error to see why.
  }
}
[PFUser logInWithUsernameInBackground:@"myname" password:@"mypass"
  block:^(PFUser *user, NSError *error) {
    if (user) {
      // Do stuff after successful login.
    } else {
      // The login failed. Check error to see why.
    }
  }
];
try
{
    await ParseUser.LogInAsync("myname", "mypass");
    // Login was successful.
}
catch (Exception e)
{
    // The login failed. Check the error to see why.
}
try {
  $user = ParseUser::logIn("myname", "mypass");
  // Do stuff after successful login.
} catch (ParseException $error) {
  // The login failed. Check error to see why.
}

To log in into a user account you'll need to send a POST request to /login endpoint with your app's credentials in the headers and the username and password as URL parameters. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/login

Method

POST

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

X-Parse-Revocable-Session: 1

Parameters

Pass the username and password in URL parameters. It should be encoded JSON.

Success Response

Status

200 OK

Body

A JSON document with the user's fields.

Error Response

Please check the Errors section.

Verifying Email

Example Request:

# Don't forget to set the target e-mail!
curl -X POST \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "Content-Type: application/json" \
-d '{"email":"email@example.com"}' \
https://parseapi.back4app.com/verificationEmailRequest

Example Response:

{}

Example Request:

(async () => {
  const https = require('https');

  const params = '{"email": "email@example.com"}';

  const options = {
    hostname: 'https://parseapi.back4app.com',
    path: '/verificationEmailRequest',
    method: 'POST',
    headers: {
      'X-Parse-Application-Id': 'OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg',
      'X-Parse-REST-API-Key': 'Clone or connect in this app to use your own keys.',
      'Content-Type': 'application/json'
    }
  };

  const req = https.request(options, (res) => {
    console.log(`STATUS: ${res.statusCode}`);
    res.setEncoding('utf8');
    res.on('data', (chunk) => {
      console.log(`BODY: ${chunk}`);
    });
    res.on('end', () => {
      console.log('No more data in response.');
    });
  });

  req.on('error', (e) => {
    console.error(`Problem with request: ${e.message}`);
  });

  // write data to request body
  req.write(params);
  req.end();
})();
(async () => {
  const https = require('https');

  const params: string = '{"email": "email@example.com"}';

  const options: object = {
    hostname: 'https://parseapi.back4app.com',
    path: '/verificationEmailRequest',
    method: 'POST',
    headers: {
      'X-Parse-Application-Id': 'OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg',
      'X-Parse-REST-API-Key': 'Clone or connect in this app to use your own keys.',
      'Content-Type': 'application/json'
    }
  };

  const req: https.request = https.request(options, (res) => {
    console.log(`STATUS: ${res.statusCode}`);
    res.setEncoding('utf8');
    res.on('data', (chunk) => {
      console.log(`BODY: ${chunk}`);
    });
    res.on('end', () => {
      console.log('No more data in response.');
    });
  });

  req.on('error', (e: any) => {
    console.error(`Problem with request: ${e.message}`);
  });

  // write data to request body
  req.write(params);
  req.end();
})();

Example Response:

STATUS: 200
BODY: {}
No more data in response.

Enable email verification in server settings provides the app to reserve part of its experience just to users with confirmed email addresses. Email verification adds the emailVerified key to the Parse.User object. When a Parse.User’s email is set or modified, emailVerified is set to false and an email is automatically sent to user email. After the validation process, the emailVerified is set to true.

You can request a verification email to be sent by sending a POST request to /verificationEmailRequest endpoint with email in the body of the request:

Sign up

Code:

(async () => {
  const user = new Parse.User()
  user.set('username', 'A string');
  user.set('email', 'A string');
  user.set('password', '#Password123')

  try {
    let userResult = await user.signUp();
    Parse.User.logOut();
    console.log("User signed up. Please verify your e-mail")
  } catch (error) {
    console.error('Error while signing up user', error);
  }
})();
(async () => {
  const user: Parse.User = new Parse.User();
  user.set('username', 'A string');
  user.set('email', 'A string');
  user.set('password', '#Password123');

  try {
    let userResult: Parse.User = await user.signUp();
    Parse.User.logOut();
    console.log("User signed up. Please verify your e-mail")
  } catch (error: any) {
    console.error('Error while signing up user', error);
  }
})();

Example Output:

"Please verify your e-mail"
import com.parse.ParseException;
import com.parse.ParseUser;
import com.parse.SignUpCallback;

public void signInWithEmailVerification() {
  ParseUser user = new ParseUser();
  user.setUsername("my name");
  user.setPassword("my pass");
  user.setEmail("email@example.com");

  // Other fields can be set just like any other ParseObject,
  // using the "put" method, like this: user.put("attribute", "its value");
  // If this field does not exists, it will be automatically created

  user.signUpInBackground(e -> {
    if (e == null) {
        // Here you should tell the user to verify the e-mail
        ParseUser.logOut();
    } else {
        // Sign up didn't succeed. Look at the ParseException
        // to figure out what went wrong
        Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}

func createUser() {
  var user = PFUser()
  user.username = "myUsername"
  user.password = "myPassword"
  user.email = "email@example.com"

  // Other fields can be set just like any other PFObject,
  // like this: user["attribute"] = "its value"
  // If this field does not exists, it will be automatically created

  user.signUpInBackgroundWithBlock {
    (succeeded: Bool, error: NSError?) -> Void in
    if let error = error {
      let errorString = error.userInfo["error"] as? NSString
      // Show the errorString somewhere and let the user try again.
    } else {
      // Here you should tell the user to verify the e-mail
      PFUser.logOut();
    }
  }
}
PFUser *user = [PFUser user];
user.username = @"my name";
user.password = @"my pass";
user.email = @"email@example.com";

// Other fields can be set just like any other PFObject,
// like this: user[@"attribute"] = @"its value";
// If this field does not exists, it will be automatically created

[user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
  if (!error) {
    // Here you should tell the user to verify the e-mail
    [PFUser logOut];
  } else {
    // Show the errorString somewhere and let the user try again.
    NSString *errorString = [error userInfo][@"error"];
  }
}];
public async void SignUpButton_Click(object sender, RoutedEventArgs e)
{
    var user = new ParseUser()
    {
        Username = "myname",
        Password = "MyPaSs123#",
        Email = "email@example.com"
    };

    // Other fields can be set just like any other PFObject,
    // like this: user["attribute"] = "its value"
    // If this field does not exists, it will be automatically created

    await user.SignUpAsync();

    // Here you should tell the user to verify the e-mail
    user.LogOut();
}
$user = new ParseUser();
$user->set("username", "my name");
$user->set("password", "my pass");
$user->set("email", "email@example.com");

// Other fields can be set just like any other ParseObject,
// like this: $user->set("attribute", "its value");
// If this field does not exists, it will be automatically created
// other fields can be set just like with ParseObject

try {
  $user->signUp();

  // Here you should tell the user to verify the e-mail
  ParseUser::logOut();
} catch (ParseException $ex) {
  // Show the error message somewhere and let the user try again.
  echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
}

To implement Sign Up with Email Verification, you will use the same method which you used to implement the basic user registration. But this time, instead of making an intent to the next page, you will ask the user to verify his or her email to login

Once the sign up process is completed, the user is automatically added to Parse Dashboard and its emailVerified Boolean attribute is set as true. Email verification is must as only you’ll be allowed to let your users access your app entirely.

Log in

Code:

(async () => {
  try {
    // Pass the username and password to logIn function
    let user = await Parse.User.logIn('newUserName','#Password123');
    if (user.get('emailVerified')) {
      console.log('User logged in', user);
    } else {
      Parse.User.logOut();
      console.log('User logged in. Please verify your email first');
    }
  } catch (error) {
    console.error('Error while logging in user', error);
  }
})();
(async () => {
  try {
    // Pass the username and password to logIn function
    let user: Parse.User = await Parse.User.logIn('newUserName','#Password123');
    if (user.get('emailVerified')) {
      console.log('User logged in', user);
    } else {
      Parse.User.logOut();
      console.log('User logged in. Please verify your email first');
    }
  } catch (error: any) {
    console.error('Error while logging in user', error);
  }
})();

Example Output:

ParseUser { _objCount: 0, className: '_User', id: 'kzunnPFh5i' }

Finally, you may add your own code to provide feedback

import com.parse.LogInCallback;
import com.parse.ParseException;
import com.parse.ParseUser;

public void loginUserWithEmailVerification() {

  ParseUser.logInInBackground("<userName>", "<password>", (user, e) -> {
    if (user != null) {
        Boolean emailVerified = user.getBoolean("emailVerified");
        if (emailVerified == true) {
          // Hooray! The user is logged in.
        } else {
          // User did not confirm the e-mail!!
        }
    } else {
        // Login failed. Look at the ParseException to see what happened.
        Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
PFUser.logInWithUsernameInBackground("<userName>", password:"<password>") {
  (user: PFUser?, error: NSError?) -> Void in
  if user != nil {
    if user["emailVerified"] != nil && user["emailVerified"] {
      // User logged in successfully :)
    } else {
      // User did not confirm the e-mail!!
    }
  } else {
    // The login failed. Check error to see why.
  }
}
[PFUser logInWithUsernameInBackground:@"myname" password:@"mypass"
  block:^(PFUser *user, NSError *error) {
    if (user && !user[@"emailVerified"]) {
      // User did not confirm the e-mail!!
      [PFUser logOut];
    }
  }
];
try
{
    var user await ParseUser.LogInAsync("myname", "mypass");
    if (user["emailVerified"] == true) {
        // User logged in successfully :)
    } else {
        // User did not confirm the e-mail!!
    }
}
catch (Exception e)
{
    // The login failed. Check the error to see why.
}
try {
  $user = ParseUser::logIn("myname", "mypass");

  if (!($user->get("emailVerified") == true)) {
    // User did not confirm the e-mail!!
    ParseUser::logOut();
  }
} catch (ParseException $error) {
  // The login failed. Check error to see why.
}

To implement Log In with Email Verification, you will use the same method which you used to implement the basic user registration. But this time, you will check the emailVerified boolean before granting further access to the user.

Requesting Password Reset

Example Request:

# Don't forget to set the target e-mail!
curl -X POST \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "Content-Type: application/json" \
-d '{"email":"email@example.com"}' \
https://parseapi.back4app.com/requestPasswordReset

Example Response:

{}

Code:

(async () => {
  try {
    // Pass the username and password to logIn function
    let result = await Parse.User.requestPasswordReset("email@example.com");
    // Password reset request was sent successfully
    console.log('Reset password email sent successfully');
  } catch (error) {
    console.error('Error while creating request to reset user password', error);
  }
})();
(async () => {
  try {
    // Pass the username and password to logIn function
    let result: any = await Parse.User.requestPasswordReset("email@example.com");
    // Password reset request was sent successfully
    console.log('Reset password email sent successfully');
  } catch (error: any) {
    console.error('Error while creating request to reset user password', error);
  }
})();

Example Output:

{}
import com.parse.ParseException;
import com.parse.ParseUser;
import com.parse.RequestPasswordResetCallback;

public void passwordReset() {
  // An e-mail will be sent with further instructions
  ParseUser.requestPasswordResetInBackground("myemail@example.com", e -> {
    if (e == null) {
      // An email was successfully sent with reset instructions.
    } else {
      // Something went wrong. Look at the ParseException to see what's up.
    }
  });
}
// An e-mail will be sent with further instructions
PFUser.requestPasswordResetForEmailInBackground("email@example.com")
[PFUser requestPasswordResetForEmailInBackground:@"email@example.com"];
// An e-mail will be sent with further instructions
await ParseUser.RequestPasswordResetAsync("email@example.com");
ParseUser::requestVerificationEmail('email@example.com');

You can initiate password resets for users who have emails associated with their account. To do this, send a POST request to /requestPasswordReset endpoint with email in the body of the request: This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/requestPasswordReset

Method

POST

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

Content-Type: application/json

Body

A JSON document with the user's email.

Success Response

Status

200 OK

Body

An empty JSON document.

Error Response

Please check the Errors section.

Retrieving Current User

Example Request:

# Don't forget to set the session token, received
# when you logged in or signed up
curl -X GET \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "X-Parse-Session-Token: <SESSION_TOKEN>" \
https://parseapi.back4app.com/users/me

Example Response:

{
  "username": "myuser123",
  "myCustomKeyName": "myCustomKeyValue",
  "createdAt": "2018-11-07T20:58:34.448Z",
  "updatedAt": "2018-11-07T20:58:34.448Z",
  "objectId": "g7y9tkhB7O",
  "sessionToken":"r:03a4c2d87a63a020a7d737c6fc64fd4c"
}

Code:

(async () => {
  try {
    let user = await Parse.User.logIn('newUserName','#Password123');
    const currentUser = Parse.User.current();
    console.log('Current logged in user', currentUser);
  } catch (error) {
    console.error('Error while logging in user', error);
  }
})();
(async () => {
  try {
    let user: Parse.User = await Parse.User.logIn('newUserName','#Password123');
    const currentUser: Parse.User = Parse.User.current();
    console.log('Current logged in user', currentUser);
  } catch (error: any) {
    console.error('Error while logging in user', error);
  }
})();

Example Output:

ParseUser { _objCount: 0, className: '_User', id: 'hEPjkt4epS' }

Please note that this functionality is disabled by default on Node.js environments (such as React Native) to discourage stateful usages on server-side configurations.

import com.parse.ParseUser;

public void getCurrentUser() {
  // After login, Parse will cache it on disk, so
  // we don't need to login every time we open this
  // application
  ParseUser currentUser = ParseUser.getCurrentUser();
  if (currentUser != null) {
    // do stuff with the user
  } else {
    // show the signup or login screen
  }
}
var currentUser = PFUser.currentUser()
if currentUser != nil {
  // Do stuff with the user
} else {
  // Show the signup or login screen
}
PFUser *currentUser = [PFUser currentUser];
if (currentUser) {
  // do stuff with the user
} else {
  // show the signup or login screen
}
if (ParseUser.CurrentUser != null)
{
    // do stuff with the user
}
else
{
    // show the signup or login screen
}
$currentUser = ParseUser::getCurrentUser();
if ($currentUser) {
  // Do stuff with the user
} else {
  // Show the signup or login page
}

To retrieve the current user, you'll need to send a GET request to users/me endpoint with your app's credentials and the session token in the headers. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/users/me

Method

GET

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

X-Parse-Session-Token: r:03a4c2d87a63a020a7d737c6fc64fd4c

Success Response

Status

200 OK

Body

A JSON document with all the user-provided fields, except password.

Error Response

Please check the Errors section.

Reading Users

Example Request:

# Don't forget to set the USER_OBJECT_ID parameter
curl -X GET \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
https://parseapi.back4app.com/users/<USER_OBJECT_ID>

Example Response:

{
  "username":\"A string\",
  "email":\"A string\"

  "createdAt": "2018-11-07T20:58:34.448Z",
  "updatedAt": "2018-11-07T20:58:34.448Z",
  "objectId": "g7y9tkhB7O",
}

Code:

(async () => {
  const User = new Parse.User();
  const query = new Parse.Query(User);

  try {
    let user = await query.get('hEPjkt4epS');
    console.log('User found', user);
  } catch (error) {
    console.error('Error while fetching user', error);
  }
})();
(async () => {
  const User: Parse.User = new Parse.User();
  const query: Parse.Query = new Parse.Query(User);

  try {
    let user: Parse.Object = await query.get('hEPjkt4epS');
    console.log('User found', user);
  } catch (error: any) {
    console.error('Error while fetching user', error);
  }
})();

Example Output:

ParseUser { _objCount: 1, className: '_User', id: 'hEPjkt4epS' }
import java.util.List;

import com.parse.FindCallback;
import com.parse.ParseException;
import com.parse.ParseQuery;
import com.parse.ParseUser;

public void findUsers() {
  ParseQuery<ParseUser> query = ParseUser.getQuery();
  query.whereEqualTo("email", "email@example.com");
  query.findInBackground((users, e) -> {
    if (e == null) {
        // The query was successful, returns the users that matches
        // the criteria.
        for(ParseUser user1 : users) {
            Log.d("User List ",(user1.getUsername()));
        }
    } else {
        // Something went wrong.
        Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
var query = PFUser.query()
query.whereKey("email", equalTo:"email@example.com")
var users = query.findObjects()
PFQuery *query = [PFUser query];
[query whereKey:@"email" equalTo:@"email@example.com"];
NSArray *users = [query findObjects];
var user = await ParseUser.Query
    .WhereEqualTo("Email", "email@example.com")
    .FindAsync();
$query = ParseUser::query();
$query->equalTo("email", "email@example.com");

// Finds all users with the given email
$users = $query->find();

To retrieve users is almost the same way as retrieving a generic Parse.Object, you'll need to send a GET request to its users endpoint with your app's credentials in the headers. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/users/myCurrentUserId

Method

GET

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

Success Response

Status

200 OK

Body

A JSON document with all the user-provided fields except password.

Error Response

Please check the Errors section.

Updating Users

Example Request:

# Don't forget to set the SESSION_TOKEN and USER_OBJECT_ID parameters
curl -X PUT \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "X-Parse-Session-Token: <SESSION_TOKEN>" \
-H "Content-Type: application/json" \
-d "{ \"username\": \"A string\",\"email\": \"A string\" }" \
https://parseapi.back4app.com/users/<USER_OBJECT_ID>

Example Response:

{
  "updatedAt": "2011-08-21T18:02:52.248Z"
}

You must provide the X-Parse-Session-Token header to authenticate.

Code:

(async () => {
  const User = new Parse.User();
  const query = new Parse.Query(User);

  try {
    // Finds the user by its ID
    let user = await query.get('hEPjkt4epS');
    // Updates the data we want
    user.set('username', 'A string');
    user.set('email', 'A string');
    try {
      // Saves the user with the updated data
      let response = await user.save();
      console.log('Updated user', response);
    } catch (error) {
      console.error('Error while updating user', error);
    }
  } catch (error) {
    console.error('Error while retrieving user', error);
  }
})();
(async () => {
  const User: Parse.User = new Parse.User();
  const query: Parse.Query = new Parse.Query(User);

  try {
    // Finds the user by its ID
    let user: Parse.Object = await query.get('hEPjkt4epS');
    // Updates the data we want
    user.set('username', 'A string');
    user.set('email', 'A string');
    try {
      // Saves the user with the updated data
      let response: Parse.Object = await user.save();
      console.log('Updated user', response);
    } catch (error: any) {
      console.error('Error while updating user', error);
    }
  } catch (error: any) {
    console.error('Error while retrieving user', error);
  }
})();

Example Output:

ParseObjectSubclass { className: _User, _objCount: 0, id: 'xKue915KBG' }
import com.parse.ParseException;
import com.parse.ParseUser;
import com.parse.SaveCallback;

public void updateUser() {
  ParseUser currentUser = ParseUser.getCurrentUser();
  if (currentUser != null) {
    // Other attributes than "email" will remain unchanged!
    currentUser.put("email", "new_email@example.com");

    // Saves the object.
    currentUser.saveInBackground(e -> {
      if(e==null){
        //Save successfull
        Toast.makeText(this, "Save Successful", Toast.LENGTH_SHORT).show();
      }else{
        // Something went wrong while saving
        Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
      }
    });
  }
}
var currentUser = PFUser.currentUser()
if currentUser != nil {
  currentUser["email"] = "new_email@example.com"

  currentUser.saveInBackground()
}
PFUser *currentUser = [PFUser currentUser];
if (currentUser) {
  currentUser[@"email"] = @"new_email@example.com";

  [currentUser saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
    if (succeeded) {
      // The PFUser has been saved.
    } else {
      // There was a problem, check error.description
    }
  }];
}
var user = await ParseUser.currentUser();
user.Username = "my_new_username"; // attempt to change username
await user.SaveAsync(); // This succeeds, since this user was
                        // authenticated on the device
$currentUser = ParseUser::getCurrentUser();
if ($currentUser) {
  // We can set the fields just like any other ParseObject
  $user->set("email", "new_email@example.com");

  // After we make our changes, we need to save it
  $user->save();
}

To update data on an user that already exists, send a PUT request to this user endpoint with your app's credentials in the headers and the query parameters in the body. Any keys you don’t specify will remain unchanged, so you can update just a subset of the object’s data. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/users/MyUserObjectId

Method

PUT

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

X-Parse-Session-Token: myCurrentSessionToken

Content-Type: application/json

Body

A JSON document with the key-value pairs that represent the user's new data.

Success Response

Status

200 OK

Headers

content-type: application/json;

Body

a JSON object that contains a updatedAt field with the timestamp of the update.

Error Response

Please check the Errors section.

Deleting Users

Example Request:

# Don't forget to set the SESSION_TOKEN and USER_OBJECT_ID parameters
curl -X DELETE \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "X-Parse-Session-Token: <SESSION_TOKEN>" \
https://parseapi.back4app.com/users/<USER_OBJECT_ID>

Example Response:

{}

You must provide the X-Parse-Session-Token header to authenticate.

Code:

(async () => {
  const User = new Parse.User();
  const query = new Parse.Query(User);

  try {
    // Finds the user by its ID
    let user = await query.get('FD2UCUD3t0');
    try {
      // Invokes the "destroy" method to delete the user
      let response = await user.destroy();
      console.log('Deleted user', response);
    } catch (error) {
      console.error('Error while deleting user', error);
    }
  } catch (error) {
    console.error('Error while retrieving user', error);
  }
})();
(async () => {
  const User: Parse.User = new Parse.User();
  const query: Parse.Query = new Parse.Query(User);

  try {
    // Finds the user by its ID
    let user: Parse.Object = await query.get('FD2UCUD3t0');
    try {
      // Invokes the "destroy" method to delete the user
      let response: any = await user.destroy();
      console.log('Deleted user', response);
    } catch (error: any) {
      console.error('Error while deleting user', error);
    }
  } catch (error: any) {
    console.error('Error while retrieving user', error);
  }
})();

Example Output:

ParseObjectSubclass { className: '_User', _objCount: 0, id: 'xKue915KBG' }
import com.parse.DeleteCallback;
import com.parse.ParseException;
import com.parse.ParseUser;

public void deleteUser() {
  // Notice that ParseUser extends ParseObject class, so we can
  // use the "remove" method in order to delete a single attribute.
  ParseUser currentUser = ParseUser.getCurrentUser();

  if (currentUser != null) {
    // Deletes the user.
    // Notice that the DeleteCallback is totally optional!
    currentUser.deleteInBackground(e -> {
      if(e==null){
        //Delete successfull
        Toast.makeText(this, "User was deleted", Toast.LENGTH_SHORT).show();
      }else{
        // Something went wrong while deleting
        Toast.makeText(this,e.getMessage(), Toast.LENGTH_SHORT).show();
      }
    });
  }
}
// Notice that ParseUser extends ParseObject class, so we can use
// the "removeObjectForKey" method in order to delete a single attribute.
var currentUser = PFUser.currentUser()

if currentUser != nil {
  // Deletes the user.
  currentUser.deleteInBackground()
}
PFUser *currentUser = [PFUser currentUser];
if (currentUser) {
  // Deletes the user.
  [currentUser deleteInBackground];
}
var user = await ParseUser.currentUser();
await user.DeleteAsync(); // This succeeds, since this user was
                        // authenticated on the device
$currentUser = ParseUser::getCurrentUser();
if ($currentUser) {
  // Deletes the user.
  $user->destroy();
}

To delete an user send a DELETE request to this user endpoint with your app's credentials in the headers. This task can be easily accomplished just by calling the appropriated method of your preferred Parse SDK. Please check how to do it in the right panel of this documentation.

Request

URL

https://parseapi.back4app.com/users/MyCurrentObjectId

Method

DELETE

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

X-Parse-Session-Token: myCurrentSessionToken

Success Response

Status

200 OK

Headers

content-type: application/json;

Body

An empty JSON object.

Error Response

Please check the Errors section.

Logging Out

Example Request:

# Don't forget to set the SESSION_TOKEN and USER_OBJECT_ID parameters
curl -X POST \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "X-Parse-Session-Token: <SESSION_TOKEN>" \
https://parseapi.back4app.com/logout

Example Response:

{}

You must provide the X-Parse-Session-Token header to authenticate.

Code:

(async () => {
  // Checks if the user is logged in
  const currentUser = Parse.User.current();
  if (currentUser) {
    // Logs out the current user
    await Parse.User.logOut();
    console.log('User logged out');
  } else {
    console.log('No user logged in');
  }
})();
(async () => {
  // Checks if the user is logged in
  const currentUser = Parse.User.current();
  if (currentUser) {
    // Logs out the current user
    await Parse.User.logOut();
    console.log('User logged out');
  } else {
    console.log('No user logged in');
  }
}
})();

Example Output:

User logged out
import com.parse.ParseUser;

private void logoutUser() {
    // Checks if the user is logged in
    ParseUser currentUser = ParseUser.getCurrentUser();
    if (currentUser != null) {
      // Logs out the current user
        ParseUser.logOut();
        Log.d("Logout", "User logged out.");
    } else {
        Log.d("Logout", "No user found.");
    }
}
func logoutUser() {
    // Checks if the user is logged in
    if let currentUser = PFUser.current() {
        // Logs out the current user
        PFUser.logOut()
        print("User logged out.")
    } else {
        print("No user found.")
    }
}
    // Checks if the user is logged in
    PFUser *currentUser = [PFUser currentUser];
    if (currentUser) {
        // Logs out the current user
        [PFUser logOut];
        NSLog(@"User logged out.");
    } else {
        NSLog(@"No user found.");
    }

private async Task LogoutUser()
{
    // Checks if the user is logged in
    ParseUser currentUser = ParseUser.CurrentUser;
    if (currentUser != null)
    {
        // Logs out the current user
        await ParseUser.LogOutAsync();
        Console.WriteLine("User logged out.");
    }
    else
    {
        Console.WriteLine("No user found.");
    }
}
function logoutUser() {
    // Checks if the user is logged in
    $currentUser = ParseUser::getCurrentUser();
    if ($currentUser) {
        // Logs out the current user
        ParseUser::logOut();
        echo 'User logged out.';
    } else {
        echo 'No user found.';
    }
}

Request

URL

https://parseapi.back4app.com/logout

Method

POST

Headers

X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg

X-Parse-REST-API-Key: Clone or connect in this app to use your own keys.

X-Parse-Session-Token: myCurrentSessionToken

Success Response

Status

200 OK

Headers

content-type: application/json;

Body

An empty JSON object.

Error Response

Please check the Errors section.

Queries

A query can be as simple as this, which finds all objects, given a class.

Code:

(async () => {
  // Creates a new Query object to help us fetch MyCustomClass objects
  const query = new Parse.Query('MyCustomClass');
  try {
    // Executes the query, which returns an array of MyCustomClass
    const results = await query.find();
    console.log(`ParseObjects found: ${JSON.stringify(results)}`);
  } catch (error) {
    console.log(`Error: ${JSON.stringify(error)}`);
  }
})();
(async () => {
  // Creates a new Query object to help us fetch MyCustomClass objects
  const query: Parse.Query = new Parse.Query('MyCustomClass');
  try {
    // Executes the query, which returns an array of MyCustomClass
    const results: Parse.Query[] = await query.find();
    console.log(`ParseObjects found: ${JSON.stringify(results)}`);
  } catch (error: any) {
    console.log(`Error: ${JSON.stringify(error)}`);
  }
})();
curl -X GET \
  -H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
  -H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
  https://parseapi.back4app.com/classes/MyCustomClass
import com.parse.FindCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

import java.util.List;

public void runQuery() {

  // Creates a new ParseQuery object to help us fetch MyCustomClass objects
  ParseQuery<ParseObject> query = ParseQuery.getQuery("MyCustomClass");

  // Fetches data synchronously
  try {
    List<ParseObject> results = query.find();
    for (ParseObject result : results) {
        System.out.println("Object found " + result.getObjectId());
    }
  } catch (ParseException e) {
    e.printStackTrace();
  }

  // Or use the the non-blocking method findInBackground method with a FindCallback
 query.findInBackground((results, e) -> {
    // do some stuff with results
    if (e == null) {
      for (ParseObject result : results) {
        Log.d("Object found",result.getObjectId());
      }
    } else {
        Toast.makeText(this, "Error: "+e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
PFQuery *query = [PFQuery queryWithClassName:@"MyCustomClass"];

NSArray* results = [query findObjects];

// or use the the non-blocking method findObjectsInBackgroundWithBlock

[query findObjectsInBackgroundWithBlock:^(NSArray *results, NSError *error) {
  // do some stuff with results
}];
let query = PFQuery(className:"MyCustomClass")

let results = query.findObjects()

// or use the the non-blocking method findObjectsInBackground

query.findObjectsInBackground { (results: [PFObject]?, error: Error?) in
  // do some stuff with results
}

use Parse\ParseQuery;

$query = new ParseQuery("MyCustomClass");
$results = $query->find();
foreach($results as $result) {
  echo 'Object found ' . $result->getObjectId() . '<br>';
}
using Parse;

var query = from myCustomClass in ParseObject.GetQuery("MyCustomClass")
            select myCustomClass;
IEnumerable<ParseObject> results = await query.FindAsync();

// or using LINQ
var query = ParseObject.GetQuery("MyCustomClass");
IEnumerable<ParseObject> results = await query.FindAsync();

Sometimes you will find that the get method from the Parse Object is not enough to retrieve the exact data that you want. In this section, we will explore the Query capabilities, which allows us to fetch an array of objects, apply different constraints to filter our query results, or even get unique results given a specific field.

Counting Objects

Counting objects is as simple as that:

Code:

(async () => {
  const query = new Parse.Query('MyCustomClass');

  try {
    // Uses 'count' instead of 'find' to retrieve the number of objects
    const count = await query.count();
    console.log(`ParseObjects found: ${count}`);
  } catch (error) {
    console.log(`Error: ${error}`);
  }
})();
(async () => {
  const query: Parse.Query = new Parse.Query('MyCustomClass');

  try {
    // Uses 'count' instead of 'find' to retrieve the number of objects
    const count: number = await query.count();
    console.log(`ParseObjects found: ${count}`);
  } catch (error: any) {
    console.log(`Error: ${error}`);
  }
})();
curl -X GET \
  -H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
  -H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
  -G --data-urlencode "count=1" \
  https://parseapi.back4app.com/classes/MyCustomClass
import com.parse.CountCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

public void runQuery() {
  ParseQuery<ParseObject> query = ParseQuery.getQuery("MyCustomClass");
  //We can query in two ways

  //Fetches count synchronously,this will block the main thread
  try {
     int count  =  query.count();
     Toast.makeText(this, "Count : "+count, Toast.LENGTH_SHORT).show();
  } catch (ParseException e) {
    e.printStackTrace();
  }

  // Or call it asynchronously 
  query.countInBackground((count, e) -> {
      if (e == null) {
          Toast.makeText(this, "Count : "+count, Toast.LENGTH_SHORT).show();
      } else {
          Toast.makeText(this, "Error: "+e.getMessage(), Toast.LENGTH_SHORT).show();
      }
  });
}
PFQuery *query = [PFQuery queryWithClassName:@"MyCustomClass"];

[query countObjectsInBackgroundWithBlock:^(int count, NSError *error) {
  if (!error) {
    NSLog(@"%d objects found!", count);
  } else {
    // The request failed
  }
}];
let query = PFQuery(className:"MyCustomClass")
query.countObjectsInBackground { (count: Int32, error: Error?) in
    if let error = error {
        // The request failed
        print(error.localizedDescription)
    } else {
        print("\(count) objects found!")
    }
}
use Parse\ParseQuery;

$query = new ParseQuery("MyCustomClass");
$count = $query->count();
// The count request succeeded. Show the count
echo $count . " objects found!";
using Parse;

var query = from myCustomClass in ParseObject.GetQuery("MyCustomClass")
            select myCustomClass;
int count = await query.CountAsync();

// or using LINQ
var query = ParseObject.GetQuery("MyCustomClass");
int count = await query.CountAsync();

If you do not need to retrieve any data from the objects, but count them, we have it covered.

Distinct Results

Code:

(async () => {
  const query = new Parse.Query('User');

  // Returns unique emails
  try {
    const results = await query.distinct('email');
    console.log(`Unique emails: ${JSON.stringify(results)}`);
  } catch (error) {
    console.log(`Error: ${JSON.stringify(error)}`);
  }
})();
(async () => {
  const query: Parse.Query = new Parse.Query('User');

  // Returns unique emails
  try {
    const results: Parse.Object[] = await query.distinct('email');
    console.log(`Unique emails: ${JSON.stringify(results)}`);
  } catch (error: any) {
    console.log(`Error: ${JSON.stringify(error)}`);
  }
})();

Example Request:

curl -X GET \
  -H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
  -H "X-Parse-Master-Key: For test purpose only you can use Kq7Dv4kU7SVzqequMt7EznsvzSbORNb7g7Pd1SFn. Clone or connect in this app to use your own keys." \
  -H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
  -G --data-urlencode 'distinct=likes' \
  https://parseapi.back4app.com/aggregate/Post
use Parse\ParseQuery;

$query = new ParseQuery('User');
// Returns unique emails
$results = $query->distinct('email');
foreach($results as $email) {
  echo 'Email ' . $email . '<br>';
}

Distinct feature is not yet available for this SDK, but you still can make use of the REST API directly.

The query results should contain only unique emails

It is also possible to fetch unique results for a specific field, like so:

Constraints

Code:

(async () => {
  // 'Post' is just an arbitrary class, replace it with your custom class
  const query = new Parse.Query('Post');

  // Finds objects whose title is equal to 'Documentation'
  query.equalTo('title', 'Documentation');

  // Finds objects whose title is not equal to 'No hard feelings'
  query.notEqualTo('title', 'No hard feelings');

  // Finds objects with less than 50 likes
  query.lessThan('likes', 50);

  // Finds objects with less than or equal to 50 likes
  query.lessThanOrEqualTo('likes', 50);

  // Finds objects with more than 50 likes
  query.greaterThan('likes', 50);

  // Finds objects with more than or equal to 50 likes
  query.greaterThanOrEqualTo('likes', 50);

  // Finds objects whose 'category' field is either 'it', 'politics' or 'sports'
  query.containedIn('category', ['it', 'politics', 'sports']);

  // Finds objects whose 'category' field is neither 'music', 'health' or 'trending'
  query.notContainedIn('category', ['music', 'health', 'trending']);

  // Finds objects that have the 'relatedPost' field set
  query.exists('relatedPost');

  // Finds objects that don't have the 'relatedPost' field set
  query.doesNotExist('relatedPost');

  // Find objects where 'tags' field is an array and contains 'books'.
  query.equalTo('tags', 'books');

  // Find objects where 'tags' field is an array and contains all of the elements
  // 'fun', 'recommended', and 'cheap'.
  query.containsAll('tags', ['fun', 'recommended', 'cheap']);

  // Title starts with 'Life'
  query.startsWith('title', 'Life');

  // Title contains 'cat'
  query.fullText('title', 'cat');

  try {
    const results = await query.find();
    console.log(`ParseObjects found: ${JSON.stringify(results)}`);
  } catch (error) {
    console.log(`ParseObjects found: ${JSON.stringify(results)}`);
  }
})();
(async () => {
  // 'Post' is just an arbitrary class, replace it with your custom class
  const query: Parse.Query = new Parse.Query('Post');

  // Finds objects whose title is equal to 'Documentation'
  query.equalTo('title', 'Documentation');

  // Finds objects whose title is not equal to 'No hard feelings'
  query.notEqualTo('title', 'No hard feelings');

  // Finds objects with less than 50 likes
  query.lessThan('likes', 50);

  // Finds objects with less than or equal to 50 likes
  query.lessThanOrEqualTo('likes', 50);

  // Finds objects with more than 50 likes
  query.greaterThan('likes', 50);

  // Finds objects with more than or equal to 50 likes
  query.greaterThanOrEqualTo('likes', 50);

  // Finds objects whose 'category' field is either 'it', 'politics' or 'sports'
  query.containedIn('category', ['it', 'politics', 'sports']);

  // Finds objects whose 'category' field is neither 'music', 'health' or 'trending'
  query.notContainedIn('category', ['music', 'health', 'trending']);

  // Finds objects that have the 'relatedPost' field set
  query.exists('relatedPost');

  // Finds objects that don't have the 'relatedPost' field set
  query.doesNotExist('relatedPost');

  // Find objects where 'tags' field is an array and contains 'books'.
  query.equalTo('tags', 'books');

  // Find objects where 'tags' field is an array and contains all of the elements
  // 'fun', 'recommended', and 'cheap'.
  query.containsAll('tags', ['fun', 'recommended', 'cheap']);

  // Title starts with 'Life'
  query.startsWith('title', 'Life');

  // Title contains 'cat'
  query.fullText('title', 'cat');

  try {
    const results: Parse.Query[] = await query.find();
    console.log(`ParseObjects found: ${JSON.stringify(results)}`);
  } catch (error: any) {
    console.log(`ParseObjects found: ${JSON.stringify(results)}`);
  }
})();
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public void runQuery() {
  ParseQuery<ParseObject> query = ParseQuery.getQuery("Post");

  // Finds objects whose title is equal to "Documentation"
  query.whereEqualTo("title", "Documentation");

  // Finds objects whose title is not equal to "No hard feelings"
  query.whereNotEqualTo("title", "No hard feelings");

  // Finds objects with less than 50 likes
  query.whereLessThan("likes", 50);

  // Finds objects with less than or equal to 50 likes
  query.whereLessThanOrEqualTo("likes", 50);

  // Finds objects with more than 50 likes
  query.whereGreaterThan("likes", 50);

  // Finds objects with more than or equal to 50 likes
  query.whereGreaterThanOrEqualTo("likes", 50);

  // Finds objects whose "category" field is either "it", "politics" or "sports"
  query.whereContainedIn("category", Arrays.asList("it", "politics", "sports"));

  // Finds objects whose "category" field is neither "music", "health" or "trending"
  query.whereNotContainedIn("category", Arrays.asList("music", "health", "trending"));

  // Finds objects that have the "relatedPost" field set
  query.whereExists("relatedPost");

  // Finds objects that don't have the "relatedPost" field set
  query.whereDoesNotExist("relatedPost");

  // Find objects where "tags" field is an array and contains "books".
  query.whereEqualTo("tags", "books");

  // Find objects where "tags" field is an array and contains all of the elements
  // "fun", "recommended", and "cheap".
  List<String> myTags = new ArrayList<String>();
  myTags.add("fun");
  myTags.add("recommended");
  myTags.add("cheap");
  query.whereContainsAll("tags", myTags);

  // Title starts with "Life"
  query.whereStartsWith("title", "Life");

  // Title contains "cat"
  query.whereFullText("title", "cat");

  query.findInBackground((objects, e) -> {
    if(e == null){
        for (ParseObject result : objects) {
            Log.d("Object found ",result.getObjectId());
        }
    }else{
        Toast.makeText(this, "Error: "+e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
// "Post" is just an arbitrary class, replace it with your custom class
PFQuery *query = [PFQuery queryWithClassName:@"Post"];

// Finds objects whose title is equal to "Documentation"
[query whereKey:@"title" equalTo:@"Documentation"];

// Finds objects whose title is not equal to "No hard feelings"
[query whereKey:@"title" equalTo:@"No hard feelings"];

// Finds objects with less than 50 likes
[query whereKey:@"likes" lessThan:@50];

// Finds objects with less than or equal to 50 likes
[query whereKey:@"likes" lessThanOrEqualTo:@50];

// Finds objects with more than 50 likes
[query whereKey:@"likes" greaterThan:@50];

// Finds objects with more than or equal to 50 likes
[query whereKey:@"likes" greaterThanOrEqualTo:@50];

// Finds objects whose "category" field is either "it", "politics" or "sports"
[query whereKey:@"category" containedIn:@[@"it", @"politics", @"sports"]];

// Finds objects whose "category" field is neither "music", "health" or "trending"
[query whereKey:@"category" containedIn:@[@"music", @"health", @"trending"]];

// Finds objects that have the "relatedPost" field set
[query whereKeyExists:@"relatedPost"];

// Finds objects that don't have the "relatedPost" field set
[query doesNotExist:@"relatedPost"];

// Find objects where "tags" field is an array and contains "books".
[query whereKey:@"tags" equalTo:@"books"];

// Find objects where "tags" field is an array and contains all of the elements
// "fun", "recommended", and "cheap".
[query whereKey:@"tags" containsAllObjectsInArray:@[@"fun", @"recommended", @"cheap"]];

// Title starts with "Life"
[query whereKey:@"title" hasPrefix:@"Life"];

// Title contains "cat"
[query whereKey:@"title" matchesText:@"cat"];

NSArray* results = [query findObjects];
// "Post" is just an arbitrary class, replace it with your custom class
let query = PFQuery(className:"Post")

// Finds objects whose title is equal to "Documentation"
query.whereKey("title", equalTo: "Documentation");

// Finds objects whose title is not equal to "No hard feelings"
query.whereKey("title", notEqualTo: "No hard feelings");

// Finds objects with less than 50 likes
query.whereKey("likes", lessThan: 50);

// Finds objects with less than or equal to 50 likes
query.whereKey("likes", lessThanOrEqualTo: 50);

// Finds objects with more than 50 likes
query.whereKey("likes", greaterThan: 50);

// Finds objects with more than or equal to 50 likes
query.whereKey("likes", greaterThanOrEqualTo: 50);

// Finds objects whose "category" field is either "it", "politics" or "sports"
query.whereKey("category", containedIn: ["it", "politics", "sports"]);

// Finds objects whose "category" field is neither "music", "health" or "trending"
query.whereKey("category", notContainedIn: ["music", "health", "trending"]);

// Finds objects that have the "relatedPost" field set
query.whereKeyExists("relatedPost");

// Finds objects that don't have the "relatedPost" field set
query.whereKeyDoesNotExist("relatedPost");

// Find objects where "tags" field is an array and contains "books".
query.whereKey("tags", equalTo: "books");

// Find objects where "tags" field is an array and contains all of the elements
// "fun", "recommended", and "cheap".
query.whereKey("tags", containsAllObjectsIn: ["fun", "recommended", "cheap"]);

// Title starts with "Life"
query.whereKey("title", hasPrefix: "Life");

// Title contains "cat"
query.whereKey('title', matchesText: 'cat');

let results = query.findObjects()
use Parse\ParseQuery;

$query = new ParseQuery('Post');

// Finds objects whose title is equal to "Documentation"
$query->equalTo("title", "Documentation");

// Finds objects whose title is not equal to "No hard feelings"
$query->notEqualTo("title", "No hard feelings");

// Finds objects with less than 50 likes
$query->lessThan("likes", 50);

// Finds objects with less than or equal to 50 likes
$query->lessThanOrEqualTo("likes", 50);

// Finds objects with more than 50 likes
$query->greaterThan("likes", 50);

// Finds objects with more than or equal to 50 likes
$query->greaterThanOrEqualTo("likes", 50);

// Finds objects whose "category" field is either "it", "politics" or "sports"
$query->containedIn("category", ["it", "politics", "sports"]);

// Finds objects whose "category" field is neither "music", "health" or "trending"
$query->notContainedIn("category", ["music", "health", "trending"]);

// Finds objects that have the "relatedPost" field set
$query->exists("relatedPost");

// Finds objects that don't have the "relatedPost" field set
$query->doesNotExist("relatedPost");

// Find objects where "tags" field is an array and contains "books".
$query->equalTo("tags", "books");

// Find objects where "tags" field is an array and contains all of the elements
// "fun", "recommended", and "cheap".
$query->containsAll("tags", ["fun", "recommended", "cheap"]);

// Title starts with "Life"
$query->startsWith("name", "Life");

// Title contains "cat"
$query->fullText('title', 'cat');

$results = $query->find();
foreach($results as $result) {
  echo 'Object found ' . $result->getObjectId() . '<br>';
}
using Parse;

// "Post" is just an arbitrary class, replace it with your custom class
var query = from post in ParseObject.GetQuery("Post")
            // Finds objects whose title is equal to "Documentation"
            where post.Get<string>("title") == "Documentation"

            // Finds objects whose title is not equal to "No hard feelings"
            where post.Get<string>("title") != "No hard feelings"

            // Finds objects with less than 50 likes
            where post.Get<int>("likes") < 50

            // Finds objects with less than or equal to 50 likes
            where post.Get<int>("likes") <= 50

            // Finds objects with more than 50 likes
            where post.Get<int>("likes") > 50

            // Finds objects with more than or equal to 50 likes
            where post.Get<int>("likes") >= 50

            // Finds objects whose "category" field is either "it", "politics" or "sports"
            where (new[] {"it", "politics", "sports"}).Contains(post.Get<string>("category"))

            // Finds objects whose "category" field is neither "music", "health" or "trending"
            where (new[] {"music", "health", "trending"}).Contains(post.Get<string>("category"))

            // Finds objects that have the "relatedPost" field set
            where post.ContainsKey("relatedPost")

            // Finds objects that don't have the "relatedPost" field set
            where !post.ContainsKey("relatedPost")

            // Find objects where "tags" field is an array and contains "books".
            where post.Get<IList<string>>("tags").Contains("books")

            // Title starts with "Life"
            where post.Get<string>("title").StartsWith("Life")

            select post;

// or using LINQ
// "Post" is just an arbitrary class, replace it with your custom class
var query = ParseObject.GetQuery("Post")
    // Finds objects whose title is equal to "Documentation"
    .WhereEqualTo("title", "Documentation")

    // Finds objects whose title is not equal to "No hard feelings"
    .WhereNotEqualTo("title", "No hard feelings")

    // Finds objects with less than 50 likes
    .WhereLessThan("likes", 50)

    // Finds objects with less than or equal to 50 likes
    .WhereLessThanOrEqualTo("likes", 50)

    // Finds objects with more than 50 likes
    .WhereGreaterThan("likes", 50)

    // Finds objects with more than or equal to 50 likes
    .WhereGreaterThanOrEqualTo("likes", 50)

    // Finds objects whose "category" field is either "it", "politics" or "sports"
    .WhereContainedIn("category", (new[] {"it", "politics", "sports"}))

    // Finds objects whose "category" field is neither "music", "health" or "trending"
    .WhereNotContainedIn("category", (new[] {"music", "health", "trending"}))

    // Finds objects that have the "relatedPost" field set
    .WhereExists("relatedPost")

    // Finds objects that don't have the "relatedPost" field set
    .WhereDoesNotExist("relatedPost")

    // Find objects where "tags" field is an array and contains "books".
    .WhereEqualTo("tags", "books")

    // Title starts with "Life"
    .WhereStartsWith("title", "Life");

Example Request:

# Finds the Posts with title equal to "My post title" and
# with likes greater than 100
curl -X GET \
  -H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
  -H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
  -G \
  --data-urlencode 'where={"title": "My post title", "likes": { "$gt": 100 }}' \
  https://parseapi.back4app.com/classes/Post

There are other operators than the $gt used above. Check the list below:

# Key - Operation

# $lt - Less Than
# $lte - Less Than Or Equal To
# $gt - Greater Than
# $gte - Greater Than Or Equal To
# $ne - Not Equal To
# $in - Contained In
# $nin - Not Contained in
# $exists - A value is set for the key
# $select - This matches a value for a key in the result of a different query
# $dontSelect - Requires that a key’s value not match a value for a key in the result of a different query
# $all - Contains all of the given values
# $regex - Requires that a key’s value match a regular expression
# $text - Performs a full text search on indexed fields

# Example request using multiple operators
# Finds all Posts with likes between 50 and 400
# and with title starting with "Parse"
curl -X GET \
  -H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
  -H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
  -G \
  --data-urlencode 'where={"likes":{"$gte":50,"$lte":400}, "title":{"$regex": "^Parse"}}' \
  https://parseapi.back4app.com/classes/Post

You can apply multiple constraints on a query, which will filter all the objects that do not match the conditions. It will be like an AND operator of constraints.

Ordering

Code:

(async () => {
  // 'Post' is just an arbitrary class, replace it with your custom class
  const query = new Parse.Query('Post');

  // Sorts the results in ascending order by the likes field
  query.ascending('likes');

  // Sorts the results in descending order by the views field
  query.descending('views');

  try {
    const results = await query.find();
    console.log(`Posts found: ${JSON.stringify(results)}`);
  } catch (error) {
    console.log(`Error: ${JSON.stringify(error)}`);
  }
})();
(async () => {
  // 'Post' is just an arbitrary class, replace it with your custom class
  const query: Parse.Query = new Parse.Query('Post');

  // Sorts the results in ascending order by the likes field
  query.ascending('likes');

  // Sorts the results in descending order by the views field
  query.descending('views');

  try {
    const results: Parse.Query[] = await query.find();
    console.log(`Posts found: ${JSON.stringify(results)}`);
  } catch (error: any) {
    console.log(`Error: ${JSON.stringify(error)}`);
  }
})();

Example Request:

curl -X GET \
  -H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
  -H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
  -G \
  --data-urlencode 'order=likes' \
  https://parseapi.back4app.com/classes/Post
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

import java.util.List;

public void runQuery() {
  ParseQuery<ParseObject> query = ParseQuery.getQuery("Post");

  // Sorts the results in ascending order by the 'likes' field
  query.orderByAscending("likes");

  // Sorts the results in descending order by the 'views' field
  query.orderByDescending("views");

  query.findInBackground((objects, e) -> {
    if(e == null){
      for (ParseObject result : objects) {
          String res = "Likes " + result.get("likes").toString() + " Views " + result.get("views");
          Log.d("Fetch Results",res);
      }
    }else{
        Toast.makeText(this, "Error: "+e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
PFQuery *query = [PFQuery queryWithClassName:@"Post"];

// Sorts the results in ascending order by the 'likes' field
[query orderByAscending:@"likes"];

// Sorts the results in descending order by the 'views' field
[query orderByDescending:@"views"];

NSArray* results = [query findObjects];
let query = PFQuery(className:"Post")

// Sorts the results in ascending order by the 'likes' field
query.order(byAscending: "likes")

// Sorts the results in descending order by the 'views' field
query.order(byDescending: "views")

let results = quer.findObjects();
use Parse\ParseQuery;

// "Post" is just an arbitrary class, replace it with your custom class
$query = new ParseQuery("Post");

// Sorts the results in ascending order by the likes field
$query->ascending("likes");

// Sorts the results in descending order by the views field
$query->descending("views");

$results = $query->find();
foreach($results as $result) {
  echo 'Object found ' . $result->getObjectId() . '<br>';
}
using Parse;

// Sorts the results in ascending order by likes and descending order by title
var query = from post in ParseObject.GetQuery("Post")
            orderby post.Get<int>("likes"), post.Get<string>("title") descending
            select post;

// or using LINQ
// Sorts the results in ascending order by likes and descending order by title
var query = ParseObject.GetQuery("Post")
    .OrderBy("likes")
    .ThenByDescending("title");

It is also possible to sort the query results by a specific field:

Limit and Skip

Code:

(async () => {
  // 'Post' is just an arbitrary class, replace it with your custom class
  const query = new Parse.Query('Post');

  query.limit(10); // limit to at most 10 results

  query.skip(10); // skip the first 10 results

  try {
    const results = await query.find();
    console.log(`Posts found: ${JSON.stringify(results)}`);
  } catch (error) {
    console.log(`Error: ${JSON.stringify(error)}`);
  }
})();
(async () => {
  // 'Post' is just an arbitrary class, replace it with your custom class
  const query: Parse.Query = new Parse.Query('Post');

  query.limit(10); // limit to at most 10 results

  query.skip(10); // skip the first 10 results

  try {
    const results: Parse.Query[] = await query.find();
    console.log(`Posts found: ${JSON.stringify(results)}`);
  } catch (error: any) {
    console.log(`Error: ${JSON.stringify(error)}`);
  }
})();
# Finds 10 Posts, skipping the first 100 results
curl -X GET \
  -H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
  -H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
  -G \
  --data-urlencode 'limit=10' \
  --data-urlencode 'skip=100' \
  https://parseapi.back4app.com/classes/Post
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

import java.util.List;

public void runQuery() {
  ParseQuery<ParseObject> query = ParseQuery.getQuery("Post");

  query.setLimit(10); // limit to at most 10 results
  query.setSkip(10); // skip the first 10 results

  query.findInBackground((objects, e) -> {
    if(e == null){
      for (ParseObject result : objects) {
        Log.d("Object found ",result.getObjectId());
      }
    }else{
        Toast.makeText(this, "Error: "+e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
PFQuery *query = [PFQuery queryWithClassName:@"Post"];

query.limit = 10; // limit to at most 10 results

query.skip = 10; // skip the first 10 results

NSArray* results = [query findObjects];
let query = PFQuery(className:"Post")

query.limit = 10; // limit to at most 10 results

query.skip = 10; // skip the first 10 results

let results = query.findObjects();
use Parse\ParseQuery;

// "Post" is just an arbitrary class, replace it with your custom class
$query = new ParseQuery("Post");

$query->limit(10); // limit to at most 10 results

$query->skip(10); // skip the first 10 results

$results = $query->find();
foreach($results as $result) {
  echo 'Object found ' . $result->getObjectId() . '<br>';
}
using Parse;

var query = from post in ParseObject.GetQuery("Post")
            // limit to at most 10 results
            .Limit(10)

            // skip the first 10 results
            .Skip(10)

            select post;

// or using LINQ
var query = ParseObject.GetQuery("Post")
    .Limit(10) // limit to at most 10 results
    .Skip(10); // skip the first 10 results

If you need to limit the number of results or skip the first N results (useful when implementing pagination), you can do like so:

Relational Queries

Using object reference as a constraint:

(async () => {
  // Creates the Post
  const myPostObject = new Parse.Object('Post');

  myPostObject.set('content', 'First post! Yay!');
  try {
    const myPost = await myPostObject.save();
    // Creates the Comment
    const myCommentObject = new Parse.Object('Comment');

    myCommentObject.set('content', 'Congrats!');
    myCommentObject.set('post', myPost); // Sets 'myPost' and its post
    try {
      const myComment = await myCommentObject.save();
      // Finds only the comments that has 'myPost' as a post
      const query = new Parse.Query(Comment);
      query.equalTo('post', myPost);

      query.find().then((comments) => {
        console.log(`Comments found: ${JSON.stringify(comments)}`);
      });
    } catch (error) {
      console.log(`Error saving object: ${error}`);
    }
  } catch (error) {
    console.log(`Error saving object: ${error}`);
  }
})();
(async () => {
  // Creates the Post
  const myPostObject: Parse.Object = new Parse.Object('Post');

  myPostObject.set('content', 'First post! Yay!');
  try {
    const myPost: Parse.Object = await myPostObject.save();
    // Creates the Comment
    const myCommentObject: Parse.Object = new Parse.Object('Comment');

    myCommentObject.set('content', 'Congrats!');
    myCommentObject.set('post', myPost); // Sets 'myPost' and its post
    try {
      const myComment: Parse.Object = await myCommentObject.save();
      // Finds only the comments that has 'myPost' as a post
      const query: Parse.Object = new Parse.Query(Comment);
      query.equalTo('post', myPost);

      try {
        const comments: Parse.Object[] = await query.find();
        console.log(`Comments found: ${JSON.stringify(comments)}`);
      } catch (error: any) {
        console.log(`Error fetching objects: ${error}`);  
      }
    } catch (error: any) {
      console.log(`Error saving object: ${error}`);
    }
  } catch (error: any) {
    console.log(`Error saving object: ${error}`);
  }
})();
# Creates the Post
curl -X POST \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "Content-Type: application/json" \
-d '{"content":"First post ! Yay!"}' \
https://parseapi.back4app.com/classes/Post

# Creates the Comment
curl -X POST \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "Content-Type: application/json" \
-d '{"content":"Congrats!", "post":{"__type":"Pointer","className":"Post","objectId":"<OBJECT_ID>"}}' \
https://parseapi.back4app.com/classes/Comment

# Finds only the comments related to the newly created post
curl -X GET \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-G \
--data-urlencode 'where={"post":{"__type":"Pointer","className":"Post","objectId":"<OBJECT_ID>"}}' \
https://parseapi.back4app.com/classes/Comment
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

import java.util.List;

public void runQuery() throws ParseException {
  // Creates the Post
  ParseObject myPost = new ParseObject("Post");
  myPost.put("content", "First post! Yay!");
  myPost.save();

  // Creates the Comment
  ParseObject myComment = new ParseObject("Comment");
  myComment.put("content", "Congrats!");
  myComment.put("post", myPost); // Sets "myPost" and its post
  myComment.save();

  ParseQuery<ParseObject> query = ParseQuery.getQuery("Comment");

  // Finds only the comments that has "myPost" as a post
  query.whereEqualTo("post", myPost);

  query.findInBackground((objects, e) -> {
    if(e == null){
      for (ParseObject result : objects) {
        Log.d("Object found ",result.getObjectId());
      }
    }else{
        Toast.makeText(this, "Error: "+e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
// Creates the Post
PFObject *myPost = [PFObject objectWithClassName:@"Post"];
myPost[@"content"] = @"First post! Yay!";
[myPost save];

// Creates the Comment
PFObject *myComment = [PFObject objectWithClassName:@"Comment"];
myComment[@"content"] = @"Congrats!";
myComment[@"post"] = myPost;
[myComment save];

PFQuery *query = [PFQuery queryWithClassName:@"Comment"];
// Finds only the comments that has "myPost" as a post
[query whereKey:@"post" equalTo:myPost];

[query findObjectsInBackgroundWithBlock:^(NSArray *comments, NSError *error) {
    // comments now contains the comments for myPost
}];
// Creates the Post
var myPost = PFObject(className:"Post")
myPost["content"] = "First post! Yay!"
myPost.save();

var myComment = PFObject(className:"Comment")
myComment["content"] = "Congrats!"
myComment["post"] = myPost
myComment.save()

let query = PFQuery(className:"Post")
query.whereKey("post", equalTo: myPost)

let results = query.findObjects();
use Parse\ParseObject;
use Parse\ParseQuery;

// Creates the Post
$myPost = new ParseObject("Post");
$myPost->set('content', 'First post! Yay!');
$myPost.save();

// Creates the Comment
$myComment = new ParseObject("Comment");
$myComment->set('content', 'Congrats!');
$myComment->set('post', myPost); // Sets "myPost" and its post
$myComment.save();

// Finds only the comments that has "myPost" as a post
$query = new ParseQuery("Comment");
$query->equalTo("post", myPost);
$comments = $query->find();
foreach($comments as $result) {
  echo 'Object found ' . $result->getObjectId() . '<br>';
}
using Parse;

// Creates the Post
ParseObject myPost = new ParseObject("Post");
myPost["content"] = "First post! Yay!";
await myPost.SaveAsync();

// Creates the Comment
ParseObject myComment = new ParseObject("Comment");
myComment["content"] = "Congrats!";
await myComment.SaveAsync();

// Finds only the comments that has "myPost" as a post
var query = from comment in ParseObject.GetQuery("Comment")
            where comment["post"] == myPost
            select comment;

// or using LINQ
var query = ParseObject.GetQuery("Comment")
    .WhereEqualTo("post", myPost);

var comments = await query.FindAsync();
//comments now contains the comments for myPost

Alternatively, you can create relational queries using the objectId:

(async () => {
  // ... creates the query out of a class that have a relation with Post
  const query = new Parse.Query('Blog');

  const myPost = new Parse.Object('Post');
  myPost.id = '<OBJECT_ID>';

  // Just the objectId is enough to compare the object
  query.equalTo('post', myPost);

  try {
    const results = await query.find();
    console.log(`Comments found: ${JSON.stringify(results)}`);
  } catch (error) {
    console.log(`Error: ${error}`);
  }
})();
(async () => {
  // ... creates the query out of a class that have a relation with Post
  const query: Parse.Query = new Parse.Query('Blog');

  const myPost: Parse.Object = new Parse.Object('Post');
  myPost.id = '<OBJECT_ID>';

  // Just the objectId is enough to compare the object
  query.equalTo('post', myPost);

  try {
    const results: Parse.Object[] = await query.find();
    console.log(`Comments found: ${JSON.stringify(results)}`);
  } catch (error: any) {
    console.log(`Error: ${error}`);
  }
})();
// ... creates the query out of a class that have a relation with Post

// Just the objectId is enough to compare the object
[query whereKey:@"post" equalTo:[PFObject objectWithoutDataWithClassName:@"Post" objectId:@"<OBJECT_ID>"]];

// ... runs the query
// ... creates the query out of a class that have a relation with Post

// Just the objectId is enough to compare the object
query.whereKey("post", equalTo: PFObject(withoutDataWithClassName: "Post", objectId: "<OBJECT_ID>"))
// ... runs the query
use Parse\ParseObject;

// ... creates the query out of a class that have a relation with Post
$post = new ParseObject("Post", "<OBJECT_ID>");
$query->equalTo("post", $post);
// ... runs the query
using Parse;

var query = from comment in ParseObject.GetQuery("Comment")
            where comment["post"] == ParseObject.CreateWithoutData("Post", "<OBJECT_ID>")
            select comment;

// or using LINQ
var query = ParseObject.GetQuery("Comment")
    .WhereEqualTo("post", ParseObject.CreateWithoutData("Post", "<OBJECT_ID>"));

Creating relational constraints:

(async () => {
  const innerQuery = new Parse.Query('Post');

  innerQuery.exists('content');

const query = new Parse.Query('Comment');
  query.matchesQuery('post', innerQuery); // Uses the innerQuery to apply constraints to the 'post' field

  try {
    // Fetches only the comments whose posts contains content
    const comments = await query.find();
    console.log(`Comments found: ${JSON.stringify(comments)}`);
  } catch (error) {
    console.log(`Error: ${error}`);
  }
})();
(async () => {
  const innerQuery: Parse.Query = new Parse.Query('Post');

  innerQuery.exists('content');

  const query: Parse.Query = new Parse.Query('Comment');
    query.matchesQuery('post', innerQuery); // Uses the innerQuery to apply constraints to the 'post' field

    try {
      // Fetches only the comments whose posts contains content
      const comments: Parse.Object[] = await query.find();
      console.log(`Comments found: ${JSON.stringify(comments)}`);
    } catch (error: any) {
      console.log(`Error: ${error}`);
    }
  }
)();
# Fetches only the comments whose posts contains image
curl -X GET \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-G \
--data-urlencode 'where={"post":{"$inQuery":{"where":{"image":{"$exists":true}},"className":"Post"}}}' \
https://parseapi.back4app.com/classes/Comment

import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

import java.util.List;

public void runQuery() {
  ParseQuery<ParseObject> innerQuery = ParseQuery.getQuery("Post");
  innerQuery.whereExists("image");

  ParseQuery<ParseObject> query = ParseQuery.getQuery("Comment");
  query.whereMatchesQuery("post", innerQuery);

  query.findInBackground((commentList, e) -> {
    if(e == null){
      for (ParseObject comment : commentList) {
        ParseObject post = comment.getParseObject("post");
        Log.d("Object found ",post.getObjectId());
      }
    }else{
        Toast.makeText(this, "Error: "+e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
PFQuery *innerQuery = [PFQuery queryWithClassName:@"Post"];
[innerQuery whereKeyExists:@"image"];
PFQuery *query = [PFQuery queryWithClassName:@"Comment"];
[query whereKey:@"post" matchesQuery:innerQuery];
[query findObjectsInBackgroundWithBlock:^(NSArray *comments, NSError *error) {
    // comments now contains the comments for posts with images
}];
let innerQuery = PFQuery(className: "Post")
innerQuery.whereKeyExists("image")
let query = PFQuery(className: "Comment")
query.whereKey("post", matchesQuery: innerQuery)
query.findObjectsInBackground { (comments: [PFObject]?, error: Error?) in
    if let error = error {
        // The request failed
        print(error.localizedDescription)
    } else {
        // comments now contains the comments for posts with images

    }
}
use Parse\ParseQuery;

$innerQuery = new ParseQuery("Post");
$innerQuery->exists("image");

$query = new ParseQuery("Comment");
$query->matchesQuery("post", $innerQuery);

// comments now contains the comments for posts with images.
$comments = $query->find();
foreach($comments as $result) {
  echo 'Object found ' . $result->getObjectId() . '<br>';
}
using Parse;

var innerQuery = from post in ParseObject.GetQuery("Post")
                 where post.ContainsKey("image")
                 select post;
var query = from comment in ParseObject.GetQuery("Comment")
            join post in innerQuery on comment["post"] equals post
            select comment;

var comments = await query.FindAsync();
// comments now contains the comments for posts with images

// or using LINQ
var innerQuery = ParseObject.GetQuery("Post")
    .WhereExists("image");
var query = ParseObject.GetQuery("Comment")
    .WhereMatchesQuery("post", innerQuery);

var comments = await query.FindAsync();
// comments now contains the comments for posts with images

Creating relational constraints (negation):

(async () => {
  const innerQuery = new Parse.Query('Post');
  innerQuery.greaterThan('likes', 50);

  const query = new Parse.Query('Comment');
  // Uses the innerQuery to apply constraints to the 'post' field
  query.doesNotMatchQuery('post', innerQuery);

  try {
    // Fetches only the comments whose posts does NOT contains more than 50 likes
    const comments = await query.find();
    console.log(`Comments found: ${JSON.stringify(comments)}`);
  } catch (error) {
    console.log(`Error: ${error}`);
  }
})();
(async () => {
  const innerQuery: Parse.Query = new Parse.Query('Post');
  innerQuery.greaterThan('likes', 50);

  const query: Parse.Query = new Parse.Query('Comment');
  // Uses the innerQuery to apply constraints to the 'post' field
  query.doesNotMatchQuery('post', innerQuery);

  try {
    // Fetches only the comments whose posts does NOT contains more than 50 likes
    const comments: Parse.Object[] = await query.find();
    console.log(`Comments found: ${JSON.stringify(comments)}`);
  } catch (error: any) {
    console.log(`Error: ${error}`);
  }
})();
# Fetches only the comments whose posts does NOT contains more than 50 likes
curl -X GET \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-G \
--data-urlencode 'where={"post":{"$notInQuery":{"where":{"likes":{"$gt":50}},"className":"Post"}}}' \
https://parseapi.back4app.com/classes/Comment
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

import java.util.List;

public void runQuery() {
  ParseQuery<ParseObject> innerQuery = ParseQuery.getQuery("Post");
  innerQuery.whereGreaterThan("likes", 50);

  ParseQuery<ParseObject> query = ParseQuery.getQuery("Comment");
  query.whereDoesNotMatchQuery("post", innerQuery);

  query.findInBackground((commentList, e) -> {
    if(e == null){
      for (ParseObject comment : commentList) {
        ParseObject post = comment.getParseObject("post");
        Log.d("Object found ",post.getObjectId());
      }
    }else{
        Toast.makeText(this, "Error: "+e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
PFQuery *innerQuery = [PFQuery queryWithClassName:@"Post"];
[innerQuery whereKey:@"likes" greaterThan:@50];
PFQuery *query = [PFQuery queryWithClassName:@"Comment"];
[query whereKey:@"post" doesNotMatchQuery:innerQuery];
[query findObjectsInBackgroundWithBlock:^(NSArray *comments, NSError *error) {
  // Fetches only the comments whose posts does NOT contains more than 50 likes
}];
let innerQuery = PFQuery(className: "Post")
innerQuery.whereKey("image", greaterThan: 50)
let query = PFQuery(className: "Comment")
query.whereKey("post", doesNotMatch: innerQuery)
query.findObjectsInBackground { (comments: [PFObject]?, error: Error?) in
  if let error = error {
    // The request failed
    print(error.localizedDescription)
  } else {
    // Fetches only the comments whose posts does NOT contains more than 50 likes
  }
}
use Parse\ParseQuery;

$innerQuery = new ParseQuery("Post");
$innerQuery->greaterThan("likes", 50);

$query = new ParseQuery("Comment");
$query->doesNotMatchQuery("post", $innerQuery);

// Fetches only the comments whose posts does NOT contains more than 50 likes
$results = $query->find();
foreach($results as $result) {
  echo 'Object found ' . $result->getObjectId() . '<br>';
}
using Parse;

var innerQuery = from post in ParseObject.GetQuery("Post")
                 where post.ContainsKey("image")
                 select post;
var query = ParseObject.GetQuery("Comment")
    .WhereDoesNotMatchQuery("post", innerQuery);

var comments = await query.FindAsync();
// comments now contains the comments for posts without images

// or using LINQ
var innerQuery = ParseObject.GetQuery("Post")
    .WhereExists("image");
var query = ParseObject.GetQuery("Comment")
    .WhereDoesNotMatchQuery("post", innerQuery);

var comments = await query.FindAsync();
// comments now contains the comments for posts without images

Initializing a related object:

(async () => {
  const query = new Parse.Query('Comment');

  // Include the post data with each comment
  query.include('post');

  // You also can initialize multiple levels of relations
  // query.include(['post.author']); // Initializes the post and its author

  try {
    // Comments now contains the 'post' field initialized!
    const comments = await query.find();
    const posts = comments.map(function (comment) {
      return comment.get('post');
    });
    console.log(`Posts found: ${JSON.stringify(posts)}`);
  } catch (error) {
    console.log(`Error: ${error}`);
  }
})();
(async () => {
  const query: Parse.Query = new Parse.Query('Comment');

  // Include the post data with each comment
  query.include('post');

  // You also can initialize multiple levels of relations
  // query.include(['post.author']); // Initializes the post and its author

  try {
    // Comments now contains the 'post' field initialized!
    const comments: Parse.Object[] = await query.find();
    const posts: Parse.Object[] = comments.map(function (comment) {
      return comment.get('post');
    });
    console.log(`Posts found: ${JSON.stringify(posts)}`);
  } catch (error: any) {
    console.log(`Error: ${error}`);
  }
})();
curl -X GET \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-G \
--data-urlencode 'include=post' \
https://parseapi.back4app.com/classes/Comment

# You can also do multi level includes using dot notation. ex: include=post.author
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

import java.util.List;

public void runQuery() {
  ParseQuery<ParseObject> query = ParseQuery.getQuery("Comment");

  // Include the post data with each comment
  query.include("post");

  // You also can initialize multiple levels of relations
  // query.include("post.author");

  query.findInBackground((commentList, e) -> {
    if(e == null){
      for (ParseObject comment : commentList) {
        // This does not require a network access.
        ParseObject post = comment.getParseObject("post");
        Log.d("Object found ",post.getObjectId());
      }
    }else{
        Toast.makeText(this, "Error: "+e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
PFQuery *query = [PFQuery queryWithClassName:@"Comment"];

// Include the post data with each comment
[query includeKey:@"post"];

// You also can initialize multiple levels of relations
// [query includeKey:@"post.author"];

[query findObjectsInBackgroundWithBlock:^(NSArray *comments, NSError *error) {
    // Comments now contains the "post" field
    // has been populated. For example:
    for (PFObject *comment in comments) {
         // This does not require a network access.
         PFObject *post = comment[@"post"];
         NSLog(@"retrieved related post: %@", post);
    }
}];
let query = PFQuery(className:"Comment")

// Include the post data with each comment
query.includeKey("post")

// You also can initialize multiple levels of relations
// query.includeKey("post.author")

query.findObjectsInBackground { (comments: [PFObject]?, error: Error?) in
  if let error = error {
    // The request failed
    print(error.localizedDescription)
  } else if let comments = comments {
    // Comments now contains the "post" field
    for comment in comments {
      // This does not require a network access.
      let post = comment["post"] as? PFObject
      print("retrieved related post: \(String(describing: post))")
    }
  }
}
use Parse\ParseQuery;

$query = new ParseQuery("Comment");

// Include the post data with each comment
query->includeKey("post");

// You also can initialize multiple levels of relations
// query->include("post.author"); // Initializes the post and its author

// Comments now contains the "post" field initialized!
$comments = query->find();
foreach($comments as $comment) {
  $post = $comment->get("post");
  echo 'Object found ' . $post->getObjectId() . '<br>';
}
using Parse;

var query = from comment in ParseObject.GetQuery("Comment")
            // Include the post data with each comment
            .Include("post")
            // You also can initialize multiple levels of relations
            // .Include("post.author")
            select comment;

var comments = await query.FindAsync();
// Comments now contains the "post" field

// or using LINQ
var query = ParseObject.GetQuery("Comment")
    // Include the post data with each comment
    .Include("post");
    // You also can initialize multiple levels of relations
    // .Include("post.author");

var comments = await query.FindAsync();
// Comments now contains the "post" field

Query supports creating constraints that evaluates if a field matches a particular Parse Object. It allows you to fetch only the objects that contains a specific relation with another object.

There are cases when you need to evaluate some related object fields in order to build a query with refined results.

That can be done by creating a inner query whose constraints will be applied only on the related field you want to evaluate, those are known as relational constraints and are also demonstrated in this section.

Using AND / OR operators

OR operator:

(async () => {
  // 'Post' is just an arbitrary class, replace it with your custom class
  const manyLikesQuery = new Parse.Query('Post');
  manyLikesQuery.greaterThan('likes', 1000);

  const specificPostQuery = new Parse.Query(Post);
  specificPostQuery.equalTo('title', 'My great post');

  // The query is satisfied when one of the constraints matches
  const composedQuery = Parse.Query.or(manyLikesQuery, specificPostQuery);

  try {
    // Fetches the posts with more than 1000 likes OR posts with the title 'My great post'
    const posts = await composedQuery.find();
    console.log(`Posts found: ${JSON.stringify(posts)}`);
  } catch (error) {
    console.log(`Error: ${error}`);
  }
})();
(async () => {
  // 'Post' is just an arbitrary class, replace it with your custom class
  const manyLikesQuery: Parse.Query = new Parse.Query('Post');
  manyLikesQuery.greaterThan('likes', 1000);

  const specificPostQuery: Parse.Query = new Parse.Query(Post);
  specificPostQuery.equalTo('title', 'My great post');

  // The query is satisfied when one of the constraints matches
  const composedQuery: Parse.Query = Parse.Query.or(manyLikesQuery, specificPostQuery);

  try {
    // Fetches the posts with more than 1000 likes OR posts with the title 'My great post'
    const posts: Parse.Object[] = await composedQuery.find();
    console.log(`Posts found: ${JSON.stringify(posts)}`);
  } catch (error: any) {
    console.log(`Error: ${error}`);
  }
})();
curl -X GET \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-G \
--data-urlencode 'where={"$or":[{"likes":{"$gt":1000}},{"title":"My great post"}]}' \
https://parseapi.back4app.com/classes/Comment
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

import java.util.ArrayList;
import java.util.List;

public void runQuery() {
  ParseQuery<ParseObject> manyLikesQuery = ParseQuery.getQuery("Post");
  manyLikesQuery.whereGreaterThan("likes", 1000);

  ParseQuery<ParseObject> specificPostQuery = ParseQuery.getQuery("Post");
  specificPostQuery.whereEqualTo("title", "My great post");

  List<ParseQuery<ParseObject>> queries = new ArrayList<ParseQuery<ParseObject>>();
  queries.add(manyLikesQuery);
  queries.add(specificPostQuery);

  ParseQuery<ParseObject> mainQuery = ParseQuery.or(queries);

  // Fetches the posts with more than 1000 likes OR posts with the title "My great post"
  mainQuery.findInBackground((postList, e) -> {
    if(e == null){
      for (ParseObject post : postList) {
        Log.d("Object found ",post.getObjectId());
      }
    }else{
        Toast.makeText(this, "Error: "+e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
PFQuery *manyLikesQuery = [PFQuery queryWithClassName:@"Post"];
[manyLikesQuery whereKey:@"likes" greaterThan:@1000];

PFQuery *specificPostQuery = [PFQuery queryWithClassName:@"Post"];
[specificPostQuery whereKey:@"title" equalTo:@"My great post"];

PFQuery *query = [PFQuery orQueryWithSubqueries:@[manyLikesQuery,specificPostQuery]];
[query findObjectsInBackgroundWithBlock:^(NSArray *results, NSError *error) {
  // Fetches the posts with more than 1000 likes OR posts with the title "My great post"
}];
let manyLikesQuery = PFQuery(className:"Post")
manyLikesQuery.whereKey("likes", greaterThan:1000)

let specificPostQuery = PFQuery(className:"Player")
specificPostQuery.whereKey("title", equalTo:"My great post")

let query = PFQuery.orQuery(withSubqueries: [manyLikesQuery, specificPostQuery])
query.findObjectsInBackground { (results: [PFObject]?, error: Error?) in
  if let error = error {
    // The request failed
    print(error.localizedDescription)
  } else {
    // Fetches the posts with more than 1000 likes OR posts with the title "My great post"
  }
}
use Parse\ParseQuery;

$manyLikesQuery = new ParseQuery("Post");
$manyLikesQuery->greaterThan("likes", 1000);

$specificPostQuery = new ParseQuery("Player");
$specificPostQuery->equalTo("title", "My great post");

// The query is satisfied when one of the constraints matches
$mainQuery = ParseQuery::orQueries([$manyLikesQuery, $specificPostQuery]);

// Fetches the posts with more than 1000 likes OR posts with the title "My great post"
$results = $mainQuery->find();
foreach($results as $result) {
  echo 'Object found ' . $result->getObjectId() . '<br>';
}
using Parse;

var manyLikesQuery = from post in ParseObject.GetQuery("Post")
                 where post.Get<int>("likes") > 1000
                 select post;

var specificPostQuery = from post in ParseObject.GetQuery("Post")
              where post.Get<string>("title") == "My great post"
              select post;

ParseQuery<ParseObject> query = manyLikesQuery.Or(specificPostQuery);

var results = await query.FindAsync();
// Fetches the posts with more than 1000 likes OR posts with the title "My great post"

// or using LINQ
var manyLikesQuery = ParseObject.GetQuery("Post")
    .WhereGreaterThan("likes", 1000);

var specificPostQuery = ParseObject.GetQuery("Post")
    .WhereEqualTo("title", "My great post");

ParseQuery<ParseObject> query = manyLikesQuery.Or(specificPostQuery);
// Fetches the posts with more than 1000 likes OR posts with the title "My great post"

AND operator:

(async () => {
  // 'Post' is just an arbitrary class, replace it with your custom class
  const manyLikesQuery = new Parse.Query('Post');
  manyLikesQuery.greaterThan('likes', 1000);

  const specificPostQuery = new Parse.Query(Post);
  specificPostQuery.equalTo('title', 'My great post');

  const loggedUser = Parse.User.current();
  const authorQuery = new Parse.Query(Post);
  authorQuery.equalTo('author', loggedUser);

  // The query is satisfied when both of the constraints matches.
  // You can combine multiple AND and OR operators in order to create
  // even more complex queries
  const composedQuery = Parse.Query.and(
    Parse.Query.or(manyLikesQuery, specificPostQuery),
    authorQuery
  );

  try {
    // Fetches the posts with more than 1000 likes OR posts with the title 'My great post',
    // and the logged user is the author of the post
    const posts = await composedQuery.find();
    console.log(`Posts found: ${JSON.stringify(posts)}`);
  } catch (error) {
    console.log(`Error: ${error}`);
  }
})();
(async () => {
  // 'Post' is just an arbitrary class, replace it with your custom class
  const manyLikesQuery: Parse.Query = new Parse.Query('Post');
  manyLikesQuery.greaterThan('likes', 1000);

  const specificPostQuery: Parse.Query = new Parse.Query(Post);
  specificPostQuery.equalTo('title', 'My great post');

  const loggedUser: Parse.User = Parse.User.current();
  const authorQuery: Parse.Query = new Parse.Query(Post);
  authorQuery.equalTo('author', loggedUser);

  // The query is satisfied when both of the constraints matches.
  // You can combine multiple AND and OR operators in order to create
  // even more complex queries
  const composedQuery: Parse.Query = Parse.Query.and(
    Parse.Query.or(manyLikesQuery, specificPostQuery),
    authorQuery
  );

  try {
    // Fetches the posts with more than 1000 likes OR posts with the title 'My great post',
    // and the logged user is the author of the post
    const posts: Parse.Object[] = await composedQuery.find();
    console.log(`Posts found: ${JSON.stringify(posts)}`);
  } catch (error: any) {
    console.log(`Error: ${error}`);
  }
})();
# Fetches the posts with more than 1000 likes OR posts with the title "My great post",
# and a specific user is the author of the post
curl -X GET \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-G \
--data-urlencode 'where={"$or":[{"likes":{"$gt":1000}}, {"title":"My great post"}], "author": {"__type":"Pointer","className":"_User","objectId":"kzunnPFh5i"}}' \
https://parseapi.back4app.com/classes/Post

import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseUser;

import java.util.ArrayList;
import java.util.List;

public void runQuery() {
  String className = "Post";

  ParseQuery<ParseObject> manyLikesQuery = ParseQuery.getQuery(className);
  manyLikesQuery.whereGreaterThan("likes", 1000);

  ParseUser loggedUser = ParseUser.getCurrentUser();
  ParseQuery<ParseObject> specificPostQuery = ParseQuery.getQuery(className);
  specificPostQuery.whereEqualTo("title", "My great post"); // title equals to "My great post"
  specificPostQuery.whereEqualTo("author", loggedUser); // AND author equals loggedUser

  List<ParseQuery<ParseObject>> queries = new ArrayList<ParseQuery<ParseObject>>();
  queries.add(manyLikesQuery);
  queries.add(specificPostQuery);

  ParseQuery<ParseObject> mainQuery = ParseQuery.or(queries);

  // The query is satisfied when both of the constraints matches.
  // You can combine multiple AND and OR operators in order to create
  // even more complex queries

  // Fetches the posts with more than 1000 likes OR posts with the title "My great post"
  // and the logged user is the author of the post
  mainQuery.findInBackground((postList, e) -> {
    if(e == null){
      for (ParseObject post : postList) {
        Log.d("Object found ",post.getObjectId());
      }
    }else{
        Toast.makeText(this, "Error: "+e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
PFQuery *manyLikesQuery = [PFQuery queryWithClassName:@"Post"];
[manyLikesQuery whereKey:@"likes" greaterThan:@1000];

PFQuery *specificPostQuery = [PFQuery queryWithClassName:@"Post"];
[specificPostQuery whereKey:@"title" equalTo:@"My great post"];

PFUser *loggedUser = [PFUser loggedUser];

PFQuery *query = [PFQuery orQueryWithSubqueries:@[manyLikesQuery,specificPostQuery]];
[query whereKey:@"author" equalTo:@loggedUser];

[query findObjectsInBackgroundWithBlock:^(NSArray *results, NSError *error) {
  // Fetches the posts with more than 1000 likes OR posts with the title "My great post",
  // and the logged user is the author of the post
}];
let manyLikesQuery = PFQuery(className:"Post")
manyLikesQuery.whereKey("likes", greaterThan:1000)

let specificPostQuery = PFQuery(className:"Post")
specificPostQuery.whereKey("title", equalTo:"My great post")

let loggedUser = PFUser.loggedUser()

let query = PFQuery.orQuery(withSubqueries: [manyLikesQuery, specificPostQuery])
query.whereKey("author", equalTo:loggedUser)

query.findObjectsInBackground { (results: [PFObject]?, error: Error?) in
  if let error = error {
    // The request failed
    print(error.localizedDescription)
  } else {
    // Fetches the posts with more than 1000 likes OR posts with the title "My great post",
    // and the logged user is the author of the post
  }
}
use Parse\ParseQuery;

$manyLikesQuery = new ParseQuery("Post");
$manyLikesQuery->greaterThan("likes", 1000);

$specificPostQuery = new ParseQuery("Player");
$specificPostQuery->equalTo("title", "My great post");

$loggedUser = ParseUser::getCurrentUser();

// The query is satisfied when one of the constraints matches
$mainQuery = ParseQuery::orQueries([$manyLikesQuery, $specificPostQuery]);

$mainQuery->equalTo("author", $loggedUser)

// Fetches the posts with more than 1000 likes OR posts with the title "My great post",
// and the logged user is the author of the post
$results = $mainQuery->find();
foreach($results as $result) {
  echo 'Object found ' . $result->getObjectId() . '<br>';
}

In order to create more complex queries, you will often need to create multiple constraints and combining them using logical operators OR and AND.

By using both operators, Query enables us to combine multiple subqueries, thus applying different sets of constraints. This way, we can achieve a higher level of complexity but also get even more refined results from our queries.

Aggregation

Grouping the results using a field value:

(async () => {
  // 'Post' is just an arbitrary class, replace it with your custom class
  const query = new Parse.Query('Post');

  // Grouping the results by the number of likes.
  // We need to use $ to indicate 'tags' is the name of the field
  // we want to use as our objectId
  const pipeline = {
    group: { objectId: '$tags' },
  };

  try {
    // results contains unique content values
    // The results are similar to the distinct feature
    const results = await query.aggregate(pipeline);
    console.log(`Posts grouped by tags found: ${JSON.stringify(results)}`);
  } catch (error) {
    console.log(`Error: ${error}`);
  }
})();
(async () => {
  // 'Post' is just an arbitrary class, replace it with your custom class
  const query: Parse.Query = new Parse.Query('Post');

  // Grouping the results by the number of likes.
  // We need to use $ to indicate 'tags' is the name of the field
  // we want to use as our objectId
  const pipeline: any = {
    group: { objectId: '$tags' },
  };

  try {
    // results contains unique content values
    // The results are similar to the distinct feature
    const results: Parse.Object[] = await query.aggregate(pipeline);
    console.log(`Posts grouped by tags found: ${JSON.stringify(results)}`);
  } catch (error: any) {
    console.log(`Error: ${error}`);
  }
})();
# Grouping the results by the number of likes.
# We need to use $ to indicate "content" is the name of the field
# we want to use as our objectId

curl -X GET \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "X-Parse-Master-Key: For test purpose only you can use Kq7Dv4kU7SVzqequMt7EznsvzSbORNb7g7Pd1SFn. Clone or connect in this app to use your own keys." \
-G \
--data-urlencode 'group={"objectId": "$content" }' \
https://parseapi.back4app.com/aggregate/Post

# The results are similar to the distinct feature
use Parse\ParseQuery;

// "Post" is just an arbitrary class, replace it with your custom class
$query = new ParseQuery("Post");

// Grouping the results by the number of likes.
// We need to use $ to indicate "content" is the name of the field
// we want to use as our objectId
$pipeline = [
  'group' => [ 'objectId' => '$content' ]
];

$results = $query->aggregate($pipeline);
// results contains unique likes values
// The results are similar to the distinct feature

Aggregating values:

(async () => {
  // 'Post' is just an arbitrary class, replace it with your custom class
  const query = new Parse.Query('Post');

  const pipeline = {
    group: {
      objectId: null,
      total: { $sum: '$likes' }, // 'total' will be a created field to hold the sum of likes field
      average: { $avg: '$likes' }, // 'average' will be a created field to hold the average of likes field
      maxLikes: { $max: '$likes' }, // 'maxLikes' will be a created field to hold the maximum value of likes field
      minLikes: { $min: '$likes' }, // 'minLikes' will be a created field to hold the minimum value of likes field
    },
  };
  // Notice that 'total', 'average', 'maxLikes', 'minLikes' are just arbitrary names,
  // and could be anything you want

  try {
    // results[0] should contain 'total', 'average', 'maxLikes' and 'minLikes' as attribute
    // You can access them like this: results[0].total
    const results = await query.aggregate(pipeline);
    console.log(`Aggregated results: ${JSON.stringify(results)}`);
  } catch (error) {
    console.log(`Error: ${error}`);
  }
})();
(async () => {
  // 'Post' is just an arbitrary class, replace it with your custom class
  const query: Parse.Query = new Parse.Query('Post');

  const pipeline: any = {
    group: {
      objectId: null,
      total: { $sum: '$likes' }, // 'total' will be a created field to hold the sum of likes field
      average: { $avg: '$likes' }, // 'average' will be a created field to hold the average of likes field
      maxLikes: { $max: '$likes' }, // 'maxLikes' will be a created field to hold the maximum value of likes field
      minLikes: { $min: '$likes' }, // 'minLikes' will be a created field to hold the minimum value of likes field
    },
  };
  // Notice that 'total', 'average', 'maxLikes', 'minLikes' are just arbitrary names,
  // and could be anything you want

  try {
    // results[0] should contain 'total', 'average', 'maxLikes' and 'minLikes' as attribute
    // You can access them like this: results[0].total
    const results: Parse.Object[] = await query.aggregate(pipeline);
    console.log(`Aggregated results: ${JSON.stringify(results)}`);
  } catch (error: any) {
    console.log(`Error: ${error}`);
  }
})();
curl -X GET \
-H "X-Parse-Application-Id: OuWMdJfaD0nadz4fTDcMQUHs2PT0DLEakh8WGReg" \
-H "X-Parse-REST-API-Key: Clone or connect in this app to use your own keys." \
-H "X-Parse-Master-Key: For test purpose only you can use Kq7Dv4kU7SVzqequMt7EznsvzSbORNb7g7Pd1SFn. Clone or connect in this app to use your own keys." \
-G \
--data-urlencode 'group={"objectId":null,"total":{"$sum":"$likes"},"average":{"$avg": "$likes"},"maxLikes":{"$max": "$likes"},"minLikes":{"$min": "$likes"}}'
https://parseapi.back4app.com/aggregate/Post
use Parse\ParseQuery;

// "Post" is just an arbitrary class, replace it with your custom class
$query = new ParseQuery("Post");

$pipeline = [
  'group' => [
    'objectId' => null,
    'total' => [ '$sum' => '$likes' ], // "total" will be a created field to hold the sum of likes field
    'average' => [ '$avg' => '$likes' ], // "average" will be a created field to hold the average of likes field
    'maxLikes' => [ '$max' => '$likes' ], // "maxLikes" will be a created field to hold the maximum value of likes field
    'minLikes' => [ '$min' => '$likes' ], // "minLikes" will be a created field to hold the minimum value of likes field
  ]
];
// Notice that "total", "average", "maxLikes", "minLikes" are just arbitrary names,
// and could be anything you want

$results = $query->aggregate($pipeline);
// results[0] should contain "total", "average", "maxLikes" and "minLikes" as attribute
// You can access them like this: results[0].total

For a more complete list of operators, please check the MongoDB documentation.

The aggregate operation is not available for this SDK yet. To execute this operation you could call REST API directly.

It is also possible to aggregate data into our queries. This is done by adding a pipeline of aggregations, where each aggregation can apply a transformation on the query results. In these aggregations, you can also apply calculations such as retrieving the average, minimum, maximum, and the sum of values.

Errors

This section provides a list of the Back4App API errors, with the error code and name, as well as brief details on how to properly handle errors. Make sure to inspect the returned error message for more specific information.

API Issues

Code Name Meaning
101 UserInvalidLoginParams Invalid login parameters. Check error message for more details.
101 ObjectNotFound The specified object or session doesn’t exist or could not be found. Can also indicate that you do not have the necessary permissions to read or write this object. Check error message for more details.
102 InvalidQuery There is a problem with the parameters used to construct this query. This could be an invalid field name or an invalid field type for a specific constraint. Check error message for more details.
105 InvalidFieldName An invalid field name. Keys are case-sensitive. They must start with a letter, and a-zA-Z0-9_ are the only valid characters. Some field names may be reserved. Check error message for more details.
107 InvalidJSON Badly formed JSON was received upstream. This either indicates you have done something unusual with modifying how things encode to JSON, or the network is failing badly. Can also indicate an invalid utf-8 string or use of multiple form encoded values. Check error message for more details.
109 NotInitialized You must call Parse.initialize before using the Parse library. Check the Quick Start guide for your platform.
116 ObjectTooLarge The object is too large. Parse Objects have a max size of 128 kilobytes.
116 ExceededConfigParamsError You have reached the limit of 100 config parameters.
117 InvalidLimitError An invalid value was set for the limit. Check error message for more details.
118 InvalidSkipError An invalid value was set for skip. Check error message for more details.
119 OperationForbidden The operation isn’t allowed for clients due to class-level permissions. Check error message for more details.
120 CacheMiss The result was not found in the cache.
121 InvalidNestedKey An invalid key was used in a nested JSONObject. Check error message for more details.
123 InvalidACL An invalid ACL was provided.
125 InvalidEmailAddress The email address was invalid.
137 DuplicateValue Unique field was given a value that is already taken.
139 InvalidRoleName Role’s name is invalid.
139 ReservedValue Field value is reserved.
140 ExceededCollectionQuota You have reached the quota on the number of classes in your app. Please delete some classes if you need to add a new class.
141 ScriptFailed Cloud Code script failed. Usually points to a JavaScript error. Check error message for more details.
141 FunctionNotFound Cloud function not found. Check that the specified Cloud function is present in your Cloud Code script and has been deployed.
141 JobNotFound Background job not found. Check that the specified job is present in your Cloud Code script and has been deployed.
141 SuccessErrorNotCalled success/error was not called. A cloud function will return once response.success() or response.error() is called. A background job will similarly finish execution once status.success() or status.error() is called. If a function or job never reaches either of the success/error methods, this error will be returned. This may happen when a function does not handle an error response correctly, preventing code execution from reaching the success() method call.
141 MultupleSuccessErrorCalls Can’t call success/error multiple times. A cloud function will return once response.success() or response.error() is called. A background job will similarly finish execution once status.success() or status.error() is called. If a function or job calls success() and/or error() more than once in a single execution path, this error will be returned.
142 ValidationFailed Cloud Code validation failed.
143 WebhookError Webhook error.
150 InvalidImageData Invalid image data.
151 UnsavedFileError An unsaved file.
152 InvalidPushTimeError An invalid push time was specified.
158 HostingError Hosting error.
160 InvalidEventName The provided analytics event name is invalid.
255 ClassNotEmpty Class is not empty and cannot be dropped.
256 AppNameInvalid App name is invalid.
902 MissingAPIKeyError The request is missing an API key.
903 InvalidAPIKeyError The request is using an invalid API key.
Code Name Meaning
200 UsernameMissing Invalid login parameters. Check error message for more details.
201 PasswordMissing The specified object or session doesn’t exist or could not be found. Can also indicate that you do not have the necessary permissions to read or write this object. Check error message for more details.
202 UsernameTaken There is a problem with the parameters used to construct this query. This could be an invalid field name or an invalid field type for a specific constraint. Check error message for more details.
203 UserEmailTaken An invalid field name. Keys are case-sensitive. They must start with a letter, and a-zA-Z0-9_ are the only valid characters. Some field names may be reserved. Check error message for more details.
204 UserEmailMissing Badly formed JSON was received upstream. This either indicates you have done something unusual with modifying how things encode to JSON, or the network is failing badly. Can also indicate an invalid utf-8 string or use of multiple form encoded values. Check error message for more details.
205 UserWithEmailNotFound You must call Parse.initialize before using the Parse library. Check the Quick Start guide for your platform.
206 SessionMissing A user object without a valid session could not be altered.
207 MustCreateUserThroughSignup A user can only be created through signup.
208 AccountAlreadyLinked An account being linked is already linked to another user.
209 InvalidSessionToken The device’s session token is no longer valid. The application should ask the user to log in again.

General Issues

Code Name Meaning
-1 OtherCause Invalid login parameters. Check error message for more details.
1 InternalServerError The specified object or session doesn’t exist or could not be found. Can also indicate that you do not have the necessary permissions to read or write this object. Check error message for more details.
2 ServiceUnavailable There is a problem with the parameters used to construct this query. This could be an invalid field name or an invalid field type for a specific constraint. Check error message for more details.
4 ClientDisconnected An invalid field name. Keys are case-sensitive. They must start with a letter, and a-zA-Z0-9_ are the only valid characters. Some field names may be reserved. Check error message for more details.

Learning More

Since this documentation is not yet exhaustive and the team is still working to make it complete, you can find below a set of useful links through which you can learn about the APIs that are not yet documented here:

Back4App Documentation

Parse Open Source Documentation