NAV Navbar

Back4Press

cURL JavaScript Android Swift Objective-C PHP .NET

Introduction

The Back4Press 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 are mostly generated through Parse Server.

The API documentation below is specifically generated for your app Back4Press 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.

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

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.

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

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 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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
https://parseapi.back4app.com/serverInfo

You should not use the REST API Key in client apps. If you need to send a RETS 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 Node.js project:

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

Parse.serverURL = 'https://parseapi.back4app.com'; // This is your Server URL
Parse.initialize(
  'BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f', // This is your Application ID
  '4wPYRKbpTJeCdmFNaS31AiQZ8344aaYubk6Uo8VW', // This is your Javascript key
  '5AVAtvlGlG5cEeolatkFDhY5p99PzoBUvm7MBLMo' // This is your Master key (never use it in the frontend)
);

In an Ionic project:

const Parse = require('parse');

Parse.serverURL = 'https://parseapi.back4app.com'; // This is your Server URL
Parse.initialize(
  'BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f', // This is your Application ID
  '4wPYRKbpTJeCdmFNaS31AiQZ8344aaYubk6Uo8VW' // This is your Javascript key
);

In a React Native project:

const { AsyncStorage } = require('react-native');
const Parse = require('parse/react-native');

Parse.setAsyncStorage(AsyncStorage);
Parse.serverURL = 'https://parseapi.back4app.com'; // This is your Server URL
Parse.initialize(
  'BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f', // This is your Application ID
  '4wPYRKbpTJeCdmFNaS31AiQZ8344aaYubk6Uo8VW' // This is your Javascript key
);

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
Parse.initialize(
  'BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f', // This is your Application ID
  '4wPYRKbpTJeCdmFNaS31AiQZ8344aaYubk6Uo8VW' // This is your Javascript key
);
</script>

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("BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f")
      .clientKey("rWFPEbTs7UzkaVsIXnQ4qmmr9oWqwXfiiJehtIZu")
      .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 = "BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f"
      $0.clientKey = "rWFPEbTs7UzkaVsIXnQ4qmmr9oWqwXfiiJehtIZu"
      $0.server = "https://parseapi.back4app.com"
  }
  Parse.initialize(with: parseConfig)
}
// AppDelegate.m
[Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration>  _Nonnull configuration) {
  configuration.applicationId = @"BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f";
  configuration.clientKey = @"rWFPEbTs7UzkaVsIXnQ4qmmr9oWqwXfiiJehtIZu";
  configuration.server = @"https://parseapi.back4app.com";
}]];
using Parse;

ParseClient.Initialize(new ParseClient.Configuration {
    ApplicationId = "BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f",
    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( "BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f", "swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w", "5AVAtvlGlG5cEeolatkFDhY5p99PzoBUvm7MBLMo" );
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

BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

Client key

rWFPEbTs7UzkaVsIXnQ4qmmr9oWqwXfiiJehtIZu

JavaScript key

4wPYRKbpTJeCdmFNaS31AiQZ8344aaYubk6Uo8VW

.NET key

Y1xbq7W0YSJSw1JSOf8hPUgHqXvwgXVEBDck3oaB

REST API key

swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

Webhook key

W0683XHye3PU6H4I8mvOL0aMgsyoPrBdnN0rxn4B

File key

8b5c72e4-8894-4dc3-ab9b-d64528420865

Master key

5AVAtvlGlG5cEeolatkFDhY5p99PzoBUvm7MBLMo

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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-H "Content-Type: application/json" \
-d '{where={"myCustomKey1Name":"myCustomKey1Value","myCustomKey2Name":"myCustomKey2Value"}}' \
https://parseapi.back4app.com/classes/MyCustomClassName

Example Response:

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

Code:

const MyCustomClass = Parse.Object.extend('MyCustomClassName');
const myNewObject = new MyCustomClass();

myNewObject.set('myCustomKey1Name', 'myCustomKey1Value');
myNewObject.set('myCustomKey2Name', 'myCustomKey2Value');

myNewObject.save().then(
  (result) => {
    console.log(result);
  },
  (error) => {
    console.error(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(new SaveCallback() {
    @Override
    public void done(ParseException e) {
      // Here you can handle errors, if thrown. Otherwise, "e" should be null
    }
  });
}
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:

ParseObjectSubclass {
  className: 'MyCustomClassName',
  _objCount: 0,
  id: '4BwpMWdCnm'
}

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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-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:

const MyCustomClass = Parse.Object.extend('MyCustomClassName');
const query = new Parse.Query(MyCustomClass);
query.equalTo("myCustomKey1Name", "myCustomKey1Value");
query.find().then((results) => {
  results.forEach((result) =>{
    const myCustomKey1Name = result.get('myCustomKey1Name');
    const myCustomKey2Name = result.get('myCustomKey2Name');
    console.log(myCustomKey1Name, myCustomKey2Name);
  })
}, (error) => {
  console.error(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>", new GetCallback<ParseObject>() {
    public void done(ParseObject result, ParseException e) {
      if (e == null) {
        System.out.println(result);
      } else {
        // something went wrong
      }
    }
  });
}
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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-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:

const MyCustomClass = Parse.Object.extend('MyCustomClassName');
const query = new Parse.Query(MyCustomClass);
// here you put the objectId that you want to update
query.get('xKue915KBG').then((object) => {
  object.set('myCustomKey1Name', 'new value');
  object.save().then((response) => {
    console.log(response);
  })
}, (error) => {
  console.error(error);
});

Example Output:

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

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

const MyCustomClass = Parse.Object.extend('MyCustomClassName');
const query = new Parse.Query(MyCustomClass);
// here you put the objectId that you want to update
query.get('xKue915KBG').then((object) => {
  // After this, the myCustomKeyName field will be empty
  object.unset('myCustomKeyName');

  object.save().then((response) => {
    console.log(response);
  })
}, (error) => {
  console.error(error);
});

Example Output:

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

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>", new GetCallback<ParseObject>() {
    public void done(ParseObject entity, ParseException e) {
      if (e == null) {
        // Update the fields we want to
        entity.put("myCustomKey1Name", "My new value");
        entity.put("myCustomKey2Name", 999);

        // All other fields will remain the same
        entity.saveInBackground();
      }
    }
  });
}
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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
https://parseapi.back4app.com/classes/MyCustomClassName/Ed1nuqPvcm

Example Response:

{}

Code:

const MyCustomClass = Parse.Object.extend('MyCustomClassName');
const query = new Parse.Query(MyCustomClass);
// here you put the objectId that you want to delete
query.get('xKue915KBG').then((object) => {
  object.destroy().then((response) => {
    console.log(response);
  })
}, (error) => {
  console.error(error);
});

Example Output:

ParseObjectSubclass { 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() {
  // TODO: modify me!
  final boolean deleteAttributesOnly = true;

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

  // Retrieve the object by id
  query.getInBackground("<PARSE_OBJECT_ID>", new GetCallback<ParseObject>() {
    public void done(ParseObject entity, ParseException e) {
      if (e == null) {
        if (deleteAttributesOnly) {
          // If you want to undefine a specific field, do this:
          entity.remove("myCustomKey1Name");

          // Then save the changes
          entity.saveInBackground();
        } else {
          // Otherwise, you can delete the entire ParseObject from the database
          entity.deleteInBackground();
        }
      }
    }
  });
}
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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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\": \"Class to establish a relation\" },
  \"geopointExample\": { \"__type\": \"GeoPoint\", \"latitude\": 40.0, \"longitude\": -30.0 },
  \"polygonExample\": [ {\"__type\": \"GeoPoint\", \"latitude\": 0, \"longitude\": 0 }, { \"__type\": \"GeoPoint\", \"latitude\": 0, \"longitude\": 1 }, { \"__type\": \"GeoPoint\", \"latitude\": 1, \"longitude\": 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("Class to establish a relation");

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("Class to establish a relation");

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:"Class to establish a relation")

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("Class to establish a relation")

$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("Class to establish a relation");

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

//  polygonExample = <NOT_AVAILABLE>;

Comment Class

Example JSON:

{
  "content": "A string",
  "likes": 1,
  "publishDate": "2018-11-12T13:13:45.958Z",
  "owner": { "__type": "Pointer", "className": "<YOUR_CLASS_NAME>", "objectId": "<THE_REFERENCED_OBJECT_ID>" }
}

Comment is a custom class that was created and is specific for Back4Press. 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/Comment

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

Name Type Example
content String "A string"
likes Number 1
publishDate Date "2018-11-12T13:13:45.958Z"
owner Pointer { "__type": "Pointer", "className": "<YOUR_CLASS_NAME>", "objectId": "<THE_REFERENCED_OBJECT_ID>" }

Creating Objects

Example Request:

curl -X POST \
-H "X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-H "Content-Type: application/json" \
-d "{ \"content\":\"A string\",\"likes\":1,\"publishDate\":{ \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },\"owner\":{ \"__type\": \"Pointer\", \"className\": \"<YOUR_CLASS_NAME>\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" } }" \
https://parseapi.back4app.com/classes/Comment

Example Response:

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

Code:

const Comment = Parse.Object.extend('Comment');
const myNewObject = new Comment();

myNewObject.set('content', 'A string');
myNewObject.set('likes', 1);
myNewObject.set('publishDate', new Date());
myNewObject.set('owner', new Parse.Object("<YOUR_CLASS_NAME>"));

myNewObject.save().then(
  (result) => {
    console.log(result);
  },
  (error) => {
    console.error(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("Comment");

  entity.put("content", "A string");
  entity.put("likes", 1);
  entity.put("publishDate", new Date());
  entity.put("owner", new ParseObject("<YOUR_CLASS_NAME>"));

  // Saves the new object.
  // Notice that the SaveCallback is totally optional!
  entity.saveInBackground(new SaveCallback() {
    @Override
    public void done(ParseException e) {
      // Here you can handle errors, if thrown. Otherwise, "e" should be null
    }
  });
}
var parseObject = PFObject(className:"Comment")

parseObject["content"] = "A string"
parseObject["likes"] = 1
parseObject["publishDate"] = NSDate()
parseObject["owner"] = PFObject(className:"<YOUR_CLASS_NAME>")

// 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:@"Comment"];

parseObject[@"content"] = @"A string";
parseObject[@"likes"] = @1;
parseObject[@"publishDate"] = [NSDate date];
parseObject[@"owner"] = [PFObject objectWithClassName:@"<YOUR_CLASS_NAME>"];

[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("Comment");
myObject["content"] = "A string";
myObject["likes"] = 1;
myObject["publishDate"] = DateTime.Now;
myObject["owner"] = new ParseObject("<YOUR_CLASS_NAME>");
await myObject.SaveAsync();
$myCustomObject = new ParseObject("Comment");

$myCustomObject->set("content", "A string");
$myCustomObject->set("likes", 1);
$myCustomObject->set("publishDate", new DateTime());
$myCustomObject->set("owner", new ParseObject("<YOUR_CLASS_NAME>"));

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:

ParseObjectSubclass {
  className: 'Comment',
  _objCount: 0,
  id: '4BwpMWdCnm'
}

To create a new object of the Comment class, you'll need to send a POST request to the Comment 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/Comment

Method

POST

Headers

X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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/Comment/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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-G \
--data-urlencode "where={ \"content\":\"A string\",\"likes\":1,\"publishDate\":{ \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },\"owner\":{ \"__type\": \"Pointer\", \"className\": \"<YOUR_CLASS_NAME>\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" } }" \
https://parseapi.back4app.com/classes/Comment

Example Response:

{
  "results": [
    {
      "objectId": "zJxVP17mTi",
      "createdAt": "2018-10-31T14:16:13.616Z",
      "updatedAt": "2018-11-07T12:12:20.758Z",
      "content": \"A string\","likes": 1,"publishDate": { \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },"owner": { \"__type\": \"Pointer\", \"className\": \"<YOUR_CLASS_NAME>\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" }
    },
    {
      "objectId": "yDbv0gKGJR",
      "createdAt": "2018-10-31T14:16:42.811Z",
      "updatedAt": "2018-11-07T12:12:18.543Z",
      "content": \"A string\","likes": 1,"publishDate": { \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },"owner": { \"__type\": \"Pointer\", \"className\": \"<YOUR_CLASS_NAME>\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" }
    },
    {
      "objectId": "xKue915KBG",
      "createdAt": "2018-11-07T12:11:58.533Z",
      "updatedAt": "2018-11-07T12:12:15.413Z",
      "content": \"A string\","likes": 1,"publishDate": { \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },"owner": { \"__type\": \"Pointer\", \"className\": \"<YOUR_CLASS_NAME>\", \"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:

const Comment = Parse.Object.extend('Comment');
const query = new Parse.Query(Comment);
query.equalTo("content", 'A string');
query.equalTo("likes", 1);
query.equalTo("publishDate", new Date());
query.equalTo("owner", new Parse.Object("<YOUR_CLASS_NAME>"));
query.find().then((results) => {
  results.forEach((result) => {
    const content = result.get('content');
    const likes = result.get('likes');
    const publishDate = result.get('publishDate');
    const owner = result.get('owner');
    console.log(content, likes, publishDate, owner);
  })
}, (error) => {
  console.error(error);
});

Example Output:

'A string' 1 new Date() new Parse.Object("<YOUR_CLASS_NAME>") 

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("Comment");

  // 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>", new GetCallback<ParseObject>() {
    public void done(ParseObject result, ParseException e) {
      if (e == null) {
        System.out.println(result);
      } else {
        // something went wrong
      }
    }
  });
}
var query = PFQuery(className:"Comment")

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:@"Comment"];
[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("Comment");
ParseObject result = await query.GetAsync("<PARSE_OBJECT_ID>");
// Use the Get<T> method to get the values
string content = result.Get<string>("content");
int likes = result.Get<int>("likes");
DateTime publishDate = result.Get<DateTime>("publishDate");
ParseObject owner = result.Get<ParseObject>("owner");
$query = new ParseQuery("Comment");
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:
  $content = $myCustomObject->get("content");
  $likes = $myCustomObject->get("likes");
  $publishDate = $myCustomObject->get("publishDate");
  $owner = $myCustomObject->get("owner");
} 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/Comment

Method

GET

Headers

X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-H "Content-Type: application/json" \
-d "{ \"content\": \"A string\",\"likes\": 1,\"publishDate\": { \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },\"owner\": { \"__type\": \"Pointer\", \"className\": \"<YOUR_CLASS_NAME>\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" } }" \
https://parseapi.back4app.com/classes/Comment/<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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-H "Content-Type: application/json" \
-d '{ "content": {"__op":"Delete"},"likes": {"__op":"Delete"},"publishDate": {"__op":"Delete"},"owner": {"__op":"Delete"} }' \
https://parseapi.back4app.com/classes/Comment

Example Response:

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

Code:

const Comment = Parse.Object.extend('Comment');
const query = new Parse.Query(Comment);
// here you put the objectId that you want to update
query.get('xKue915KBG').then((object) => {
  object.set('content', 'A string');
  object.set('likes', 1);
  object.set('publishDate', new Date());
  object.set('owner', new Parse.Object("<YOUR_CLASS_NAME>"));
  object.save().then((response) => {
    console.log(response);
  })
}, (error) => {
  console.error(error);
});

Example Output:

ParseObjectSubclass { className: Comment, _objCount: 0, id: 'xKue915KBG' }

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

const Comment = Parse.Object.extend('Comment');
const query = new Parse.Query(Comment);
// here you put the objectId that you want to update
query.get('xKue915KBG').then((object) => {
  // After this, the myCustomKeyName field will be empty
  object.unset('name');

  object.save().then((response) => {
    console.log(response);
  })
}, (error) => {
  console.error(error);
});

Example Output:

ParseObjectSubclass { className: 'Comment', _objCount: 0, id: 'xKue915KBG' }

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("Comment");

  // Retrieve the object by id
  query.getInBackground("<PARSE_OBJECT_ID>", new GetCallback<ParseObject>() {
    public void done(ParseObject entity, ParseException e) {
      if (e == null) {
        // Update the fields we want to
        entity.put("content", "A string");
        entity.put("likes", 1);
        entity.put("publishDate", new Date());
        entity.put("owner", new ParseObject("<YOUR_CLASS_NAME>"));

        // All other fields will remain the same
        entity.saveInBackground();
      }
    }
  });
}
var query = PFQuery(className:"Comment")

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error != nil {
    print(error)
  } else if parseObject != nil {
    parseObject["content"] = "A string"
    parseObject["likes"] = 1
    parseObject["publishDate"] = NSDate()
    parseObject["owner"] = PFObject(className:"<YOUR_CLASS_NAME>")

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

// Retrieve the object by id
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>"
                             block:^(PFObject *parseObject, NSError *error) {
    parseObject[@"content"] = @"A string";
    parseObject[@"likes"] = @1;
    parseObject[@"publishDate"] = [NSDate date];
    parseObject[@"owner"] = [PFObject objectWithClassName:@"<YOUR_CLASS_NAME>"];

    [parseObject saveInBackground];
}];
ParseQuery<ParseObject> query = ParseObject.GetQuery("Comment");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
myObject["content"] = "A string";
myObject["likes"] = 1;
myObject["publishDate"] = DateTime.Now;
myObject["owner"] = new ParseObject("<YOUR_CLASS_NAME>");
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("content");
myObject.Remove("likes");
myObject.Remove("publishDate");
myObject.Remove("owner");
await myObject.SaveAsync();
$query = new ParseQuery("Comment");
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("content", "A string");
  $myCustomObject->set("likes", 1);
  $myCustomObject->set("publishDate", new DateTime());
  $myCustomObject->set("owner", new ParseObject("<YOUR_CLASS_NAME>"));

  // 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/Comment/MyCurrentObjectId

Method

PUT

Headers

X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
https://parseapi.back4app.com/classes/Comment/<OBJECT_ID>

Example Response:

{}

Code:

const Comment = Parse.Object.extend('Comment');
const query = new Parse.Query(Comment);
// here you put the objectId that you want to delete
query.get('xKue915KBG').then((object) => {
  object.destroy().then((response) => {
    console.log(response);
  })
}, (error) => {
  console.error(error);
});

Example Output:

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

public void deleteObject() {
  // TODO: modify me!
  final boolean deleteAttributesOnly = true;

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

  // Retrieve the object by id
  query.getInBackground("<PARSE_OBJECT_ID>", new GetCallback<ParseObject>() {
    public void done(ParseObject entity, ParseException e) {
      if (e == null) {
        if (deleteAttributesOnly) {
          // If you want to undefine a specific field, do this:
          entity.remove("content");
          entity.remove("likes");
          entity.remove("publishDate");
          entity.remove("owner");

          // Then save the changes
          entity.saveInBackground();
        } else {
          // Otherwise, you can delete the entire ParseObject from the database
          entity.deleteInBackground();
        }
      }
    }
  });
}
var deleteAttributesOnly = true

var query = PFQuery(className:"Comment")

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error != nil {
    print(error)
  } else if parseObject != nil {
    if deleteAttributesOnly {
      parseObject.removeObjectForKey("content")
      parseObject.removeObjectForKey("likes")
      parseObject.removeObjectForKey("publishDate")
      parseObject.removeObjectForKey("owner")
      parseObject.saveInBackground()
    } else {
      parseObject.deleteInBackground()
    }
  }
}
PFQuery *query = [PFQuery queryWithClassName:@"Comment"];

// 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:@"content"];
  // [parseObject removeObjectForKey:@"likes"];
  // [parseObject removeObjectForKey:@"publishDate"];
  // [parseObject removeObjectForKey:@"owner"];
  // 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("Comment");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
await myObject.DeleteAsync();
$query = new ParseQuery("Comment");
try {
  $myCustomObject = $query->get("<PARSE_OBJECT_ID>");
  // The object was retrieved successfully.

  // After this, the field will be empty
  $myCustomObject->delete("content");
  $myCustomObject->delete("likes");
  $myCustomObject->delete("publishDate");
  $myCustomObject->delete("owner");
  // 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/Comment/MyCurrentObjectId

Method

DELETE

Headers

X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

Success Response

Status

200 OK

Headers

content-type: application/json;

Body

An empty JSON object.

Error Response

Please check the Errors section.

Post Class

Example JSON:

{
  "content": "A string",
  "likes": 1,
  "tags": [1, "a string"],
  "publishDate": "2018-11-12T13:13:45.958Z",
  "owner": { "__type": "Pointer", "className": "<YOUR_CLASS_NAME>", "objectId": "<THE_REFERENCED_OBJECT_ID>" },
  "showComments": true
}

Post is a custom class that was created and is specific for Back4Press. 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/Post

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

Name Type Example
content String "A string"
likes Number 1
tags Array [1, "a string"]
publishDate Date "2018-11-12T13:13:45.958Z"
owner Pointer { "__type": "Pointer", "className": "<YOUR_CLASS_NAME>", "objectId": "<THE_REFERENCED_OBJECT_ID>" }
showComments Boolean true

Creating Objects

Example Request:

curl -X POST \
-H "X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-H "Content-Type: application/json" \
-d "{ \"content\":\"A string\",\"likes\":1,\"tags\":[ 1, \"a string\" ],\"publishDate\":{ \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },\"owner\":{ \"__type\": \"Pointer\", \"className\": \"<YOUR_CLASS_NAME>\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" },\"showComments\":true }" \
https://parseapi.back4app.com/classes/Post

Example Response:

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

Code:

const Post = Parse.Object.extend('Post');
const myNewObject = new Post();

myNewObject.set('content', 'A string');
myNewObject.set('likes', 1);
myNewObject.set('tags', [1, 'a string']);
myNewObject.set('publishDate', new Date());
myNewObject.set('owner', new Parse.Object("<YOUR_CLASS_NAME>"));
myNewObject.set('showComments', true);

myNewObject.save().then(
  (result) => {
    console.log(result);
  },
  (error) => {
    console.error(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("Post");

  entity.put("content", "A string");
  entity.put("likes", 1);
  entity.put("tags", new JSONArray());
  entity.put("publishDate", new Date());
  entity.put("owner", new ParseObject("<YOUR_CLASS_NAME>"));
  entity.put("showComments", true);

  // Saves the new object.
  // Notice that the SaveCallback is totally optional!
  entity.saveInBackground(new SaveCallback() {
    @Override
    public void done(ParseException e) {
      // Here you can handle errors, if thrown. Otherwise, "e" should be null
    }
  });
}
var parseObject = PFObject(className:"Post")

parseObject["content"] = "A string"
parseObject["likes"] = 1
parseObject["tags"] = [1, "a string"]
parseObject["publishDate"] = NSDate()
parseObject["owner"] = PFObject(className:"<YOUR_CLASS_NAME>")
parseObject["showComments"] = true

// 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:@"Post"];

parseObject[@"content"] = @"A string";
parseObject[@"likes"] = @1;
parseObject[@"tags"] = @[@1, @"a string"];
parseObject[@"publishDate"] = [NSDate date];
parseObject[@"owner"] = [PFObject objectWithClassName:@"<YOUR_CLASS_NAME>"];
parseObject[@"showComments"] = @YES;

[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("Post");
myObject["content"] = "A string";
myObject["likes"] = 1;
myObject["tags"] = new List<object>{1, "a string"};
myObject["publishDate"] = DateTime.Now;
myObject["owner"] = new ParseObject("<YOUR_CLASS_NAME>");
myObject["showComments"] = true;
await myObject.SaveAsync();
$myCustomObject = new ParseObject("Post");

$myCustomObject->set("content", "A string");
$myCustomObject->set("likes", 1);
$myCustomObject->set("tags", [1, "a string"]);
$myCustomObject->set("publishDate", new DateTime());
$myCustomObject->set("owner", new ParseObject("<YOUR_CLASS_NAME>"));
$myCustomObject->set("showComments", true);

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:

ParseObjectSubclass {
  className: 'Post',
  _objCount: 0,
  id: '4BwpMWdCnm'
}

To create a new object of the Post class, you'll need to send a POST request to the Post 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/Post

Method

POST

Headers

X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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/Post/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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-G \
--data-urlencode "where={ \"content\":\"A string\",\"likes\":1,\"tags\":[ 1, \"a string\" ],\"publishDate\":{ \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },\"owner\":{ \"__type\": \"Pointer\", \"className\": \"<YOUR_CLASS_NAME>\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" },\"showComments\":true }" \
https://parseapi.back4app.com/classes/Post

Example Response:

{
  "results": [
    {
      "objectId": "zJxVP17mTi",
      "createdAt": "2018-10-31T14:16:13.616Z",
      "updatedAt": "2018-11-07T12:12:20.758Z",
      "content": \"A string\","likes": 1,"tags": [ 1, \"a string\" ],"publishDate": { \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },"owner": { \"__type\": \"Pointer\", \"className\": \"<YOUR_CLASS_NAME>\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" },"showComments": true
    },
    {
      "objectId": "yDbv0gKGJR",
      "createdAt": "2018-10-31T14:16:42.811Z",
      "updatedAt": "2018-11-07T12:12:18.543Z",
      "content": \"A string\","likes": 1,"tags": [ 1, \"a string\" ],"publishDate": { \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },"owner": { \"__type\": \"Pointer\", \"className\": \"<YOUR_CLASS_NAME>\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" },"showComments": true
    },
    {
      "objectId": "xKue915KBG",
      "createdAt": "2018-11-07T12:11:58.533Z",
      "updatedAt": "2018-11-07T12:12:15.413Z",
      "content": \"A string\","likes": 1,"tags": [ 1, \"a string\" ],"publishDate": { \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },"owner": { \"__type\": \"Pointer\", \"className\": \"<YOUR_CLASS_NAME>\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" },"showComments": true
    }
  ]
}

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

Learn more about query parameters in queries section.

Code:

const Post = Parse.Object.extend('Post');
const query = new Parse.Query(Post);
query.equalTo("content", 'A string');
query.equalTo("likes", 1);
query.equalTo("tags", [1, 'a string']);
query.equalTo("publishDate", new Date());
query.equalTo("owner", new Parse.Object("<YOUR_CLASS_NAME>"));
query.equalTo("showComments", true);
query.find().then((results) => {
  results.forEach((result) => {
    const content = result.get('content');
    const likes = result.get('likes');
    const tags = result.get('tags');
    const publishDate = result.get('publishDate');
    const owner = result.get('owner');
    const showComments = result.get('showComments');
    console.log(content, likes, tags, publishDate, owner, showComments);
  })
}, (error) => {
  console.error(error);
});

Example Output:

'A string' 1 [1, 'a string'] new Date() new Parse.Object("<YOUR_CLASS_NAME>") true 

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("Post");

  // 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>", new GetCallback<ParseObject>() {
    public void done(ParseObject result, ParseException e) {
      if (e == null) {
        System.out.println(result);
      } else {
        // something went wrong
      }
    }
  });
}
var query = PFQuery(className:"Post")

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:@"Post"];
[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("Post");
ParseObject result = await query.GetAsync("<PARSE_OBJECT_ID>");
// Use the Get<T> method to get the values
string content = result.Get<string>("content");
int likes = result.Get<int>("likes");
IList tags = result.Get<IList>("tags");
DateTime publishDate = result.Get<DateTime>("publishDate");
ParseObject owner = result.Get<ParseObject>("owner");
bool showComments = result.Get<bool>("showComments");
$query = new ParseQuery("Post");
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:
  $content = $myCustomObject->get("content");
  $likes = $myCustomObject->get("likes");
  $tags = $myCustomObject->get("tags");
  $publishDate = $myCustomObject->get("publishDate");
  $owner = $myCustomObject->get("owner");
  $showComments = $myCustomObject->get("showComments");
} 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/Post

Method

GET

Headers

X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-H "Content-Type: application/json" \
-d "{ \"content\": \"A string\",\"likes\": 1,\"tags\": [ 1, \"a string\" ],\"publishDate\": { \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },\"owner\": { \"__type\": \"Pointer\", \"className\": \"<YOUR_CLASS_NAME>\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" },\"showComments\": true }" \
https://parseapi.back4app.com/classes/Post/<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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-H "Content-Type: application/json" \
-d '{ "content": {"__op":"Delete"},"likes": {"__op":"Delete"},"tags": {"__op":"Delete"},"publishDate": {"__op":"Delete"},"owner": {"__op":"Delete"},"showComments": {"__op":"Delete"} }' \
https://parseapi.back4app.com/classes/Post

Example Response:

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

Code:

const Post = Parse.Object.extend('Post');
const query = new Parse.Query(Post);
// here you put the objectId that you want to update
query.get('xKue915KBG').then((object) => {
  object.set('content', 'A string');
  object.set('likes', 1);
  object.set('tags', [1, 'a string']);
  object.set('publishDate', new Date());
  object.set('owner', new Parse.Object("<YOUR_CLASS_NAME>"));
  object.set('showComments', true);
  object.save().then((response) => {
    console.log(response);
  })
}, (error) => {
  console.error(error);
});

Example Output:

ParseObjectSubclass { className: Post, _objCount: 0, id: 'xKue915KBG' }

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

const Post = Parse.Object.extend('Post');
const query = new Parse.Query(Post);
// here you put the objectId that you want to update
query.get('xKue915KBG').then((object) => {
  // After this, the myCustomKeyName field will be empty
  object.unset('name');

  object.save().then((response) => {
    console.log(response);
  })
}, (error) => {
  console.error(error);
});

Example Output:

ParseObjectSubclass { className: 'Post', _objCount: 0, id: 'xKue915KBG' }

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("Post");

  // Retrieve the object by id
  query.getInBackground("<PARSE_OBJECT_ID>", new GetCallback<ParseObject>() {
    public void done(ParseObject entity, ParseException e) {
      if (e == null) {
        // Update the fields we want to
        entity.put("content", "A string");
        entity.put("likes", 1);
        entity.put("tags", new JSONArray());
        entity.put("publishDate", new Date());
        entity.put("owner", new ParseObject("<YOUR_CLASS_NAME>"));
        entity.put("showComments", true);

        // All other fields will remain the same
        entity.saveInBackground();
      }
    }
  });
}
var query = PFQuery(className:"Post")

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error != nil {
    print(error)
  } else if parseObject != nil {
    parseObject["content"] = "A string"
    parseObject["likes"] = 1
    parseObject["tags"] = [1, "a string"]
    parseObject["publishDate"] = NSDate()
    parseObject["owner"] = PFObject(className:"<YOUR_CLASS_NAME>")
    parseObject["showComments"] = true

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

// Retrieve the object by id
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>"
                             block:^(PFObject *parseObject, NSError *error) {
    parseObject[@"content"] = @"A string";
    parseObject[@"likes"] = @1;
    parseObject[@"tags"] = @[@1, @"a string"];
    parseObject[@"publishDate"] = [NSDate date];
    parseObject[@"owner"] = [PFObject objectWithClassName:@"<YOUR_CLASS_NAME>"];
    parseObject[@"showComments"] = @YES;

    [parseObject saveInBackground];
}];
ParseQuery<ParseObject> query = ParseObject.GetQuery("Post");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
myObject["content"] = "A string";
myObject["likes"] = 1;
myObject["tags"] = new List<object>{1, "a string"};
myObject["publishDate"] = DateTime.Now;
myObject["owner"] = new ParseObject("<YOUR_CLASS_NAME>");
myObject["showComments"] = true;
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("content");
myObject.Remove("likes");
myObject.Remove("tags");
myObject.Remove("publishDate");
myObject.Remove("owner");
myObject.Remove("showComments");
await myObject.SaveAsync();
$query = new ParseQuery("Post");
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("content", "A string");
  $myCustomObject->set("likes", 1);
  $myCustomObject->set("tags", [1, "a string"]);
  $myCustomObject->set("publishDate", new DateTime());
  $myCustomObject->set("owner", new ParseObject("<YOUR_CLASS_NAME>"));
  $myCustomObject->set("showComments", true);

  // 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/Post/MyCurrentObjectId

Method

PUT

Headers

X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
https://parseapi.back4app.com/classes/Post/<OBJECT_ID>

Example Response:

{}

Code:

const Post = Parse.Object.extend('Post');
const query = new Parse.Query(Post);
// here you put the objectId that you want to delete
query.get('xKue915KBG').then((object) => {
  object.destroy().then((response) => {
    console.log(response);
  })
}, (error) => {
  console.error(error);
});

Example Output:

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

public void deleteObject() {
  // TODO: modify me!
  final boolean deleteAttributesOnly = true;

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

  // Retrieve the object by id
  query.getInBackground("<PARSE_OBJECT_ID>", new GetCallback<ParseObject>() {
    public void done(ParseObject entity, ParseException e) {
      if (e == null) {
        if (deleteAttributesOnly) {
          // If you want to undefine a specific field, do this:
          entity.remove("content");
          entity.remove("likes");
          entity.remove("tags");
          entity.remove("publishDate");
          entity.remove("owner");
          entity.remove("showComments");

          // Then save the changes
          entity.saveInBackground();
        } else {
          // Otherwise, you can delete the entire ParseObject from the database
          entity.deleteInBackground();
        }
      }
    }
  });
}
var deleteAttributesOnly = true

var query = PFQuery(className:"Post")

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error != nil {
    print(error)
  } else if parseObject != nil {
    if deleteAttributesOnly {
      parseObject.removeObjectForKey("content")
      parseObject.removeObjectForKey("likes")
      parseObject.removeObjectForKey("tags")
      parseObject.removeObjectForKey("publishDate")
      parseObject.removeObjectForKey("owner")
      parseObject.removeObjectForKey("showComments")
      parseObject.saveInBackground()
    } else {
      parseObject.deleteInBackground()
    }
  }
}
PFQuery *query = [PFQuery queryWithClassName:@"Post"];

// 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:@"content"];
  // [parseObject removeObjectForKey:@"likes"];
  // [parseObject removeObjectForKey:@"tags"];
  // [parseObject removeObjectForKey:@"publishDate"];
  // [parseObject removeObjectForKey:@"owner"];
  // [parseObject removeObjectForKey:@"showComments"];
  // 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("Post");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
await myObject.DeleteAsync();
$query = new ParseQuery("Post");
try {
  $myCustomObject = $query->get("<PARSE_OBJECT_ID>");
  // The object was retrieved successfully.

  // After this, the field will be empty
  $myCustomObject->delete("content");
  $myCustomObject->delete("likes");
  $myCustomObject->delete("tags");
  $myCustomObject->delete("publishDate");
  $myCustomObject->delete("owner");
  $myCustomObject->delete("showComments");
  // 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/Post/MyCurrentObjectId

Method

DELETE

Headers

X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

Success Response

Status

200 OK

Headers

content-type: application/json;

Body

An empty JSON object.

Error Response

Please check the Errors section.

MyCustomClass Class

Example JSON:

{
}

MyCustomClass is a custom class that was created and is specific for Back4Press. 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/MyCustomClass

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

Name Type Example

Creating Objects

Example Request:

curl -X POST \
-H "X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-H "Content-Type: application/json" \
-d "{  }" \
https://parseapi.back4app.com/classes/MyCustomClass

Example Response:

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

Code:

const MyCustomClass = Parse.Object.extend('MyCustomClass');
const myNewObject = new MyCustomClass();


myNewObject.save().then(
  (result) => {
    console.log(result);
  },
  (error) => {
    console.error(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("MyCustomClass");


  // Saves the new object.
  // Notice that the SaveCallback is totally optional!
  entity.saveInBackground(new SaveCallback() {
    @Override
    public void done(ParseException e) {
      // Here you can handle errors, if thrown. Otherwise, "e" should be null
    }
  });
}
var parseObject = PFObject(className:"MyCustomClass")


// 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:@"MyCustomClass"];


[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("MyCustomClass");
await myObject.SaveAsync();
$myCustomObject = new ParseObject("MyCustomClass");


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:

ParseObjectSubclass {
  className: 'MyCustomClass',
  _objCount: 0,
  id: '4BwpMWdCnm'
}

To create a new object of the MyCustomClass class, you'll need to send a POST request to the MyCustomClass 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/MyCustomClass

Method

POST

Headers

X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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/MyCustomClass/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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-G \
--data-urlencode "where={  }" \
https://parseapi.back4app.com/classes/MyCustomClass

Example Response:

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

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

Learn more about query parameters in queries section.

Code:

const MyCustomClass = Parse.Object.extend('MyCustomClass');
const query = new Parse.Query(MyCustomClass);
query.find().then((results) => {
  results.forEach((result) => {
    console.log();
  })
}, (error) => {
  console.error(error);
});

Example Output:


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("MyCustomClass");

  // 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>", new GetCallback<ParseObject>() {
    public void done(ParseObject result, ParseException e) {
      if (e == null) {
        System.out.println(result);
      } else {
        // something went wrong
      }
    }
  });
}
var query = PFQuery(className:"MyCustomClass")

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:@"MyCustomClass"];
[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("MyCustomClass");
ParseObject result = await query.GetAsync("<PARSE_OBJECT_ID>");
// Use the Get<T> method to get the values
$query = new ParseQuery("MyCustomClass");
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:
} 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/MyCustomClass

Method

GET

Headers

X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-H "Content-Type: application/json" \
-d "{  }" \
https://parseapi.back4app.com/classes/MyCustomClass/<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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-H "Content-Type: application/json" \
-d '{  }' \
https://parseapi.back4app.com/classes/MyCustomClass

Example Response:

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

Code:

const MyCustomClass = Parse.Object.extend('MyCustomClass');
const query = new Parse.Query(MyCustomClass);
// here you put the objectId that you want to update
query.get('xKue915KBG').then((object) => {
  object.save().then((response) => {
    console.log(response);
  })
}, (error) => {
  console.error(error);
});

Example Output:

ParseObjectSubclass { className: MyCustomClass, _objCount: 0, id: 'xKue915KBG' }

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

const MyCustomClass = Parse.Object.extend('MyCustomClass');
const query = new Parse.Query(MyCustomClass);
// here you put the objectId that you want to update
query.get('xKue915KBG').then((object) => {
  // After this, the myCustomKeyName field will be empty
  object.unset('');

  object.save().then((response) => {
    console.log(response);
  })
}, (error) => {
  console.error(error);
});

Example Output:

ParseObjectSubclass { className: 'MyCustomClass', _objCount: 0, id: 'xKue915KBG' }

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("MyCustomClass");

  // Retrieve the object by id
  query.getInBackground("<PARSE_OBJECT_ID>", new GetCallback<ParseObject>() {
    public void done(ParseObject entity, ParseException e) {
      if (e == null) {
        // Update the fields we want to

        // All other fields will remain the same
        entity.saveInBackground();
      }
    }
  });
}
var query = PFQuery(className:"MyCustomClass")

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

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

// Retrieve the object by id
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>"
                             block:^(PFObject *parseObject, NSError *error) {

    [parseObject saveInBackground];
}];
ParseQuery<ParseObject> query = ParseObject.GetQuery("MyCustomClass");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
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>");
await myObject.SaveAsync();
$query = new ParseQuery("MyCustomClass");
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

  // 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/MyCustomClass/MyCurrentObjectId

Method

PUT

Headers

X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
https://parseapi.back4app.com/classes/MyCustomClass/<OBJECT_ID>

Example Response:

{}

Code:

const MyCustomClass = Parse.Object.extend('MyCustomClass');
const query = new Parse.Query(MyCustomClass);
// here you put the objectId that you want to delete
query.get('xKue915KBG').then((object) => {
  object.destroy().then((response) => {
    console.log(response);
  })
}, (error) => {
  console.error(error);
});

Example Output:

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

public void deleteObject() {
  // TODO: modify me!
  final boolean deleteAttributesOnly = true;

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

  // Retrieve the object by id
  query.getInBackground("<PARSE_OBJECT_ID>", new GetCallback<ParseObject>() {
    public void done(ParseObject entity, ParseException e) {
      if (e == null) {
        if (deleteAttributesOnly) {
          // If you want to undefine a specific field, do this:

          // Then save the changes
          entity.saveInBackground();
        } else {
          // Otherwise, you can delete the entire ParseObject from the database
          entity.deleteInBackground();
        }
      }
    }
  });
}
var deleteAttributesOnly = true

var query = PFQuery(className:"MyCustomClass")

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:@"MyCustomClass"];

// Retrieve the object by id
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>" block:^(PFObject *parseObject, NSError *error) {
  // When using "removeObjectForKey", the field will be empty
  // 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("MyCustomClass");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
await myObject.DeleteAsync();
$query = new ParseQuery("MyCustomClass");
try {
  $myCustomObject = $query->get("<PARSE_OBJECT_ID>");
  // The object was retrieved successfully.

  // After this, the field will be empty
  // 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/MyCustomClass/MyCurrentObjectId

Method

DELETE

Headers

X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-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:

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

user.signUp().then((user) => {
    console.log(user);
}).catch(error => {
  console.error(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 protected]");

  // 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(new SignUpCallback() {
    public void done(ParseException 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
      }
    }
  });
}

func createUser() {
  var user = PFUser()
  user.username = "myUsername"
  user.password = "myPassword"
  user.email = "[email protected]"

  // 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 protected]";

// 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 protected]"
    };

    // 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 protected]");

// 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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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 GET \
-H "X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-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:

// Pass the username and password to logIn function
Parse.User.logIn("newUserName","#Password123").then((user) => {
  // Do stuff after successful login
  console.log(user);
}).catch(error => {
  console.error(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>", new LogInCallback() {
    public void done(ParseUser user, ParseException e) {
      if (user != null) {
        // Hooray! The user is logged in.
      } else {
        // Signup failed. Look at the ParseException to see what happened.
      }
    }
  });
}
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 GET 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

GET

Headers

X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]"}' \
https://parseapi.back4app.com/verificationEmailRequest

Example Response:

{}

Example Request:


const https = require('https');

const params = '{"email": "[email protected]"}';

const options = {
  hostname: 'https://parseapi.back4app.com',
  path: '/verificationEmailRequest',
  method: 'POST',
  headers: {
    'X-Parse-Application-Id': 'BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f',
    'X-Parse-REST-API-Key': 'swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w',
    '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();

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:

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

user.signUp()
  .then((user) => {
    user.logOut()
    console.log("Please verify your e-mail")
  })
  .catch(console.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 protected]");

  // 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(new SignUpCallback() {
    public void done(ParseException 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
      }
    }
  });
}

func createUser() {
  var user = PFUser()
  user.username = "myUsername"
  user.password = "myPassword"
  user.email = "[email protected]"

  // 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 protected]";

// 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 protected]"
    };

    // 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 protected]");

// 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:

// Pass the username and password to logIn function
Parse.User.logIn("newUserName","#Password123").then((user) => {
  if (user.get('emailVerified')) {
    console.log(user);
  } else {
   user.logOut();
   console.log("Please Verify Your Email first");
  }
}).catch(console.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>", new LogInCallback() {
    public void done(ParseUser user, ParseException 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 {
        // Signup failed. Look at the ParseException to see what happened.
      }
    }
  });
}
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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]"}' \
https://parseapi.back4app.com/requestPasswordReset

Example Response:

{}

Code:

// Pass the username and password to logIn function
Parse.User.requestPasswordReset("[email protected]").then((response) => {
  // Password reset request was sent successfully
  console.log(response);
}).catch((error) => {
  console.error(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("[email protected]", new RequestPasswordResetCallback() {
    public void done(ParseException 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 protected]")
[PFUser requestPasswordResetForEmailInBackground:@"[email protected]"];
// An e-mail will be sent with further instructions
await ParseUser.RequestPasswordResetAsync("[email protected]");
ParseUser::requestVerificationEmail('[email protected]');

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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-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:

const currentUser = Parse.User.current();
if (currentUser) {
    console.log(currentUser);
} else {
    // show the signup or login page
}

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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
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:

const User = new Parse.User();
const query = new Parse.Query(User);

query.get('hEPjkt4epS').then((user) => {
  console.log(user);
}, (error) => {
  console.error(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 protected]");
  query.findInBackground(new FindCallback<ParseUser>() {
    public void done(List<ParseUser> users, ParseException e) {
      if (e == null) {
        // The query was successful, returns the users that matches
        // the criterias.
        for(ParseUser user : users) {
            System.out.println(user.getUsername());
        }
      } else {
        // Something went wrong.
      }
    }
  });
}
var query = PFUser.query()
query.whereKey("email", equalTo:"[email protected]")
var users = query.findObjects()
PFQuery *query = [PFUser query];
[query whereKey:@"email" equalTo:@"[email protected]"];
NSArray *users = [query findObjects];
var user = await ParseUser.Query
    .WhereEqualTo("Email", "[email protected]")
    .FindAsync();
$query = ParseUser::query();
$query->equalTo("email", "[email protected]");

// 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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-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:

const user = Parse.User.current();
object.set('username', 'A string');
object.set('email', 'A string');
user.save().then((response) => {
  console.log(response);
}).catch(error) => {
  console.error(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", "[email protected]");

    // Saves the object.
    // Notice that the SaveCallback is totally optional!
    currentUser.saveInBackground(new SaveCallback() {
      @Override
      public void done(ParseException e) {
        // Here you can handle errors, if thrown. Otherwise, "e" should be null
      }
    });
  }
}
var currentUser = PFUser.currentUser()
if currentUser != nil {
  currentUser["email"] = "[email protected]"

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

  [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", "[email protected]");

  // 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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-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:

const user = Parse.User.current();
user.destroy().then((response) => {
    console.log(response);
  })
}, (error) => {
  console.error(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(new DeleteCallback() {
      @Override
      public void done(ParseException e) {
        // Here you can handle errors, if thrown. Otherwise, "e" should be null
      }
    });
  }
}
// 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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f

X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w

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:

const MyCustomClass = Parse.Object.extend("MyCustomClass");

// Creates a new Query object to help us fetch MyCustomClass objects
const query = new Parse.Query(MyCustomClass);

// Executes the query, which returns an array of MyCustomClass
const results = await query.find();
curl -X GET \
  -H "X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
  -H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
  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 static 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(new FindCallback<ParseObject>() {
    public void done(List<ParseObject> results, ParseException e) {
      // do some stuff with results
      if (results != null) {
        for (ParseObject result : results) {
          System.out.println("Object found asynchronously " + result.getObjectId());
        }
      } else if (e != null) {
        e.printStackTrace();
      }
    }
  });
}
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:

var MyCustomClass = Parse.Object.extend("MyCustomClass");
var query = new Parse.Query(MyCustomClass);

// Uses "count" instead of "find" to retrieve the number of objects
const count = await query.count();
alert(count + " objects found!");
curl -X GET \
  -H "X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
  -H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
  -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 static void runQuery() {
  ParseQuery<ParseObject> query = ParseQuery.getQuery("MyCustomClass");

  // Fetches count synchronously
  try {
    query.count();
  } catch (ParseException e) {
    e.printStackTrace();
  }

  // Or use the the non-blocking method countInBackground method with a CountCallback
  query.countInBackground(new CountCallback() {
    public void done(int count, ParseException e) {
      if (e == null) {
        System.out.println("Count", count + " objects found!");
      } else {
        System.out.println("Count", "Error: " + e.getMessage());
      }
    }
  });
}
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:

const query = new Parse.Query("User");

// Returns unique emails
const uniqueEmails = await query.distinct("email");

Example request:

curl -X GET \
  -H "X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
  -H "X-Parse-Master-Key: 5AVAtvlGlG5cEeolatkFDhY5p99PzoBUvm7MBLMo" \
  -H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
  -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:

// "Post" is just an arbitrary class, replace it with your custom class
const Post = Parse.Object.extend("Post");
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');

const results = await query.find();
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 static 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");

  try {
    List<ParseObject> results = query.find();
    for (ParseObject result : results) {
      System.out.println("Object found " + result.getObjectId());
    }
  } catch (ParseException e) {
    e.printStackTrace();
  }
}
// "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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
  -H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
  -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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
  -H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
  -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:

// "Post" is just an arbitrary class, replace it with your custom class
const Post = Parse.Object.extend("Post");
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");

const results = await query.find();

Example request:

curl -X GET \
  -H "X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
  -H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
  -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 static 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");

  try {
    List<ParseObject> results = query.find();
    for (ParseObject result : results) {
      System.out.println("Likes " + result.get("likes").toString() + " Views " + result.get("views"));
    }
  } catch (ParseException e) {
    e.printStackTrace();
  }
}
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:

// "Post" is just an arbitrary class, replace it with your custom class
const Post = Parse.Object.extend("Post");
const query = new Parse.Query(Post);

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

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

const results = await query.find();
# Finds 10 Posts, skipping the first 100 results
curl -X GET \
  -H "X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
  -H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
  -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 static 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

  try {
    List<ParseObject> results = query.find();
    for (ParseObject result : results) {
      System.out.println("Object found " + result.getObjectId());
    }
  } catch (ParseException e) {
    e.printStackTrace();
  }
}
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:

// Creates the Post
const Post = Parse.Object.extend("Post");
const myPost = new Post();
myPost.set('content', 'First post! Yay!');
await myPost.save();

// Creates the Comment
const Comment = Parse.Object.extend("Comment");
const myComment = new Comment();
myComment.set('content', 'Congrats!');
myComment.set('post', myPost); // Sets "myPost" and its post
await myComment.save();

// Finds only the comments that has "myPost" as a post
const query = new Parse.Query(Comment);
query.equalTo("post", myPost);
const comments = await query.find();
# Creates the Post
curl -X POST \
-H "X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-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 static 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);
  List<ParseObject> results = query.find();
  for (ParseObject result : results) {
    System.out.println("Object found " + result.getObjectId());
  }
}
// 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:

// ... creates the query out of a class that have a relation with Post
const Post = Parse.Object.extend("Post");
const myPost = new Post();
myPost.id = "<OBJECT_ID>";

// Just the objectId is enough to compare the object
query.equalTo("post", myPost);

// ... 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 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:

const Post = Parse.Object.extend("Post");
const innerQuery = new Parse.Query(Post);
innerQuery.exists("image");

const Comment = Parse.Object.extend("Comment");
const query = new Parse.Query(Comment);
query.matchesQuery("post", innerQuery); // Uses the innerQuery to apply constraints to the "post" field

// Fetches only the comments whose posts contains image
const comments = await query.find();
# Fetches only the comments whose posts contains image
curl -X GET \
-H "X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-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 static void runQuery() {
  ParseQuery<ParseObject> innerQuery = ParseQuery.getQuery("Post");
  innerQuery.whereExists("image");

  ParseQuery<ParseObject> query = ParseQuery.getQuery("Comment");
  query.whereMatchesQuery("post", innerQuery);

  try {
    List<ParseObject> commentList = query.find();
    for (ParseObject comment : commentList) {
      ParseObject post = comment.getParseObject("post");
      System.out.println("Object found " + post.getObjectId());
    }
  } catch (ParseException e) {
    e.printStackTrace();
  }
}
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):

const Post = Parse.Object.extend("Post");
const innerQuery = new Parse.Query(Post);
innerQuery.greaterThan("likes", 50);

const Comment = Parse.Object.extend("Comment");
const query = new Parse.Query(Comment);
// Uses the innerQuery to apply constraints to the "post" field
query.doesNotMatchQuery("post", innerQuery);

// Fetches only the comments whose posts does NOT contains more than 50 likes
const comments = await query.find();
# Fetches only the comments whose posts does NOT contains more than 50 likes
curl -X GET \
-H "X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-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 static void runQuery() {
  ParseQuery<ParseObject> innerQuery = ParseQuery.getQuery("Post");
  innerQuery.whereGreaterThan("likes", 50);

  ParseQuery<ParseObject> query = ParseQuery.getQuery("Comment");
  query.whereDoesNotMatchQuery("post", innerQuery);

  try {
    List<ParseObject> commentList = query.find();
    for (ParseObject comment : commentList) {
      ParseObject post = comment.getParseObject("post");
      System.out.println("Object found " + post.getObjectId());
    }
  } catch (ParseException e) {
    e.printStackTrace();
  }
}
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:

const Comment = Parse.Object.extend("Comment");
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

// Comments now contains the "post" field initialized!
const comments = await query.find();
const posts = comments.map(function (comment) {
  return comment.get('post');
});
curl -X GET \
-H "X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-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 static 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");

  try {
    List<ParseObject> commentList = query.find();
    for (ParseObject comment : commentList) {
      // This does not require a network access.
      ParseObject post = comment.getParseObject("post");
      System.out.println("Object found " + post.getObjectId());
    }
  } catch (ParseException e) {
    e.printStackTrace();
  }
}
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:

// "Post" is just an arbitrary class, replace it with your custom class
const Post = Parse.Object.extend("Post");

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);

// Fetches the posts with more than 1000 likes OR posts with the title "My great post"
const posts = await composedQuery.find();
curl -X GET \
-H "X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-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 static 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);

  try {
    // Fetches the posts with more than 1000 likes OR posts with the title "My great post"
    List<ParseObject> postList = mainQuery.find();
    for (ParseObject post : postList) {
      System.out.println("Object found " + post.getObjectId());
    }
  } catch (ParseException e) {
    e.printStackTrace();
  }
}
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:

// "Post" is just an arbitrary class, replace it with your custom class
const Post = Parse.Object.extend("Post");

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
);

// 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();
# 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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-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 static 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
  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
    List<ParseObject> postList = mainQuery.find();
    for (ParseObject post : postList) {
      System.out.println("Object found " + post.getObjectId());
    }
  } catch (ParseException e) {
    e.printStackTrace();
  }
}
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:

// "Post" is just an arbitrary class, replace it with your custom class
const Post = Parse.Object.extend("Post");
const query = new Parse.Query(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
const pipeline = {
  group: { objectId: '$content' }
};

const results = await query.aggregate(pipeline);
// results contains unique content values
// The results are similar to the distinct feature
# 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: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-H "X-Parse-Master-Key: 5AVAtvlGlG5cEeolatkFDhY5p99PzoBUvm7MBLMo" \
-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:

// "Post" is just an arbitrary class, replace it with your custom class
const Post = Parse.Object.extend("Post");
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

const results = query.aggregate(pipeline);
// results[0] should contain "total", "average", "maxLikes" and "minLikes" as attribute
// You can access them like this: results[0].total
curl -X GET \
-H "X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-H "X-Parse-Master-Key: 5AVAtvlGlG5cEeolatkFDhY5p99PzoBUvm7MBLMo" \
-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