NAV Navbar

ToDoListApp

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

Introduction

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

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

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

Getting Started

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

Installing Parse SDK

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

Install Parse JavaScript SDK npm module:

npm install parse

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

For a React Native project:

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

In a Node.js project:

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

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

Install Parse JavaScript SDK npm module:

npm install parse
npm install @types/parse

For a React Native project:

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

In a Node.js project:

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

Parse.serverURL = 'https://parseapi.back4app.com'; // This is your Server URL
// Remember to inform BOTH the Back4App Application ID AND the JavaScript KEY
Parse.initialize(
  '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 order to install the Parse-SDK-Android as a Gradle dependency, add this in your root build.gradle file (not your module build.gradle file!)

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

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

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

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

There are a plenty of ways to install Parse SDK:

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

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

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

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

pod 'Parse'
pod 'Parse'

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

Option 3: Downloading the latest build here.

Option 4: Cloning the project and compiling manually:

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

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

# To install all the gems
bundle install

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

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

# To install all the gems
bundle install

# Build & Package the Frameworks
rake package:frameworks

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

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

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

Or install a specific release from SDK repository

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

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

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

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

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

composer install

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

require 'vendor/autoload.php';

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

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

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

require 'autoload.php';

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

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

Installing JavaScript SDK

Installing JavaScript SDK using TypeScript

Installing Android SDK

Installing iOS SDK (Swift)

Installing iOS SDK (Objective-C)

Installing PHP SDK

Installing .NET SDK

Initializing Parse SDK

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

curl -X GET \
-H "X-Parse-Application-Id: 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 REST API directly from your client-side code, you must use the Parse Client Key for your currently client-side platform (e.g. Client Key for iOS/Android, or .NET Key for Windows/Xamarin/Unity).

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

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

//Before using the SDK...
Parse.setAsyncStorage(AsyncStorage);
// Remember to inform BOTH the Back4App Application ID AND the JavaScript KEY
Parse.initialize('BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f', '4wPYRKbpTJeCdmFNaS31AiQZ8344aaYubk6Uo8VW');
//Point to Back4App Parse API address 
Parse.serverURL = 'https://parseapi.back4app.com'

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

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

<script>
Parse.serverURL = 'https://parseapi.back4app.com'; // This is your Server URL
// Remember to inform BOTH the Back4App Application ID AND the JavaScript KEY
Parse.initialize(
  'BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f', // This is your Application ID
  '4wPYRKbpTJeCdmFNaS31AiQZ8344aaYubk6Uo8VW' // This is your Javascript key
);
</script>

In an Ionic project:

const Parse = require('parse');

Parse.serverURL = 'https://parseapi.back4app.com'; // This is your Server URL
// Remember to inform BOTH the Back4App Application ID AND the JavaScript KEY
Parse.initialize(
  'BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f', // This is your Application ID
  '4wPYRKbpTJeCdmFNaS31AiQZ8344aaYubk6Uo8VW' // This is your Javascript key
);

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

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

//Before using the SDK...
Parse.setAsyncStorage(AsyncStorage);
// Remember to inform BOTH the Back4App Application ID AND the JavaScript KEY
Parse.initialize('BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f', '4wPYRKbpTJeCdmFNaS31AiQZ8344aaYubk6Uo8VW');
//Point to Back4App Parse API address 
Parse.serverURL = 'https://parseapi.back4app.com'

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

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

<script>
Parse.serverURL = 'https://parseapi.back4app.com'; // This is your Server URL
// Remember to inform BOTH the Back4App Application ID AND the JavaScript KEY
Parse.initialize(
  'BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f', // This is your Application ID
  '4wPYRKbpTJeCdmFNaS31AiQZ8344aaYubk6Uo8VW' // This is your Javascript key
);
</script>

In an Ionic project:

const Parse = require('parse');

Parse.serverURL = 'https://parseapi.back4app.com'; // This is your Server URL
// Remember to inform BOTH the Back4App Application ID AND the JavaScript KEY
Parse.initialize(
  'BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f', // This is your Application ID
  '4wPYRKbpTJeCdmFNaS31AiQZ8344aaYubk6Uo8VW' // This is your Javascript key
);

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

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

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

package <YOUR_PACKAGE_NAME>;

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

public class YOUR_ANDROID_APPLICATION extends Application {

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

    Parse.initialize(new Parse.Configuration.Builder(this)
      .applicationId("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)
}

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

// AppDelegate.m
[Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration>  _Nonnull configuration) {
  configuration.applicationId = @"BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f";
  configuration.clientKey = @"rWFPEbTs7UzkaVsIXnQ4qmmr9oWqwXfiiJehtIZu";
  configuration.server = @"https://parseapi.back4app.com";
}]];

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

using Parse;

ParseClient.Initialize(new ParseClient.Configuration {
    ApplicationId = "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 '{"myCustomKey1Name":"myCustomKey1Value","myCustomKey2Name":"myCustomKey2Value"}' \
https://parseapi.back4app.com/classes/MyCustomClassName

Example Response:

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

Code:

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

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

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

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

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

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

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

$myCustomObject = new ParseObject("MyCustomClassName");

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

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

Example Output:

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

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

Request

URL

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

Method

POST

Headers

X-Parse-Application-Id: 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:

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

Example Output:

myCustomKey1Value
myCustomKey2Value

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

Learn more about query parameters in queries section.

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

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

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

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

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

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

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

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

Request

URL

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

Method

GET

Headers

X-Parse-Application-Id: 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:

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

Example Output:

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

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

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

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

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

Example Output:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Request

URL

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

Method

PUT

Headers

X-Parse-Application-Id: 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:

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

Example Output:

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

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

var query = PFQuery(className:"")

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

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

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

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

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

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

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

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

Request

URL

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

Method

DELETE

Headers

X-Parse-Application-Id: 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\": \"<YOUR_CLASS_NAME>\" },
  \"geopointExample\": { \"__type\": \"GeoPoint\", \"latitude\": 40.0, \"longitude\": -30.0 },
  \"polygonExample\": {\"__type\":\"Polygon\",\"coordinates\":[[0,0],[0,1],[1,0]]}
}

const stringExample = 'A string';

const numberExample = 1;

const booleanExample = true;

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

const objectExample = { foo: 'bar' };

const dateExample = new Date();

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

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

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

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

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

String stringExample = "A string";

int numberExample = 1;

boolean booleanExample = true;

JSONArray arrayExample = new JSONArray();

JSONObject objectExample = new JSONObject();

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

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

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

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

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

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

var stringExample = "A string"

var numberExample = 1

var booleanExample = true

var arrayExample = [1, "a string"]

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

var dateExample = NSDate()

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

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

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

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

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

NSString stringExample = @"A string";

NSNumber numberExample = @1;

NSNumber booleanExample = @YES;

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

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

NSDate dateExample = [NSDate date];

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

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

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

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

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

$stringExample = "A string"

$numberExample = 1

$booleanExample = true

$arrayExample = [1, "a string"]

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

$dateExample = new DateTime()

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

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

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

$geopointExample = new ParseGeoPoint(40.0, -30.0)

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

string stringExample = "A string";

int numberExample = 1;

bool booleanExample = true;

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

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

DateTime dateExample = DateTime.Now;

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

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

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

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

//  polygonExample = <NOT_AVAILABLE>;

Project Class

Example JSON:

{
  "name": "A string",
  "firstName": "A string",
  "lastName": "A string",
  "AverageGrade": 1,
  "duration": 1,
  "fees": 1,
  "level": "A string"
}

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

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

Name Type Example
name String "A string"
firstName String "A string"
lastName String "A string"
AverageGrade Number 1
duration Number 1
fees Number 1
level String "A string"

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 "{ \"name\":\"A string\",\"firstName\":\"A string\",\"lastName\":\"A string\",\"AverageGrade\":1,\"duration\":1,\"fees\":1,\"level\":\"A string\" }" \
https://parseapi.back4app.com/classes/Project

Example Response:

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

Code:

(async () => {
  const myNewObject = new Parse.Object('Project');
  myNewObject.set('name', 'A string');
  myNewObject.set('firstName', 'A string');
  myNewObject.set('lastName', 'A string');
  myNewObject.set('AverageGrade', 1);
  myNewObject.set('duration', 1);
  myNewObject.set('fees', 1);
  myNewObject.set('level', 'A string');
  try {
    const result = await myNewObject.save();
    // Access the Parse Object attributes using the .GET method
    console.log('Project created', result);
  } catch (error) {
    console.error('Error while creating Project: ', error);
  }
})();
(async () => {
  const myNewObject: Parse.Object = new Parse.Object('Project');
  myNewObject.set('name', 'A string');
  myNewObject.set('firstName', 'A string');
  myNewObject.set('lastName', 'A string');
  myNewObject.set('AverageGrade', 1);
  myNewObject.set('duration', 1);
  myNewObject.set('fees', 1);
  myNewObject.set('level', 'A string');
  try {
    const result: Parse.Object = await myNewObject.save();
    // Access the Parse Object attributes using the .GET method
    console.log('Project created', result);
  } catch (error: any) {
    console.error('Error while creating Project: ', 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("Project");

  entity.put("name", "A string");
  entity.put("firstName", "A string");
  entity.put("lastName", "A string");
  entity.put("AverageGrade", 1);
  entity.put("duration", 1);
  entity.put("fees", 1);
  entity.put("level", "A string");

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

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

parseObject["name"] = "A string"
parseObject["firstName"] = "A string"
parseObject["lastName"] = "A string"
parseObject["AverageGrade"] = 1
parseObject["duration"] = 1
parseObject["fees"] = 1
parseObject["level"] = "A string"

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

parseObject[@"name"] = @"A string";
parseObject[@"firstName"] = @"A string";
parseObject[@"lastName"] = @"A string";
parseObject[@"AverageGrade"] = @1;
parseObject[@"duration"] = @1;
parseObject[@"fees"] = @1;
parseObject[@"level"] = @"A string";

[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("Project");
myObject["name"] = "A string";
myObject["firstName"] = "A string";
myObject["lastName"] = "A string";
myObject["AverageGrade"] = 1;
myObject["duration"] = 1;
myObject["fees"] = 1;
myObject["level"] = "A string";
await myObject.SaveAsync();
$myCustomObject = new ParseObject("Project");

$myCustomObject->set("name", "A string");
$myCustomObject->set("firstName", "A string");
$myCustomObject->set("lastName", "A string");
$myCustomObject->set("AverageGrade", 1);
$myCustomObject->set("duration", 1);
$myCustomObject->set("fees", 1);
$myCustomObject->set("level", "A string");

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

Example Output:

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

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

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/Project/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={ \"name\":\"A string\",\"firstName\":\"A string\",\"lastName\":\"A string\",\"AverageGrade\":1,\"duration\":1,\"fees\":1,\"level\":\"A string\" }" \
https://parseapi.back4app.com/classes/Project

Example Response:

{
  "results": [
    {
      "objectId": "zJxVP17mTi",
      "createdAt": "2018-10-31T14:16:13.616Z",
      "updatedAt": "2018-11-07T12:12:20.758Z",
      "name": \"A string\","firstName": \"A string\","lastName": \"A string\","AverageGrade": 1,"duration": 1,"fees": 1,"level": \"A string\"
    },
    {
      "objectId": "yDbv0gKGJR",
      "createdAt": "2018-10-31T14:16:42.811Z",
      "updatedAt": "2018-11-07T12:12:18.543Z",
      "name": \"A string\","firstName": \"A string\","lastName": \"A string\","AverageGrade": 1,"duration": 1,"fees": 1,"level": \"A string\"
    },
    {
      "objectId": "xKue915KBG",
      "createdAt": "2018-11-07T12:11:58.533Z",
      "updatedAt": "2018-11-07T12:12:15.413Z",
      "name": \"A string\","firstName": \"A string\","lastName": \"A string\","AverageGrade": 1,"duration": 1,"fees": 1,"level": \"A string\"
    }
  ]
}

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

Learn more about query parameters in queries section.

Code:

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

Example Output:

'A string' 'A string' 'A string' 1 1 1 'A string' 

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

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

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:@"Project"];
[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("Project");
ParseObject result = await query.GetAsync("<PARSE_OBJECT_ID>");
// Use the Get<T> method to get the values
string name = result.Get<string>("name");
string firstName = result.Get<string>("firstName");
string lastName = result.Get<string>("lastName");
int AverageGrade = result.Get<int>("AverageGrade");
int duration = result.Get<int>("duration");
int fees = result.Get<int>("fees");
string level = result.Get<string>("level");
$query = new ParseQuery("Project");
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:
  $name = $myCustomObject->get("name");
  $firstName = $myCustomObject->get("firstName");
  $lastName = $myCustomObject->get("lastName");
  $AverageGrade = $myCustomObject->get("AverageGrade");
  $duration = $myCustomObject->get("duration");
  $fees = $myCustomObject->get("fees");
  $level = $myCustomObject->get("level");
} 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/Project

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 "{ \"name\": \"A string\",\"firstName\": \"A string\",\"lastName\": \"A string\",\"AverageGrade\": 1,\"duration\": 1,\"fees\": 1,\"level\": \"A string\" }" \
https://parseapi.back4app.com/classes/Project/<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 '{ "name": {"__op":"Delete"},"firstName": {"__op":"Delete"},"lastName": {"__op":"Delete"},"AverageGrade": {"__op":"Delete"},"duration": {"__op":"Delete"},"fees": {"__op":"Delete"},"level": {"__op":"Delete"} }' \
https://parseapi.back4app.com/classes/Project

Example Response:

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

Code:

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

Example Output:


name
firstName
lastName
AverageGrade
duration
fees
level
Project updated
{
  className: Project,
   _objCount: 0,
   id: 'xKue915KBG'
}

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

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

Example Output:

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

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

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

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

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

  // Retrieve the object by id
  query.getInBackground("<PARSE_OBJECT_ID>", (object, e) -> {
    if (e == null) {
      //Object was successfully retrieved
      // Update the fields we want to
      object.put("name", "A string");
      object.put("firstName", "A string");
      object.put("lastName", "A string");
      object.put("AverageGrade", 1);
      object.put("duration", 1);
      object.put("fees", 1);
      object.put("level", "A string");

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

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

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

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error != nil {
    print(error)
  } else if parseObject != nil {
    parseObject["name"] = "A string"
    parseObject["firstName"] = "A string"
    parseObject["lastName"] = "A string"
    parseObject["AverageGrade"] = 1
    parseObject["duration"] = 1
    parseObject["fees"] = 1
    parseObject["level"] = "A string"

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

// Retrieve the object by id
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>"
                             block:^(PFObject *parseObject, NSError *error) {
    parseObject[@"name"] = @"A string";
    parseObject[@"firstName"] = @"A string";
    parseObject[@"lastName"] = @"A string";
    parseObject[@"AverageGrade"] = @1;
    parseObject[@"duration"] = @1;
    parseObject[@"fees"] = @1;
    parseObject[@"level"] = @"A string";

    [parseObject saveInBackground];
}];
ParseQuery<ParseObject> query = ParseObject.GetQuery("Project");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
myObject["name"] = "A string";
myObject["firstName"] = "A string";
myObject["lastName"] = "A string";
myObject["AverageGrade"] = 1;
myObject["duration"] = 1;
myObject["fees"] = 1;
myObject["level"] = "A string";
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("name");
myObject.Remove("firstName");
myObject.Remove("lastName");
myObject.Remove("AverageGrade");
myObject.Remove("duration");
myObject.Remove("fees");
myObject.Remove("level");
await myObject.SaveAsync();
$query = new ParseQuery("Project");
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("name", "A string");
  $myCustomObject->set("firstName", "A string");
  $myCustomObject->set("lastName", "A string");
  $myCustomObject->set("AverageGrade", 1);
  $myCustomObject->set("duration", 1);
  $myCustomObject->set("fees", 1);
  $myCustomObject->set("level", "A string");

  // 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/Project/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/Project/<OBJECT_ID>

Example Response:

{}

Code:

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

Example Output:

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

public void deleteObject() {

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

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

}
var deleteAttributesOnly = true

var query = PFQuery(className:"Project")

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error != nil {
    print(error)
  } else if parseObject != nil {
    if deleteAttributesOnly {
      parseObject.removeObjectForKey("name")
      parseObject.removeObjectForKey("firstName")
      parseObject.removeObjectForKey("lastName")
      parseObject.removeObjectForKey("AverageGrade")
      parseObject.removeObjectForKey("duration")
      parseObject.removeObjectForKey("fees")
      parseObject.removeObjectForKey("level")
      parseObject.saveInBackground()
    } else {
      parseObject.deleteInBackground()
    }
  }
}
PFQuery *query = [PFQuery queryWithClassName:@"Project"];

// 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:@"name"];
  // [parseObject removeObjectForKey:@"firstName"];
  // [parseObject removeObjectForKey:@"lastName"];
  // [parseObject removeObjectForKey:@"AverageGrade"];
  // [parseObject removeObjectForKey:@"duration"];
  // [parseObject removeObjectForKey:@"fees"];
  // [parseObject removeObjectForKey:@"level"];
  // 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("Project");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
await myObject.DeleteAsync();
$query = new ParseQuery("Project");
try {
  $myCustomObject = $query->get("<PARSE_OBJECT_ID>");
  // The object was retrieved successfully.

  // After this, the field will be empty
  $myCustomObject->delete("name");
  $myCustomObject->delete("firstName");
  $myCustomObject->delete("lastName");
  $myCustomObject->delete("AverageGrade");
  $myCustomObject->delete("duration");
  $myCustomObject->delete("fees");
  $myCustomObject->delete("level");
  // 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/Project/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.

ToDo Class

Example JSON:

{
  "title": "A string",
  "url": "A string",
  "isCompleted": true,
  "schedule": "2018-11-12T13:13:45.958Z",
  "order": 1,
  "description": "A string",
  "attachmentt": { "__type": "File", "name": "resume.txt" },
  "project": { "__type": "Pointer", "className": "Project", "objectId": "<THE_REFERENCED_OBJECT_ID>" },
  "name": "A string",
  "attachment": { "__type": "File", "name": "resume.txt" },
  "task": "A string",
  "Nombre": "A string",
  "edad": "A string",
  "correo": "A string",
  "matricula": "A string",
  "Edad": "A string",
  "Matricula": "A string",
  "nombre": "A string",
  "Correo": "A string",
  "query": "A string"
}

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

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

Name Type Example
title String "A string"
url String "A string"
isCompleted Boolean true
schedule Date "2018-11-12T13:13:45.958Z"
order Number 1
description String "A string"
attachmentt File { "__type": "File", "name": "resume.txt" }
project Pointer { "__type": "Pointer", "className": "Project", "objectId": "<THE_REFERENCED_OBJECT_ID>" }
name String "A string"
attachment File { "__type": "File", "name": "resume.txt" }
task String "A string"
Nombre String "A string"
edad String "A string"
correo String "A string"
matricula String "A string"
Edad String "A string"
Matricula String "A string"
nombre String "A string"
Correo String "A string"
query String "A string"

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 "{ \"title\":\"A string\",\"url\":\"A string\",\"isCompleted\":true,\"schedule\":{ \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },\"order\":1,\"description\":\"A string\",\"attachmentt\":{ \"__type\": \"File\", \"name\": \"resume.txt\" },\"project\":{ \"__type\": \"Pointer\", \"className\": \"Project\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" },\"name\":\"A string\",\"attachment\":{ \"__type\": \"File\", \"name\": \"resume.txt\" },\"task\":\"A string\",\"Nombre\":\"A string\",\"edad\":\"A string\",\"correo\":\"A string\",\"matricula\":\"A string\",\"Edad\":\"A string\",\"Matricula\":\"A string\",\"nombre\":\"A string\",\"Correo\":\"A string\",\"query\":\"A string\" }" \
https://parseapi.back4app.com/classes/ToDo

Example Response:

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

Code:

(async () => {
  const myNewObject = new Parse.Object('ToDo');
  myNewObject.set('title', 'A string');
  myNewObject.set('url', 'A string');
  myNewObject.set('isCompleted', true);
  myNewObject.set('schedule', new Date());
  myNewObject.set('order', 1);
  myNewObject.set('description', 'A string');
  myNewObject.set('attachmentt', new Parse.File("resume.txt", { base64: btoa("My file content") }));
  myNewObject.set('project', new Parse.Object("Project"));
  myNewObject.set('name', 'A string');
  myNewObject.set('attachment', new Parse.File("resume.txt", { base64: btoa("My file content") }));
  myNewObject.set('task', 'A string');
  myNewObject.set('Nombre', 'A string');
  myNewObject.set('edad', 'A string');
  myNewObject.set('correo', 'A string');
  myNewObject.set('matricula', 'A string');
  myNewObject.set('Edad', 'A string');
  myNewObject.set('Matricula', 'A string');
  myNewObject.set('nombre', 'A string');
  myNewObject.set('Correo', 'A string');
  myNewObject.set('query', 'A string');
  try {
    const result = await myNewObject.save();
    // Access the Parse Object attributes using the .GET method
    console.log('ToDo created', result);
  } catch (error) {
    console.error('Error while creating ToDo: ', error);
  }
})();
(async () => {
  const myNewObject: Parse.Object = new Parse.Object('ToDo');
  myNewObject.set('title', 'A string');
  myNewObject.set('url', 'A string');
  myNewObject.set('isCompleted', true);
  myNewObject.set('schedule', new Date());
  myNewObject.set('order', 1);
  myNewObject.set('description', 'A string');
  myNewObject.set('attachmentt', new Parse.File("resume.txt", { base64: btoa("My file content") }));
  myNewObject.set('project', new Parse.Object("Project"));
  myNewObject.set('name', 'A string');
  myNewObject.set('attachment', new Parse.File("resume.txt", { base64: btoa("My file content") }));
  myNewObject.set('task', 'A string');
  myNewObject.set('Nombre', 'A string');
  myNewObject.set('edad', 'A string');
  myNewObject.set('correo', 'A string');
  myNewObject.set('matricula', 'A string');
  myNewObject.set('Edad', 'A string');
  myNewObject.set('Matricula', 'A string');
  myNewObject.set('nombre', 'A string');
  myNewObject.set('Correo', 'A string');
  myNewObject.set('query', 'A string');
  try {
    const result: Parse.Object = await myNewObject.save();
    // Access the Parse Object attributes using the .GET method
    console.log('ToDo created', result);
  } catch (error: any) {
    console.error('Error while creating ToDo: ', 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("ToDo");

  entity.put("title", "A string");
  entity.put("url", "A string");
  entity.put("isCompleted", true);
  entity.put("schedule", new Date());
  entity.put("order", 1);
  entity.put("description", "A string");
  entity.put("attachmentt", new ParseFile("resume.txt", "My string content".getBytes()));
  entity.put("project", new ParseObject("Project"));
  entity.put("name", "A string");
  entity.put("attachment", new ParseFile("resume.txt", "My string content".getBytes()));
  entity.put("task", "A string");
  entity.put("Nombre", "A string");
  entity.put("edad", "A string");
  entity.put("correo", "A string");
  entity.put("matricula", "A string");
  entity.put("Edad", "A string");
  entity.put("Matricula", "A string");
  entity.put("nombre", "A string");
  entity.put("Correo", "A string");
  entity.put("query", "A string");

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

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

parseObject["title"] = "A string"
parseObject["url"] = "A string"
parseObject["isCompleted"] = true
parseObject["schedule"] = NSDate()
parseObject["order"] = 1
parseObject["description"] = "A string"
parseObject["attachmentt"] = PFFile(name:"resume.txt", data:"My string content".dataUsingEncoding(NSUTF8StringEncoding))
parseObject["project"] = PFObject(className:"Project")
parseObject["name"] = "A string"
parseObject["attachment"] = PFFile(name:"resume.txt", data:"My string content".dataUsingEncoding(NSUTF8StringEncoding))
parseObject["task"] = "A string"
parseObject["Nombre"] = "A string"
parseObject["edad"] = "A string"
parseObject["correo"] = "A string"
parseObject["matricula"] = "A string"
parseObject["Edad"] = "A string"
parseObject["Matricula"] = "A string"
parseObject["nombre"] = "A string"
parseObject["Correo"] = "A string"
parseObject["query"] = "A string"

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

parseObject[@"title"] = @"A string";
parseObject[@"url"] = @"A string";
parseObject[@"isCompleted"] = @YES;
parseObject[@"schedule"] = [NSDate date];
parseObject[@"order"] = @1;
parseObject[@"description"] = @"A string";
parseObject[@"attachmentt"] = [PFFile fileWithName:@"resume.txt" data: [@"My string content" dataUsingEncoding:NSUTF8StringEncoding]];
parseObject[@"project"] = [PFObject objectWithClassName:@"Project"];
parseObject[@"name"] = @"A string";
parseObject[@"attachment"] = [PFFile fileWithName:@"resume.txt" data: [@"My string content" dataUsingEncoding:NSUTF8StringEncoding]];
parseObject[@"task"] = @"A string";
parseObject[@"Nombre"] = @"A string";
parseObject[@"edad"] = @"A string";
parseObject[@"correo"] = @"A string";
parseObject[@"matricula"] = @"A string";
parseObject[@"Edad"] = @"A string";
parseObject[@"Matricula"] = @"A string";
parseObject[@"nombre"] = @"A string";
parseObject[@"Correo"] = @"A string";
parseObject[@"query"] = @"A string";

[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("ToDo");
myObject["title"] = "A string";
myObject["url"] = "A string";
myObject["isCompleted"] = true;
myObject["schedule"] = DateTime.Now;
myObject["order"] = 1;
myObject["description"] = "A string";
myObject["attachmentt"] =  new ParseFile("resume.txt", System.Text.Encoding.UTF8.GetBytes("My string content"));;
myObject["project"] = new ParseObject("Project");
myObject["name"] = "A string";
myObject["attachment"] =  new ParseFile("resume.txt", System.Text.Encoding.UTF8.GetBytes("My string content"));;
myObject["task"] = "A string";
myObject["Nombre"] = "A string";
myObject["edad"] = "A string";
myObject["correo"] = "A string";
myObject["matricula"] = "A string";
myObject["Edad"] = "A string";
myObject["Matricula"] = "A string";
myObject["nombre"] = "A string";
myObject["Correo"] = "A string";
myObject["query"] = "A string";
await myObject.SaveAsync();
$myCustomObject = new ParseObject("ToDo");

$myCustomObject->set("title", "A string");
$myCustomObject->set("url", "A string");
$myCustomObject->set("isCompleted", true);
$myCustomObject->set("schedule", new DateTime());
$myCustomObject->set("order", 1);
$myCustomObject->set("description", "A string");
$myCustomObject->set("attachmentt", ParseFile::createFromData("My resume content", "resume.txt"));
$myCustomObject->set("project", new ParseObject("Project"));
$myCustomObject->set("name", "A string");
$myCustomObject->set("attachment", ParseFile::createFromData("My resume content", "resume.txt"));
$myCustomObject->set("task", "A string");
$myCustomObject->set("Nombre", "A string");
$myCustomObject->set("edad", "A string");
$myCustomObject->set("correo", "A string");
$myCustomObject->set("matricula", "A string");
$myCustomObject->set("Edad", "A string");
$myCustomObject->set("Matricula", "A string");
$myCustomObject->set("nombre", "A string");
$myCustomObject->set("Correo", "A string");
$myCustomObject->set("query", "A string");

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

Example Output:

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

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

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/ToDo/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={ \"title\":\"A string\",\"url\":\"A string\",\"isCompleted\":true,\"schedule\":{ \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },\"order\":1,\"description\":\"A string\",\"attachmentt\":{ \"__type\": \"File\", \"name\": \"resume.txt\" },\"project\":{ \"__type\": \"Pointer\", \"className\": \"Project\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" },\"name\":\"A string\",\"attachment\":{ \"__type\": \"File\", \"name\": \"resume.txt\" },\"task\":\"A string\",\"Nombre\":\"A string\",\"edad\":\"A string\",\"correo\":\"A string\",\"matricula\":\"A string\",\"Edad\":\"A string\",\"Matricula\":\"A string\",\"nombre\":\"A string\",\"Correo\":\"A string\",\"query\":\"A string\" }" \
https://parseapi.back4app.com/classes/ToDo

Example Response:

{
  "results": [
    {
      "objectId": "zJxVP17mTi",
      "createdAt": "2018-10-31T14:16:13.616Z",
      "updatedAt": "2018-11-07T12:12:20.758Z",
      "title": \"A string\","url": \"A string\","isCompleted": true,"schedule": { \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },"order": 1,"description": \"A string\","attachmentt": { \"__type\": \"File\", \"name\": \"resume.txt\" },"project": { \"__type\": \"Pointer\", \"className\": \"Project\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" },"name": \"A string\","attachment": { \"__type\": \"File\", \"name\": \"resume.txt\" },"task": \"A string\","Nombre": \"A string\","edad": \"A string\","correo": \"A string\","matricula": \"A string\","Edad": \"A string\","Matricula": \"A string\","nombre": \"A string\","Correo": \"A string\","query": \"A string\"
    },
    {
      "objectId": "yDbv0gKGJR",
      "createdAt": "2018-10-31T14:16:42.811Z",
      "updatedAt": "2018-11-07T12:12:18.543Z",
      "title": \"A string\","url": \"A string\","isCompleted": true,"schedule": { \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },"order": 1,"description": \"A string\","attachmentt": { \"__type\": \"File\", \"name\": \"resume.txt\" },"project": { \"__type\": \"Pointer\", \"className\": \"Project\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" },"name": \"A string\","attachment": { \"__type\": \"File\", \"name\": \"resume.txt\" },"task": \"A string\","Nombre": \"A string\","edad": \"A string\","correo": \"A string\","matricula": \"A string\","Edad": \"A string\","Matricula": \"A string\","nombre": \"A string\","Correo": \"A string\","query": \"A string\"
    },
    {
      "objectId": "xKue915KBG",
      "createdAt": "2018-11-07T12:11:58.533Z",
      "updatedAt": "2018-11-07T12:12:15.413Z",
      "title": \"A string\","url": \"A string\","isCompleted": true,"schedule": { \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },"order": 1,"description": \"A string\","attachmentt": { \"__type\": \"File\", \"name\": \"resume.txt\" },"project": { \"__type\": \"Pointer\", \"className\": \"Project\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" },"name": \"A string\","attachment": { \"__type\": \"File\", \"name\": \"resume.txt\" },"task": \"A string\","Nombre": \"A string\","edad": \"A string\","correo": \"A string\","matricula": \"A string\","Edad": \"A string\","Matricula": \"A string\","nombre": \"A string\","Correo": \"A string\","query": \"A string\"
    }
  ]
}

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

Learn more about query parameters in queries section.

Code:

(async () => {
  const ToDo = Parse.Object.extend('ToDo');
  const query = new Parse.Query(ToDo);
  // You can also query by using a parameter of an object
  // query.equalTo('objectId', 'xKue915KBG');
  try {
    const results = await query.find();
    for (const object of results) {
      // Access the Parse Object attributes using the .GET method
      const title = object.get('title')
      const url = object.get('url')
      const isCompleted = object.get('isCompleted')
      const schedule = object.get('schedule')
      const order = object.get('order')
      const description = object.get('description')
      const attachmentt = object.get('attachmentt')
      const project = object.get('project')
      const name = object.get('name')
      const attachment = object.get('attachment')
      const task = object.get('task')
      const Nombre = object.get('Nombre')
      const edad = object.get('edad')
      const correo = object.get('correo')
      const matricula = object.get('matricula')
      const Edad = object.get('Edad')
      const Matricula = object.get('Matricula')
      const nombre = object.get('nombre')
      const Correo = object.get('Correo')
      const query = object.get('query')
      console.log(title);
      console.log(url);
      console.log(isCompleted);
      console.log(schedule);
      console.log(order);
      console.log(description);
      console.log(attachmentt);
      console.log(project);
      console.log(name);
      console.log(attachment);
      console.log(task);
      console.log(Nombre);
      console.log(edad);
      console.log(correo);
      console.log(matricula);
      console.log(Edad);
      console.log(Matricula);
      console.log(nombre);
      console.log(Correo);
      console.log(query);
    }
  } catch (error) {
    console.error('Error while fetching ToDo', error);
  }
})();
(async () => {
  const ToDo: Parse.Object = Parse.Object.extend('ToDo');
  const query: Parse.Query = new Parse.Query(ToDo);
  // You can also query by using a parameter of an object
  // query.equalTo('objectId', 'xKue915KBG');
  try {
    const results: Parse.Object[] = await query.find();
    for (const object of results) {
      // Access the Parse Object attributes using the .GET method
      const title: string = object.get('title')
      const url: string = object.get('url')
      const isCompleted: string = object.get('isCompleted')
      const schedule: string = object.get('schedule')
      const order: string = object.get('order')
      const description: string = object.get('description')
      const attachmentt: string = object.get('attachmentt')
      const project: string = object.get('project')
      const name: string = object.get('name')
      const attachment: string = object.get('attachment')
      const task: string = object.get('task')
      const Nombre: string = object.get('Nombre')
      const edad: string = object.get('edad')
      const correo: string = object.get('correo')
      const matricula: string = object.get('matricula')
      const Edad: string = object.get('Edad')
      const Matricula: string = object.get('Matricula')
      const nombre: string = object.get('nombre')
      const Correo: string = object.get('Correo')
      const query: string = object.get('query')
      console.log(title);
      console.log(url);
      console.log(isCompleted);
      console.log(schedule);
      console.log(order);
      console.log(description);
      console.log(attachmentt);
      console.log(project);
      console.log(name);
      console.log(attachment);
      console.log(task);
      console.log(Nombre);
      console.log(edad);
      console.log(correo);
      console.log(matricula);
      console.log(Edad);
      console.log(Matricula);
      console.log(nombre);
      console.log(Correo);
      console.log(query);
    }
  } catch (error: any) {
    console.error('Error while fetching ToDo', error);
  }
})();

Example Output:

'A string' 'A string' true new Date() 1 'A string' new Parse.File("resume.txt", { base64: btoa("My file content") }) new Parse.Object("Project") 'A string' new Parse.File("resume.txt", { base64: btoa("My file content") }) 'A string' 'A string' 'A string' 'A string' 'A string' 'A string' 'A string' 'A string' 'A string' 'A string' 

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

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

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:@"ToDo"];
[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("ToDo");
ParseObject result = await query.GetAsync("<PARSE_OBJECT_ID>");
// Use the Get<T> method to get the values
string title = result.Get<string>("title");
string url = result.Get<string>("url");
bool isCompleted = result.Get<bool>("isCompleted");
DateTime schedule = result.Get<DateTime>("schedule");
int order = result.Get<int>("order");
string description = result.Get<string>("description");
ParseFile attachmentt = result.Get<ParseFile>("attachmentt");
ParseObject project = result.Get<ParseObject>("project");
string name = result.Get<string>("name");
ParseFile attachment = result.Get<ParseFile>("attachment");
string task = result.Get<string>("task");
string Nombre = result.Get<string>("Nombre");
string edad = result.Get<string>("edad");
string correo = result.Get<string>("correo");
string matricula = result.Get<string>("matricula");
string Edad = result.Get<string>("Edad");
string Matricula = result.Get<string>("Matricula");
string nombre = result.Get<string>("nombre");
string Correo = result.Get<string>("Correo");
string query = result.Get<string>("query");
$query = new ParseQuery("ToDo");
try {
  $myCustomObject = $query->get("<PARSE_OBJECT_ID>");
  // The object was retrieved successfully.

  // To get attributes, you can use the "get" method, providing the attribute name:
  $title = $myCustomObject->get("title");
  $url = $myCustomObject->get("url");
  $isCompleted = $myCustomObject->get("isCompleted");
  $schedule = $myCustomObject->get("schedule");
  $order = $myCustomObject->get("order");
  $description = $myCustomObject->get("description");
  $attachmentt = $myCustomObject->get("attachmentt");
  $project = $myCustomObject->get("project");
  $name = $myCustomObject->get("name");
  $attachment = $myCustomObject->get("attachment");
  $task = $myCustomObject->get("task");
  $Nombre = $myCustomObject->get("Nombre");
  $edad = $myCustomObject->get("edad");
  $correo = $myCustomObject->get("correo");
  $matricula = $myCustomObject->get("matricula");
  $Edad = $myCustomObject->get("Edad");
  $Matricula = $myCustomObject->get("Matricula");
  $nombre = $myCustomObject->get("nombre");
  $Correo = $myCustomObject->get("Correo");
  $query = $myCustomObject->get("query");
} 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/ToDo

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 "{ \"title\": \"A string\",\"url\": \"A string\",\"isCompleted\": true,\"schedule\": { \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },\"order\": 1,\"description\": \"A string\",\"attachmentt\": { \"__type\": \"File\", \"name\": \"resume.txt\" },\"project\": { \"__type\": \"Pointer\", \"className\": \"Project\", \"objectId\": \"<THE_REFERENCED_OBJECT_ID>\" },\"name\": \"A string\",\"attachment\": { \"__type\": \"File\", \"name\": \"resume.txt\" },\"task\": \"A string\",\"Nombre\": \"A string\",\"edad\": \"A string\",\"correo\": \"A string\",\"matricula\": \"A string\",\"Edad\": \"A string\",\"Matricula\": \"A string\",\"nombre\": \"A string\",\"Correo\": \"A string\",\"query\": \"A string\" }" \
https://parseapi.back4app.com/classes/ToDo/<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 '{ "title": {"__op":"Delete"},"url": {"__op":"Delete"},"isCompleted": {"__op":"Delete"},"schedule": {"__op":"Delete"},"order": {"__op":"Delete"},"description": {"__op":"Delete"},"attachmentt": {"__op":"Delete"},"project": {"__op":"Delete"},"name": {"__op":"Delete"},"attachment": {"__op":"Delete"},"task": {"__op":"Delete"},"Nombre": {"__op":"Delete"},"edad": {"__op":"Delete"},"correo": {"__op":"Delete"},"matricula": {"__op":"Delete"},"Edad": {"__op":"Delete"},"Matricula": {"__op":"Delete"},"nombre": {"__op":"Delete"},"Correo": {"__op":"Delete"},"query": {"__op":"Delete"} }' \
https://parseapi.back4app.com/classes/ToDo

Example Response:

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

Code:

(async () => {
  const query = new Parse.Query(ToDo);
  try {
    // here you put the objectId that you want to update
    const object = await query.get('xKue915KBG');
    object.set('title', 'A string');
    object.set('url', 'A string');
    object.set('isCompleted', true);
    object.set('schedule', new Date());
    object.set('order', 1);
    object.set('description', 'A string');
    object.set('attachmentt', new Parse.File("resume.txt", { base64: btoa("My file content") }));
    object.set('project', new Parse.Object("Project"));
    object.set('name', 'A string');
    object.set('attachment', new Parse.File("resume.txt", { base64: btoa("My file content") }));
    object.set('task', 'A string');
    object.set('Nombre', 'A string');
    object.set('edad', 'A string');
    object.set('correo', 'A string');
    object.set('matricula', 'A string');
    object.set('Edad', 'A string');
    object.set('Matricula', 'A string');
    object.set('nombre', 'A string');
    object.set('Correo', 'A string');
    object.set('query', 'A string');
    try {
      const response = await object.save();
      // You can use the "get" method to get the value of an attribute
      // Ex: response.get("<ATTRIBUTE_NAME>")
      // Access the Parse Object attributes using the .GET method
      console.log(response.get('title'));
      console.log(response.get('url'));
      console.log(response.get('isCompleted'));
      console.log(response.get('schedule'));
      console.log(response.get('order'));
      console.log(response.get('description'));
      console.log(response.get('attachmentt'));
      console.log(response.get('project'));
      console.log(response.get('name'));
      console.log(response.get('attachment'));
      console.log(response.get('task'));
      console.log(response.get('Nombre'));
      console.log(response.get('edad'));
      console.log(response.get('correo'));
      console.log(response.get('matricula'));
      console.log(response.get('Edad'));
      console.log(response.get('Matricula'));
      console.log(response.get('nombre'));
      console.log(response.get('Correo'));
      console.log(response.get('query'));
      console.log('ToDo updated', response);
    } catch (error) {
      console.error('Error while updating ToDo', error);
      }
    } catch (error) {
      console.error('Error while retrieving object ToDo', error);
    }
})();
(async () => {
  const query: Parse.Query = new Parse.Query(ToDo);
  try {
    // here you put the objectId that you want to update
    const object: Parse.Object = await query.get('xKue915KBG');
    object.set('title', 'A string');
    object.set('url', 'A string');
    object.set('isCompleted', true);
    object.set('schedule', new Date());
    object.set('order', 1);
    object.set('description', 'A string');
    object.set('attachmentt', new Parse.File("resume.txt", { base64: btoa("My file content") }));
    object.set('project', new Parse.Object("Project"));
    object.set('name', 'A string');
    object.set('attachment', new Parse.File("resume.txt", { base64: btoa("My file content") }));
    object.set('task', 'A string');
    object.set('Nombre', 'A string');
    object.set('edad', 'A string');
    object.set('correo', 'A string');
    object.set('matricula', 'A string');
    object.set('Edad', 'A string');
    object.set('Matricula', 'A string');
    object.set('nombre', 'A string');
    object.set('Correo', 'A string');
    object.set('query', 'A string');
    try {
      const response: Parse.Object = await object.save();
      // You can use the "get" method to get the value of an attribute
      // Ex: response.get("<ATTRIBUTE_NAME>")
      // Access the Parse Object attributes using the .GET method
      console.log(response.get('title'));
      console.log(response.get('url'));
      console.log(response.get('isCompleted'));
      console.log(response.get('schedule'));
      console.log(response.get('order'));
      console.log(response.get('description'));
      console.log(response.get('attachmentt'));
      console.log(response.get('project'));
      console.log(response.get('name'));
      console.log(response.get('attachment'));
      console.log(response.get('task'));
      console.log(response.get('Nombre'));
      console.log(response.get('edad'));
      console.log(response.get('correo'));
      console.log(response.get('matricula'));
      console.log(response.get('Edad'));
      console.log(response.get('Matricula'));
      console.log(response.get('nombre'));
      console.log(response.get('Correo'));
      console.log(response.get('query'));
      console.log('ToDo updated', response);
    } catch (error: any) {
      console.error('Error while updating ToDo', error);
      }
    } catch (error: any) {
      console.error('Error while retrieving object ToDo', error);
    }
})();

Example Output:


title
url
isCompleted
schedule
order
description
attachmentt
project
name
attachment
task
Nombre
edad
correo
matricula
Edad
Matricula
nombre
Correo
query
ToDo updated
{
  className: ToDo,
   _objCount: 0,
   id: 'xKue915KBG'
}

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

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

Example Output:

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

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

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

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

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

  // Retrieve the object by id
  query.getInBackground("<PARSE_OBJECT_ID>", (object, e) -> {
    if (e == null) {
      //Object was successfully retrieved
      // Update the fields we want to
      object.put("title", "A string");
      object.put("url", "A string");
      object.put("isCompleted", true);
      object.put("schedule", new Date());
      object.put("order", 1);
      object.put("description", "A string");
      object.put("attachmentt", new ParseFile("resume.txt", "My string content".getBytes()));
      object.put("project", new ParseObject("Project"));
      object.put("name", "A string");
      object.put("attachment", new ParseFile("resume.txt", "My string content".getBytes()));
      object.put("task", "A string");
      object.put("Nombre", "A string");
      object.put("edad", "A string");
      object.put("correo", "A string");
      object.put("matricula", "A string");
      object.put("Edad", "A string");
      object.put("Matricula", "A string");
      object.put("nombre", "A string");
      object.put("Correo", "A string");
      object.put("query", "A string");

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

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

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

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error != nil {
    print(error)
  } else if parseObject != nil {
    parseObject["title"] = "A string"
    parseObject["url"] = "A string"
    parseObject["isCompleted"] = true
    parseObject["schedule"] = NSDate()
    parseObject["order"] = 1
    parseObject["description"] = "A string"
    parseObject["attachmentt"] = PFFile(name:"resume.txt", data:"My string content".dataUsingEncoding(NSUTF8StringEncoding))
    parseObject["project"] = PFObject(className:"Project")
    parseObject["name"] = "A string"
    parseObject["attachment"] = PFFile(name:"resume.txt", data:"My string content".dataUsingEncoding(NSUTF8StringEncoding))
    parseObject["task"] = "A string"
    parseObject["Nombre"] = "A string"
    parseObject["edad"] = "A string"
    parseObject["correo"] = "A string"
    parseObject["matricula"] = "A string"
    parseObject["Edad"] = "A string"
    parseObject["Matricula"] = "A string"
    parseObject["nombre"] = "A string"
    parseObject["Correo"] = "A string"
    parseObject["query"] = "A string"

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

// Retrieve the object by id
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>"
                             block:^(PFObject *parseObject, NSError *error) {
    parseObject[@"title"] = @"A string";
    parseObject[@"url"] = @"A string";
    parseObject[@"isCompleted"] = @YES;
    parseObject[@"schedule"] = [NSDate date];
    parseObject[@"order"] = @1;
    parseObject[@"description"] = @"A string";
    parseObject[@"attachmentt"] = [PFFile fileWithName:@"resume.txt" data: [@"My string content" dataUsingEncoding:NSUTF8StringEncoding]];
    parseObject[@"project"] = [PFObject objectWithClassName:@"Project"];
    parseObject[@"name"] = @"A string";
    parseObject[@"attachment"] = [PFFile fileWithName:@"resume.txt" data: [@"My string content" dataUsingEncoding:NSUTF8StringEncoding]];
    parseObject[@"task"] = @"A string";
    parseObject[@"Nombre"] = @"A string";
    parseObject[@"edad"] = @"A string";
    parseObject[@"correo"] = @"A string";
    parseObject[@"matricula"] = @"A string";
    parseObject[@"Edad"] = @"A string";
    parseObject[@"Matricula"] = @"A string";
    parseObject[@"nombre"] = @"A string";
    parseObject[@"Correo"] = @"A string";
    parseObject[@"query"] = @"A string";

    [parseObject saveInBackground];
}];
ParseQuery<ParseObject> query = ParseObject.GetQuery("ToDo");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
myObject["title"] = "A string";
myObject["url"] = "A string";
myObject["isCompleted"] = true;
myObject["schedule"] = DateTime.Now;
myObject["order"] = 1;
myObject["description"] = "A string";
myObject["attachmentt"] =  new ParseFile("resume.txt", System.Text.Encoding.UTF8.GetBytes("My string content"));;
myObject["project"] = new ParseObject("Project");
myObject["name"] = "A string";
myObject["attachment"] =  new ParseFile("resume.txt", System.Text.Encoding.UTF8.GetBytes("My string content"));;
myObject["task"] = "A string";
myObject["Nombre"] = "A string";
myObject["edad"] = "A string";
myObject["correo"] = "A string";
myObject["matricula"] = "A string";
myObject["Edad"] = "A string";
myObject["Matricula"] = "A string";
myObject["nombre"] = "A string";
myObject["Correo"] = "A string";
myObject["query"] = "A string";
await myObject.SaveAsync();

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

ParseQuery<ParseObject> query = ParseObject.GetQuery("MyCustomClassName");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
myObject.Remove("title");
myObject.Remove("url");
myObject.Remove("isCompleted");
myObject.Remove("schedule");
myObject.Remove("order");
myObject.Remove("description");
myObject.Remove("attachmentt");
myObject.Remove("project");
myObject.Remove("name");
myObject.Remove("attachment");
myObject.Remove("task");
myObject.Remove("Nombre");
myObject.Remove("edad");
myObject.Remove("correo");
myObject.Remove("matricula");
myObject.Remove("Edad");
myObject.Remove("Matricula");
myObject.Remove("nombre");
myObject.Remove("Correo");
myObject.Remove("query");
await myObject.SaveAsync();
$query = new ParseQuery("ToDo");
try {
  $myCustomObject = $query->get("<PARSE_OBJECT_ID>");
  // The object was retrieved successfully.

  // Update any data you want with the "set" method,
  // providing the attribute name and the new value
  $myCustomObject->set("title", "A string");
  $myCustomObject->set("url", "A string");
  $myCustomObject->set("isCompleted", true);
  $myCustomObject->set("schedule", new DateTime());
  $myCustomObject->set("order", 1);
  $myCustomObject->set("description", "A string");
  $myCustomObject->set("attachmentt", ParseFile::createFromData("My resume content", "resume.txt"));
  $myCustomObject->set("project", new ParseObject("Project"));
  $myCustomObject->set("name", "A string");
  $myCustomObject->set("attachment", ParseFile::createFromData("My resume content", "resume.txt"));
  $myCustomObject->set("task", "A string");
  $myCustomObject->set("Nombre", "A string");
  $myCustomObject->set("edad", "A string");
  $myCustomObject->set("correo", "A string");
  $myCustomObject->set("matricula", "A string");
  $myCustomObject->set("Edad", "A string");
  $myCustomObject->set("Matricula", "A string");
  $myCustomObject->set("nombre", "A string");
  $myCustomObject->set("Correo", "A string");
  $myCustomObject->set("query", "A string");

  // 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/ToDo/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/ToDo/<OBJECT_ID>

Example Response:

{}

Code:

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

Example Output:

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

public void deleteObject() {

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

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

}
var deleteAttributesOnly = true

var query = PFQuery(className:"ToDo")

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error != nil {
    print(error)
  } else if parseObject != nil {
    if deleteAttributesOnly {
      parseObject.removeObjectForKey("title")
      parseObject.removeObjectForKey("url")
      parseObject.removeObjectForKey("isCompleted")
      parseObject.removeObjectForKey("schedule")
      parseObject.removeObjectForKey("order")
      parseObject.removeObjectForKey("description")
      parseObject.removeObjectForKey("attachmentt")
      parseObject.removeObjectForKey("project")
      parseObject.removeObjectForKey("name")
      parseObject.removeObjectForKey("attachment")
      parseObject.removeObjectForKey("task")
      parseObject.removeObjectForKey("Nombre")
      parseObject.removeObjectForKey("edad")
      parseObject.removeObjectForKey("correo")
      parseObject.removeObjectForKey("matricula")
      parseObject.removeObjectForKey("Edad")
      parseObject.removeObjectForKey("Matricula")
      parseObject.removeObjectForKey("nombre")
      parseObject.removeObjectForKey("Correo")
      parseObject.removeObjectForKey("query")
      parseObject.saveInBackground()
    } else {
      parseObject.deleteInBackground()
    }
  }
}
PFQuery *query = [PFQuery queryWithClassName:@"ToDo"];

// Retrieve the object by id
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>" block:^(PFObject *parseObject, NSError *error) {
  // When using "removeObjectForKey", the field will be empty
  // [parseObject removeObjectForKey:@"title"];
  // [parseObject removeObjectForKey:@"url"];
  // [parseObject removeObjectForKey:@"isCompleted"];
  // [parseObject removeObjectForKey:@"schedule"];
  // [parseObject removeObjectForKey:@"order"];
  // [parseObject removeObjectForKey:@"description"];
  // [parseObject removeObjectForKey:@"attachmentt"];
  // [parseObject removeObjectForKey:@"project"];
  // [parseObject removeObjectForKey:@"name"];
  // [parseObject removeObjectForKey:@"attachment"];
  // [parseObject removeObjectForKey:@"task"];
  // [parseObject removeObjectForKey:@"Nombre"];
  // [parseObject removeObjectForKey:@"edad"];
  // [parseObject removeObjectForKey:@"correo"];
  // [parseObject removeObjectForKey:@"matricula"];
  // [parseObject removeObjectForKey:@"Edad"];
  // [parseObject removeObjectForKey:@"Matricula"];
  // [parseObject removeObjectForKey:@"nombre"];
  // [parseObject removeObjectForKey:@"Correo"];
  // [parseObject removeObjectForKey:@"query"];
  // 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("ToDo");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
await myObject.DeleteAsync();
$query = new ParseQuery("ToDo");
try {
  $myCustomObject = $query->get("<PARSE_OBJECT_ID>");
  // The object was retrieved successfully.

  // After this, the field will be empty
  $myCustomObject->delete("title");
  $myCustomObject->delete("url");
  $myCustomObject->delete("isCompleted");
  $myCustomObject->delete("schedule");
  $myCustomObject->delete("order");
  $myCustomObject->delete("description");
  $myCustomObject->delete("attachmentt");
  $myCustomObject->delete("project");
  $myCustomObject->delete("name");
  $myCustomObject->delete("attachment");
  $myCustomObject->delete("task");
  $myCustomObject->delete("Nombre");
  $myCustomObject->delete("edad");
  $myCustomObject->delete("correo");
  $myCustomObject->delete("matricula");
  $myCustomObject->delete("Edad");
  $myCustomObject->delete("Matricula");
  $myCustomObject->delete("nombre");
  $myCustomObject->delete("Correo");
  $myCustomObject->delete("query");
  // 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/ToDo/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.

TeamInfo Class

Example JSON:

{
}

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

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

Example Response:

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

Code:

(async () => {
  const myNewObject = new Parse.Object('TeamInfo');
  try {
    const result = await myNewObject.save();
    // Access the Parse Object attributes using the .GET method
    console.log('TeamInfo created', result);
  } catch (error) {
    console.error('Error while creating TeamInfo: ', error);
  }
})();
(async () => {
  const myNewObject: Parse.Object = new Parse.Object('TeamInfo');
  try {
    const result: Parse.Object = await myNewObject.save();
    // Access the Parse Object attributes using the .GET method
    console.log('TeamInfo created', result);
  } catch (error: any) {
    console.error('Error while creating TeamInfo: ', 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("TeamInfo");


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

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


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


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


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

Example Output:

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

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

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

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:

(async () => {
  const TeamInfo = Parse.Object.extend('TeamInfo');
  const query = new Parse.Query(TeamInfo);
  // You can also query by using a parameter of an object
  // query.equalTo('objectId', 'xKue915KBG');
  try {
    const results = await query.find();
    for (const object of results) {
      // Access the Parse Object attributes using the .GET method
    }
  } catch (error) {
    console.error('Error while fetching TeamInfo', error);
  }
})();
(async () => {
  const TeamInfo: Parse.Object = Parse.Object.extend('TeamInfo');
  const query: Parse.Query = new Parse.Query(TeamInfo);
  // You can also query by using a parameter of an object
  // query.equalTo('objectId', 'xKue915KBG');
  try {
    const results: Parse.Object[] = await query.find();
    for (const object of results) {
      // Access the Parse Object attributes using the .GET method
    }
  } catch (error: any) {
    console.error('Error while fetching TeamInfo', 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("TeamInfo");

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

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

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

Example Response:

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

Code:

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

Example Output:


TeamInfo updated
{
  className: TeamInfo,
   _objCount: 0,
   id: 'xKue915KBG'
}

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

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

Example Output:

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

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

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

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

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

  // Retrieve the object by id
  query.getInBackground("<PARSE_OBJECT_ID>", (object, e) -> {
    if (e == null) {
      //Object was successfully retrieved
      // Update the fields we want to

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

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

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

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

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

    [parseObject saveInBackground];
}];
ParseQuery<ParseObject> query = ParseObject.GetQuery("TeamInfo");
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("TeamInfo");
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/TeamInfo/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/TeamInfo/<OBJECT_ID>

Example Response:

{}

Code:

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

Example Output:

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

public void deleteObject() {

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

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

}
var deleteAttributesOnly = true

var query = PFQuery(className:"TeamInfo")

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

// 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("TeamInfo");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
await myObject.DeleteAsync();
$query = new ParseQuery("TeamInfo");
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/TeamInfo/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.

records Class

Example JSON:

{
  "where": { "foo": "bar" },
  "blogName": "A string",
  "imgUrl": "A string",
  "description": "A string"
}

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

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

Name Type Example
where Object { "foo": "bar" }
blogName String "A string"
imgUrl String "A string"
description String "A string"

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\":{ \"foo\": \"bar\" },\"blogName\":\"A string\",\"imgUrl\":\"A string\",\"description\":\"A string\" }" \
https://parseapi.back4app.com/classes/records

Example Response:

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

Code:

(async () => {
  const myNewObject = new Parse.Object('records');
  myNewObject.set('where', { foo: 'bar' });
  myNewObject.set('blogName', 'A string');
  myNewObject.set('imgUrl', 'A string');
  myNewObject.set('description', 'A string');
  try {
    const result = await myNewObject.save();
    // Access the Parse Object attributes using the .GET method
    console.log('records created', result);
  } catch (error) {
    console.error('Error while creating records: ', error);
  }
})();
(async () => {
  const myNewObject: Parse.Object = new Parse.Object('records');
  myNewObject.set('where', { foo: 'bar' });
  myNewObject.set('blogName', 'A string');
  myNewObject.set('imgUrl', 'A string');
  myNewObject.set('description', 'A string');
  try {
    const result: Parse.Object = await myNewObject.save();
    // Access the Parse Object attributes using the .GET method
    console.log('records created', result);
  } catch (error: any) {
    console.error('Error while creating records: ', 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("records");

  entity.put("where", new JSONObject());
  entity.put("blogName", "A string");
  entity.put("imgUrl", "A string");
  entity.put("description", "A string");

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

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

parseObject["where"] = [ "foo": "bar" ]
parseObject["blogName"] = "A string"
parseObject["imgUrl"] = "A string"
parseObject["description"] = "A string"

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

parseObject[@"where"] = @{ @"foo": @"bar" };
parseObject[@"blogName"] = @"A string";
parseObject[@"imgUrl"] = @"A string";
parseObject[@"description"] = @"A string";

[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("records");
myObject["where"] = new Dictionary<string, object> { { "number", number }, { "string", str } };
myObject["blogName"] = "A string";
myObject["imgUrl"] = "A string";
myObject["description"] = "A string";
await myObject.SaveAsync();
$myCustomObject = new ParseObject("records");

$myCustomObject->set("where", ["foo" => "bar"]);
$myCustomObject->set("blogName", "A string");
$myCustomObject->set("imgUrl", "A string");
$myCustomObject->set("description", "A string");

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

Example Output:

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

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

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/records/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={ \"where.foo\":\"bar\",\"blogName\":\"A string\",\"imgUrl\":\"A string\",\"description\":\"A string\" }" \
https://parseapi.back4app.com/classes/records

Example Response:

{
  "results": [
    {
      "objectId": "zJxVP17mTi",
      "createdAt": "2018-10-31T14:16:13.616Z",
      "updatedAt": "2018-11-07T12:12:20.758Z",
      "where": { \"foo\": \"bar\" },"blogName": \"A string\","imgUrl": \"A string\","description": \"A string\"
    },
    {
      "objectId": "yDbv0gKGJR",
      "createdAt": "2018-10-31T14:16:42.811Z",
      "updatedAt": "2018-11-07T12:12:18.543Z",
      "where": { \"foo\": \"bar\" },"blogName": \"A string\","imgUrl": \"A string\","description": \"A string\"
    },
    {
      "objectId": "xKue915KBG",
      "createdAt": "2018-11-07T12:11:58.533Z",
      "updatedAt": "2018-11-07T12:12:15.413Z",
      "where": { \"foo\": \"bar\" },"blogName": \"A string\","imgUrl": \"A string\","description": \"A string\"
    }
  ]
}

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

Learn more about query parameters in queries section.

Code:

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

Example Output:

{ foo: 'bar' } 'A string' 'A string' 'A string' 

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

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

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

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 "{ \"where\": { \"foo\": \"bar\" },\"blogName\": \"A string\",\"imgUrl\": \"A string\",\"description\": \"A string\" }" \
https://parseapi.back4app.com/classes/records/<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 '{ "where": {"__op":"Delete"},"blogName": {"__op":"Delete"},"imgUrl": {"__op":"Delete"},"description": {"__op":"Delete"} }' \
https://parseapi.back4app.com/classes/records

Example Response:

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

Code:

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

Example Output:


where
blogName
imgUrl
description
records updated
{
  className: records,
   _objCount: 0,
   id: 'xKue915KBG'
}

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

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

Example Output:

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

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

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

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

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

  // Retrieve the object by id
  query.getInBackground("<PARSE_OBJECT_ID>", (object, e) -> {
    if (e == null) {
      //Object was successfully retrieved
      // Update the fields we want to
      object.put("where", new JSONObject());
      object.put("blogName", "A string");
      object.put("imgUrl", "A string");
      object.put("description", "A string");

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

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

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

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error != nil {
    print(error)
  } else if parseObject != nil {
    parseObject["where"] = [ "foo": "bar" ]
    parseObject["blogName"] = "A string"
    parseObject["imgUrl"] = "A string"
    parseObject["description"] = "A string"

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

// Retrieve the object by id
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>"
                             block:^(PFObject *parseObject, NSError *error) {
    parseObject[@"where"] = @{ @"foo": @"bar" };
    parseObject[@"blogName"] = @"A string";
    parseObject[@"imgUrl"] = @"A string";
    parseObject[@"description"] = @"A string";

    [parseObject saveInBackground];
}];
ParseQuery<ParseObject> query = ParseObject.GetQuery("records");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
myObject["where"] = new Dictionary<string, object> { { "number", number }, { "string", str } };
myObject["blogName"] = "A string";
myObject["imgUrl"] = "A string";
myObject["description"] = "A string";
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("where");
myObject.Remove("blogName");
myObject.Remove("imgUrl");
myObject.Remove("description");
await myObject.SaveAsync();
$query = new ParseQuery("records");
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("where", ["foo" => "bar"]);
  $myCustomObject->set("blogName", "A string");
  $myCustomObject->set("imgUrl", "A string");
  $myCustomObject->set("description", "A string");

  // 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/records/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/records/<OBJECT_ID>

Example Response:

{}

Code:

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

Example Output:

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

public void deleteObject() {

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

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

}
var deleteAttributesOnly = true

var query = PFQuery(className:"records")

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error != nil {
    print(error)
  } else if parseObject != nil {
    if deleteAttributesOnly {
      parseObject.removeObjectForKey("where")
      parseObject.removeObjectForKey("blogName")
      parseObject.removeObjectForKey("imgUrl")
      parseObject.removeObjectForKey("description")
      parseObject.saveInBackground()
    } else {
      parseObject.deleteInBackground()
    }
  }
}
PFQuery *query = [PFQuery queryWithClassName:@"records"];

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

  // After this, the field will be empty
  $myCustomObject->delete("where");
  $myCustomObject->delete("blogName");
  $myCustomObject->delete("imgUrl");
  $myCustomObject->delete("description");
  // 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/records/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.

rareFlowers Class

Example JSON:

{
  "name": "A string",
  "birth": "2018-11-12T13:13:45.958Z",
  "birthPlace": {"__type": "GeoPoint", "latitude": 40.0, "longitude": -30.0 }
}

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

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

Name Type Example
name String "A string"
birth Date "2018-11-12T13:13:45.958Z"
birthPlace GeoPoint {"__type": "GeoPoint", "latitude": 40.0, "longitude": -30.0 }

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 "{ \"name\":\"A string\",\"birth\":{ \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },\"birthPlace\":{ \"__type\": \"GeoPoint\", \"latitude\": 40.0, \"longitude\": -30.0 } }" \
https://parseapi.back4app.com/classes/rareFlowers

Example Response:

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

Code:

(async () => {
  const myNewObject = new Parse.Object('rareFlowers');
  myNewObject.set('name', 'A string');
  myNewObject.set('birth', new Date());
  myNewObject.set('birthPlace', new Parse.GeoPoint({latitude: 40.0, longitude: -30.0}));
  try {
    const result = await myNewObject.save();
    // Access the Parse Object attributes using the .GET method
    console.log('rareFlowers created', result);
  } catch (error) {
    console.error('Error while creating rareFlowers: ', error);
  }
})();
(async () => {
  const myNewObject: Parse.Object = new Parse.Object('rareFlowers');
  myNewObject.set('name', 'A string');
  myNewObject.set('birth', new Date());
  myNewObject.set('birthPlace', new Parse.GeoPoint({latitude: 40.0, longitude: -30.0}));
  try {
    const result: Parse.Object = await myNewObject.save();
    // Access the Parse Object attributes using the .GET method
    console.log('rareFlowers created', result);
  } catch (error: any) {
    console.error('Error while creating rareFlowers: ', 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("rareFlowers");

  entity.put("name", "A string");
  entity.put("birth", new Date());
  entity.put("birthPlace", new ParseGeoPoint(40.0, -30.0));

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

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

parseObject["name"] = "A string"
parseObject["birth"] = NSDate()
parseObject["birthPlace"] = PFGeoPoint(latitude:40.0, longitude:-30.0)

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

parseObject[@"name"] = @"A string";
parseObject[@"birth"] = [NSDate date];
parseObject[@"birthPlace"] = [PFGeoPoint geoPointWithLatitude:40.0 longitude:-30.0];

[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("rareFlowers");
myObject["name"] = "A string";
myObject["birth"] = DateTime.Now;
myObject["birthPlace"] = new ParseGeoPoint(40.0, -30.0);
await myObject.SaveAsync();
$myCustomObject = new ParseObject("rareFlowers");

$myCustomObject->set("name", "A string");
$myCustomObject->set("birth", new DateTime());
$myCustomObject->set("birthPlace", new ParseGeoPoint(40.0, -30.0));

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

Example Output:

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

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

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/rareFlowers/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={ \"name\":\"A string\",\"birth\":{ \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },\"birthPlace\":{ \"__type\": \"GeoPoint\", \"latitude\": 40.0, \"longitude\": -30.0 } }" \
https://parseapi.back4app.com/classes/rareFlowers

Example Response:

{
  "results": [
    {
      "objectId": "zJxVP17mTi",
      "createdAt": "2018-10-31T14:16:13.616Z",
      "updatedAt": "2018-11-07T12:12:20.758Z",
      "name": \"A string\","birth": { \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },"birthPlace": { \"__type\": \"GeoPoint\", \"latitude\": 40.0, \"longitude\": -30.0 }
    },
    {
      "objectId": "yDbv0gKGJR",
      "createdAt": "2018-10-31T14:16:42.811Z",
      "updatedAt": "2018-11-07T12:12:18.543Z",
      "name": \"A string\","birth": { \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },"birthPlace": { \"__type\": \"GeoPoint\", \"latitude\": 40.0, \"longitude\": -30.0 }
    },
    {
      "objectId": "xKue915KBG",
      "createdAt": "2018-11-07T12:11:58.533Z",
      "updatedAt": "2018-11-07T12:12:15.413Z",
      "name": \"A string\","birth": { \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },"birthPlace": { \"__type\": \"GeoPoint\", \"latitude\": 40.0, \"longitude\": -30.0 }
    }
  ]
}

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

Learn more about query parameters in queries section.

Code:

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

Example Output:

'A string' new Date() new Parse.GeoPoint({latitude: 40.0, longitude: -30.0}) 

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

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

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

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 "{ \"name\": \"A string\",\"birth\": { \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },\"birthPlace\": { \"__type\": \"GeoPoint\", \"latitude\": 40.0, \"longitude\": -30.0 } }" \
https://parseapi.back4app.com/classes/rareFlowers/<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 '{ "name": {"__op":"Delete"},"birth": {"__op":"Delete"},"birthPlace": {"__op":"Delete"} }' \
https://parseapi.back4app.com/classes/rareFlowers

Example Response:

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

Code:

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

Example Output:


name
birth
birthPlace
rareFlowers updated
{
  className: rareFlowers,
   _objCount: 0,
   id: 'xKue915KBG'
}

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

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

Example Output:

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

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

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

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

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

  // Retrieve the object by id
  query.getInBackground("<PARSE_OBJECT_ID>", (object, e) -> {
    if (e == null) {
      //Object was successfully retrieved
      // Update the fields we want to
      object.put("name", "A string");
      object.put("birth", new Date());
      object.put("birthPlace", new ParseGeoPoint(40.0, -30.0));

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

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

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

query.getObjectInBackgroundWithId("<PARSE_OBJECT_ID>") {
  (parseObject: PFObject?, error: NSError?) -> Void in
  if error != nil {
    print(error)
  } else if parseObject != nil {
    parseObject["name"] = "A string"
    parseObject["birth"] = NSDate()
    parseObject["birthPlace"] = PFGeoPoint(latitude:40.0, longitude:-30.0)

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

// Retrieve the object by id
[query getObjectInBackgroundWithId:@"<PARSE_OBJECT_ID>"
                             block:^(PFObject *parseObject, NSError *error) {
    parseObject[@"name"] = @"A string";
    parseObject[@"birth"] = [NSDate date];
    parseObject[@"birthPlace"] = [PFGeoPoint geoPointWithLatitude:40.0 longitude:-30.0];

    [parseObject saveInBackground];
}];
ParseQuery<ParseObject> query = ParseObject.GetQuery("rareFlowers");
ParseObject myObject = await query.GetAsync("<PARSE_OBJECT_ID>");
myObject["name"] = "A string";
myObject["birth"] = DateTime.Now;
myObject["birthPlace"] = new ParseGeoPoint(40.0, -30.0);
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("name");
myObject.Remove("birth");
myObject.Remove("birthPlace");
await myObject.SaveAsync();
$query = new ParseQuery("rareFlowers");
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("name", "A string");
  $myCustomObject->set("birth", new DateTime());
  $myCustomObject->set("birthPlace", new ParseGeoPoint(40.0, -30.0));

  // 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/rareFlowers/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/rareFlowers/<OBJECT_ID>

Example Response:

{}

Code:

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

Example Output:

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

public void deleteObject() {

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

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

}
var deleteAttributesOnly = true

var query = PFQuery(className:"rareFlowers")

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

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

  // After this, the field will be empty
  $myCustomObject->delete("name");
  $myCustomObject->delete("birth");
  $myCustomObject->delete("birthPlace");
  // 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/rareFlowers/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",
  "firstName": "A string",
  "lastName": "A string",
  "birthDate": "2018-11-12T13:13:45.958Z",
  "avatarPicture": { "__type": "File", "name": "resume.txt" },
  "name": "A string",
  "imageUrl": "A string",
  "nativeFirstName": "A string",
  "nativeLastName": "A string",
  "mobilePhoneNumber": "A string",
  "role": "A string",
  "jobTitle": "A string",
  "active": true,
  "fullName": "A string",
  "retypePassword": "A string",
  "phoneNumber": "A string",
  "repeatPassword": "A string",
  "idealCarSpeedRating": "A string",
  "currentCarYearWasMade": "A string",
  "idealCarHowMuchToBuyFor": "A string",
  "currentCarSpeedRating": "A string",
  "idealCarYearWasMade": "A string",
  "currentCarSpaceRating": "A string",
  "currentCarSafetyRating": "A string",
  "currentCarModel": "A string",
  "idealNextCarTrim": "A string",
  "currentCarSuitabilityForEverydayUseRating": "A string",
  "idealCarSuitabilityForEverydayUseRating": "A string",
  "idealCarSpaceRating": "A string",
  "currentCarWhenCarWasBought": "A string",
  "idealCarModel": "A string",
  "currentCarManufacturer": "A string",
  "currentCarTrim": "A string",
  "idealCarSafetyRating": "A string",
  "idealCarManufacturer": "A string",
  "idealCarWhenToPurchase": "A string",
  "idealCarComfortRating": "A string",
  "currentCarComfort": "A string",
  "currentCarHowMuchWasBoughtFor": "A string",
  "sessionToken": "A string",
  "currentGeoPoint": {"__type": "GeoPoint", "latitude": 40.0, "longitude": -30.0 },
  "avatar": "A string",
  "AccountType": "A string",
  "Provider": "A string",
  "Name": "A string",
  "company": "A string",
  "Full_Name": "A string",
  "phone": "A string",
  "currentCarSuitabilityForEverydayUseRatng": "A string",
  "posters": [1, "a string"],
  "vip": "A string",
  "city": "A string",
  "confirmPassword": "A string",
  "address": "A string",
  "repass": "A string",
  "fisrtName": "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\",\"firstName\": \"A string\",\"lastName\": \"A string\",\"birthDate\": { \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },\"avatarPicture\": { \"__type\": \"File\", \"name\": \"resume.txt\" },\"name\": \"A string\",\"imageUrl\": \"A string\",\"nativeFirstName\": \"A string\",\"nativeLastName\": \"A string\",\"mobilePhoneNumber\": \"A string\",\"role\": \"A string\",\"jobTitle\": \"A string\",\"active\": true,\"fullName\": \"A string\",\"retypePassword\": \"A string\",\"phoneNumber\": \"A string\",\"repeatPassword\": \"A string\",\"idealCarSpeedRating\": \"A string\",\"currentCarYearWasMade\": \"A string\",\"idealCarHowMuchToBuyFor\": \"A string\",\"currentCarSpeedRating\": \"A string\",\"idealCarYearWasMade\": \"A string\",\"currentCarSpaceRating\": \"A string\",\"currentCarSafetyRating\": \"A string\",\"currentCarModel\": \"A string\",\"idealNextCarTrim\": \"A string\",\"currentCarSuitabilityForEverydayUseRating\": \"A string\",\"idealCarSuitabilityForEverydayUseRating\": \"A string\",\"idealCarSpaceRating\": \"A string\",\"currentCarWhenCarWasBought\": \"A string\",\"idealCarModel\": \"A string\",\"currentCarManufacturer\": \"A string\",\"currentCarTrim\": \"A string\",\"idealCarSafetyRating\": \"A string\",\"idealCarManufacturer\": \"A string\",\"idealCarWhenToPurchase\": \"A string\",\"idealCarComfortRating\": \"A string\",\"currentCarComfort\": \"A string\",\"currentCarHowMuchWasBoughtFor\": \"A string\",\"sessionToken\": \"A string\",\"currentGeoPoint\": { \"__type\": \"GeoPoint\", \"latitude\": 40.0, \"longitude\": -30.0 },\"avatar\": \"A string\",\"AccountType\": \"A string\",\"Provider\": \"A string\",\"Name\": \"A string\",\"company\": \"A string\",\"Full_Name\": \"A string\",\"phone\": \"A string\",\"currentCarSuitabilityForEverydayUseRatng\": \"A string\",\"posters\": [ 1, \"a string\" ],\"vip\": \"A string\",\"city\": \"A string\",\"confirmPassword\": \"A string\",\"address\": \"A string\",\"repass\": \"A string\",\"fisrtName\": \"A string\" }" \
https://parseapi.back4app.com/users

Example Response:

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

Code:

(async () => {
  const user = new Parse.User();
  user.set('username', 'A string');
  user.set('email', 'A string');
  user.set('firstName', 'A string');
  user.set('lastName', 'A string');
  user.set('birthDate', new Date());
  user.set('avatarPicture', new Parse.File("resume.txt", { base64: btoa("My file content") }));
  user.set('name', 'A string');
  user.set('imageUrl', 'A string');
  user.set('nativeFirstName', 'A string');
  user.set('nativeLastName', 'A string');
  user.set('mobilePhoneNumber', 'A string');
  user.set('role', 'A string');
  user.set('jobTitle', 'A string');
  user.set('active', true);
  user.set('fullName', 'A string');
  user.set('retypePassword', 'A string');
  user.set('phoneNumber', 'A string');
  user.set('repeatPassword', 'A string');
  user.set('idealCarSpeedRating', 'A string');
  user.set('currentCarYearWasMade', 'A string');
  user.set('idealCarHowMuchToBuyFor', 'A string');
  user.set('currentCarSpeedRating', 'A string');
  user.set('idealCarYearWasMade', 'A string');
  user.set('currentCarSpaceRating', 'A string');
  user.set('currentCarSafetyRating', 'A string');
  user.set('currentCarModel', 'A string');
  user.set('idealNextCarTrim', 'A string');
  user.set('currentCarSuitabilityForEverydayUseRating', 'A string');
  user.set('idealCarSuitabilityForEverydayUseRating', 'A string');
  user.set('idealCarSpaceRating', 'A string');
  user.set('currentCarWhenCarWasBought', 'A string');
  user.set('idealCarModel', 'A string');
  user.set('currentCarManufacturer', 'A string');
  user.set('currentCarTrim', 'A string');
  user.set('idealCarSafetyRating', 'A string');
  user.set('idealCarManufacturer', 'A string');
  user.set('idealCarWhenToPurchase', 'A string');
  user.set('idealCarComfortRating', 'A string');
  user.set('currentCarComfort', 'A string');
  user.set('currentCarHowMuchWasBoughtFor', 'A string');
  user.set('sessionToken', 'A string');
  user.set('currentGeoPoint', new Parse.GeoPoint({latitude: 40.0, longitude: -30.0}));
  user.set('avatar', 'A string');
  user.set('AccountType', 'A string');
  user.set('Provider', 'A string');
  user.set('Name', 'A string');
  user.set('company', 'A string');
  user.set('Full_Name', 'A string');
  user.set('phone', 'A string');
  user.set('currentCarSuitabilityForEverydayUseRatng', 'A string');
  user.set('posters', [1, 'a string']);
  user.set('vip', 'A string');
  user.set('city', 'A string');
  user.set('confirmPassword', 'A string');
  user.set('address', 'A string');
  user.set('repass', 'A string');
  user.set('fisrtName', 'A string');
  user.set('password', '#Password123');

  try {
    let userResult = await user.signUp();
    console.log('User signed up', userResult);
  } catch (error) {
    console.error('Error while signing up user', error);
  }
})();
(async () => {
  const user: Parse.User = new Parse.User();
  user.set('username', 'A string');
  user.set('email', 'A string');
  user.set('firstName', 'A string');
  user.set('lastName', 'A string');
  user.set('birthDate', new Date());
  user.set('avatarPicture', new Parse.File("resume.txt", { base64: btoa("My file content") }));
  user.set('name', 'A string');
  user.set('imageUrl', 'A string');
  user.set('nativeFirstName', 'A string');
  user.set('nativeLastName', 'A string');
  user.set('mobilePhoneNumber', 'A string');
  user.set('role', 'A string');
  user.set('jobTitle', 'A string');
  user.set('active', true);
  user.set('fullName', 'A string');
  user.set('retypePassword', 'A string');
  user.set('phoneNumber', 'A string');
  user.set('repeatPassword', 'A string');
  user.set('idealCarSpeedRating', 'A string');
  user.set('currentCarYearWasMade', 'A string');
  user.set('idealCarHowMuchToBuyFor', 'A string');
  user.set('currentCarSpeedRating', 'A string');
  user.set('idealCarYearWasMade', 'A string');
  user.set('currentCarSpaceRating', 'A string');
  user.set('currentCarSafetyRating', 'A string');
  user.set('currentCarModel', 'A string');
  user.set('idealNextCarTrim', 'A string');
  user.set('currentCarSuitabilityForEverydayUseRating', 'A string');
  user.set('idealCarSuitabilityForEverydayUseRating', 'A string');
  user.set('idealCarSpaceRating', 'A string');
  user.set('currentCarWhenCarWasBought', 'A string');
  user.set('idealCarModel', 'A string');
  user.set('currentCarManufacturer', 'A string');
  user.set('currentCarTrim', 'A string');
  user.set('idealCarSafetyRating', 'A string');
  user.set('idealCarManufacturer', 'A string');
  user.set('idealCarWhenToPurchase', 'A string');
  user.set('idealCarComfortRating', 'A string');
  user.set('currentCarComfort', 'A string');
  user.set('currentCarHowMuchWasBoughtFor', 'A string');
  user.set('sessionToken', 'A string');
  user.set('currentGeoPoint', new Parse.GeoPoint({latitude: 40.0, longitude: -30.0}));
  user.set('avatar', 'A string');
  user.set('AccountType', 'A string');
  user.set('Provider', 'A string');
  user.set('Name', 'A string');
  user.set('company', 'A string');
  user.set('Full_Name', 'A string');
  user.set('phone', 'A string');
  user.set('currentCarSuitabilityForEverydayUseRatng', 'A string');
  user.set('posters', [1, 'a string']);
  user.set('vip', 'A string');
  user.set('city', 'A string');
  user.set('confirmPassword', 'A string');
  user.set('address', 'A string');
  user.set('repass', 'A string');
  user.set('fisrtName', 'A string');
  user.set('password', '#Password123');

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

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

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

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

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

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

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

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

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

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

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

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

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

Example Output:

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

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

Request

URL

https://parseapi.back4app.com/users

Method

POST

Headers

X-Parse-Application-Id: 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 POST \
-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:

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

Example Output:

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

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

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

Request

URL

https://parseapi.back4app.com/login

Method

POST

Headers

X-Parse-Application-Id: 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@example.com"}' \
https://parseapi.back4app.com/verificationEmailRequest

Example Response:

{}

Example Request:

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

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

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

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

  const options: object = {
    hostname: 'https://parseapi.back4app.com',
    path: '/verificationEmailRequest',
    method: 'POST',
    headers: {
      'X-Parse-Application-Id': 'BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f',
      'X-Parse-REST-API-Key': 'swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w',
      'Content-Type': 'application/json'
    }
  };

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

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

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

Example Response:

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

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

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

Sign up

Code:

(async () => {
  const user = new Parse.User()
  user.set('username', 'A string');
  user.set('email', 'A string');
  user.set('firstName', 'A string');
  user.set('lastName', 'A string');
  user.set('birthDate', new Date());
  user.set('avatarPicture', new Parse.File("resume.txt", { base64: btoa("My file content") }));
  user.set('name', 'A string');
  user.set('imageUrl', 'A string');
  user.set('nativeFirstName', 'A string');
  user.set('nativeLastName', 'A string');
  user.set('mobilePhoneNumber', 'A string');
  user.set('role', 'A string');
  user.set('jobTitle', 'A string');
  user.set('active', true);
  user.set('fullName', 'A string');
  user.set('retypePassword', 'A string');
  user.set('phoneNumber', 'A string');
  user.set('repeatPassword', 'A string');
  user.set('idealCarSpeedRating', 'A string');
  user.set('currentCarYearWasMade', 'A string');
  user.set('idealCarHowMuchToBuyFor', 'A string');
  user.set('currentCarSpeedRating', 'A string');
  user.set('idealCarYearWasMade', 'A string');
  user.set('currentCarSpaceRating', 'A string');
  user.set('currentCarSafetyRating', 'A string');
  user.set('currentCarModel', 'A string');
  user.set('idealNextCarTrim', 'A string');
  user.set('currentCarSuitabilityForEverydayUseRating', 'A string');
  user.set('idealCarSuitabilityForEverydayUseRating', 'A string');
  user.set('idealCarSpaceRating', 'A string');
  user.set('currentCarWhenCarWasBought', 'A string');
  user.set('idealCarModel', 'A string');
  user.set('currentCarManufacturer', 'A string');
  user.set('currentCarTrim', 'A string');
  user.set('idealCarSafetyRating', 'A string');
  user.set('idealCarManufacturer', 'A string');
  user.set('idealCarWhenToPurchase', 'A string');
  user.set('idealCarComfortRating', 'A string');
  user.set('currentCarComfort', 'A string');
  user.set('currentCarHowMuchWasBoughtFor', 'A string');
  user.set('sessionToken', 'A string');
  user.set('currentGeoPoint', new Parse.GeoPoint({latitude: 40.0, longitude: -30.0}));
  user.set('avatar', 'A string');
  user.set('AccountType', 'A string');
  user.set('Provider', 'A string');
  user.set('Name', 'A string');
  user.set('company', 'A string');
  user.set('Full_Name', 'A string');
  user.set('phone', 'A string');
  user.set('currentCarSuitabilityForEverydayUseRatng', 'A string');
  user.set('posters', [1, 'a string']);
  user.set('vip', 'A string');
  user.set('city', 'A string');
  user.set('confirmPassword', 'A string');
  user.set('address', 'A string');
  user.set('repass', 'A string');
  user.set('fisrtName', 'A string');
  user.set('password', '#Password123')

  try {
    let userResult = await user.signUp();
    Parse.User.logOut();
    console.log("User signed up. Please verify your e-mail")
  } catch (error) {
    console.error('Error while signing up user', error);
  }
})();
(async () => {
  const user: Parse.User = new Parse.User();
  user.set('username', 'A string');
  user.set('email', 'A string');
  user.set('firstName', 'A string');
  user.set('lastName', 'A string');
  user.set('birthDate', new Date());
  user.set('avatarPicture', new Parse.File("resume.txt", { base64: btoa("My file content") }));
  user.set('name', 'A string');
  user.set('imageUrl', 'A string');
  user.set('nativeFirstName', 'A string');
  user.set('nativeLastName', 'A string');
  user.set('mobilePhoneNumber', 'A string');
  user.set('role', 'A string');
  user.set('jobTitle', 'A string');
  user.set('active', true);
  user.set('fullName', 'A string');
  user.set('retypePassword', 'A string');
  user.set('phoneNumber', 'A string');
  user.set('repeatPassword', 'A string');
  user.set('idealCarSpeedRating', 'A string');
  user.set('currentCarYearWasMade', 'A string');
  user.set('idealCarHowMuchToBuyFor', 'A string');
  user.set('currentCarSpeedRating', 'A string');
  user.set('idealCarYearWasMade', 'A string');
  user.set('currentCarSpaceRating', 'A string');
  user.set('currentCarSafetyRating', 'A string');
  user.set('currentCarModel', 'A string');
  user.set('idealNextCarTrim', 'A string');
  user.set('currentCarSuitabilityForEverydayUseRating', 'A string');
  user.set('idealCarSuitabilityForEverydayUseRating', 'A string');
  user.set('idealCarSpaceRating', 'A string');
  user.set('currentCarWhenCarWasBought', 'A string');
  user.set('idealCarModel', 'A string');
  user.set('currentCarManufacturer', 'A string');
  user.set('currentCarTrim', 'A string');
  user.set('idealCarSafetyRating', 'A string');
  user.set('idealCarManufacturer', 'A string');
  user.set('idealCarWhenToPurchase', 'A string');
  user.set('idealCarComfortRating', 'A string');
  user.set('currentCarComfort', 'A string');
  user.set('currentCarHowMuchWasBoughtFor', 'A string');
  user.set('sessionToken', 'A string');
  user.set('currentGeoPoint', new Parse.GeoPoint({latitude: 40.0, longitude: -30.0}));
  user.set('avatar', 'A string');
  user.set('AccountType', 'A string');
  user.set('Provider', 'A string');
  user.set('Name', 'A string');
  user.set('company', 'A string');
  user.set('Full_Name', 'A string');
  user.set('phone', 'A string');
  user.set('currentCarSuitabilityForEverydayUseRatng', 'A string');
  user.set('posters', [1, 'a string']);
  user.set('vip', 'A string');
  user.set('city', 'A string');
  user.set('confirmPassword', 'A string');
  user.set('address', 'A string');
  user.set('repass', 'A string');
  user.set('fisrtName', 'A string');
  user.set('password', '#Password123');

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

Example Output:

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

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

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

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

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

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

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

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

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

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

    await user.SignUpAsync();

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

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

try {
  $user->signUp();

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

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

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

Log in

Code:

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

Example Output:

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

Finally, you may add your own code to provide feedback

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

public void loginUserWithEmailVerification() {

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

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

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

Requesting Password Reset

Example Request:

# Don't forget to set the target e-mail!
curl -X POST \
-H "X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-H "Content-Type: application/json" \
-d '{"email":"email@example.com"}' \
https://parseapi.back4app.com/requestPasswordReset

Example Response:

{}

Code:

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

Example Output:

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

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

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

Request

URL

https://parseapi.back4app.com/requestPasswordReset

Method

POST

Headers

X-Parse-Application-Id: 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:

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

Example Output:

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

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

import com.parse.ParseUser;

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

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

Request

URL

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

Method

GET

Headers

X-Parse-Application-Id: 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\",
  "firstName":\"A string\",
  "lastName":\"A string\",
  "birthDate":{ \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },
  "avatarPicture":{ \"__type\": \"File\", \"name\": \"resume.txt\" },
  "name":\"A string\",
  "imageUrl":\"A string\",
  "nativeFirstName":\"A string\",
  "nativeLastName":\"A string\",
  "mobilePhoneNumber":\"A string\",
  "role":\"A string\",
  "jobTitle":\"A string\",
  "active":true,
  "fullName":\"A string\",
  "retypePassword":\"A string\",
  "phoneNumber":\"A string\",
  "repeatPassword":\"A string\",
  "idealCarSpeedRating":\"A string\",
  "currentCarYearWasMade":\"A string\",
  "idealCarHowMuchToBuyFor":\"A string\",
  "currentCarSpeedRating":\"A string\",
  "idealCarYearWasMade":\"A string\",
  "currentCarSpaceRating":\"A string\",
  "currentCarSafetyRating":\"A string\",
  "currentCarModel":\"A string\",
  "idealNextCarTrim":\"A string\",
  "currentCarSuitabilityForEverydayUseRating":\"A string\",
  "idealCarSuitabilityForEverydayUseRating":\"A string\",
  "idealCarSpaceRating":\"A string\",
  "currentCarWhenCarWasBought":\"A string\",
  "idealCarModel":\"A string\",
  "currentCarManufacturer":\"A string\",
  "currentCarTrim":\"A string\",
  "idealCarSafetyRating":\"A string\",
  "idealCarManufacturer":\"A string\",
  "idealCarWhenToPurchase":\"A string\",
  "idealCarComfortRating":\"A string\",
  "currentCarComfort":\"A string\",
  "currentCarHowMuchWasBoughtFor":\"A string\",
  "sessionToken":\"A string\",
  "currentGeoPoint":{ \"__type\": \"GeoPoint\", \"latitude\": 40.0, \"longitude\": -30.0 },
  "avatar":\"A string\",
  "AccountType":\"A string\",
  "Provider":\"A string\",
  "Name":\"A string\",
  "company":\"A string\",
  "Full_Name":\"A string\",
  "phone":\"A string\",
  "currentCarSuitabilityForEverydayUseRatng":\"A string\",
  "posters":[ 1, \"a string\" ],
  "vip":\"A string\",
  "city":\"A string\",
  "confirmPassword":\"A string\",
  "address":\"A string\",
  "repass":\"A string\",
  "fisrtName":\"A string\"

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

Code:

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

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

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

Example Output:

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

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

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

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

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

Request

URL

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

Method

GET

Headers

X-Parse-Application-Id: 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\",\"firstName\": \"A string\",\"lastName\": \"A string\",\"birthDate\": { \"__type\": \"Date\", \"iso\": \"2018-11-06T18:02:52.249Z\" },\"avatarPicture\": { \"__type\": \"File\", \"name\": \"resume.txt\" },\"name\": \"A string\",\"imageUrl\": \"A string\",\"nativeFirstName\": \"A string\",\"nativeLastName\": \"A string\",\"mobilePhoneNumber\": \"A string\",\"role\": \"A string\",\"jobTitle\": \"A string\",\"active\": true,\"fullName\": \"A string\",\"retypePassword\": \"A string\",\"phoneNumber\": \"A string\",\"repeatPassword\": \"A string\",\"idealCarSpeedRating\": \"A string\",\"currentCarYearWasMade\": \"A string\",\"idealCarHowMuchToBuyFor\": \"A string\",\"currentCarSpeedRating\": \"A string\",\"idealCarYearWasMade\": \"A string\",\"currentCarSpaceRating\": \"A string\",\"currentCarSafetyRating\": \"A string\",\"currentCarModel\": \"A string\",\"idealNextCarTrim\": \"A string\",\"currentCarSuitabilityForEverydayUseRating\": \"A string\",\"idealCarSuitabilityForEverydayUseRating\": \"A string\",\"idealCarSpaceRating\": \"A string\",\"currentCarWhenCarWasBought\": \"A string\",\"idealCarModel\": \"A string\",\"currentCarManufacturer\": \"A string\",\"currentCarTrim\": \"A string\",\"idealCarSafetyRating\": \"A string\",\"idealCarManufacturer\": \"A string\",\"idealCarWhenToPurchase\": \"A string\",\"idealCarComfortRating\": \"A string\",\"currentCarComfort\": \"A string\",\"currentCarHowMuchWasBoughtFor\": \"A string\",\"sessionToken\": \"A string\",\"currentGeoPoint\": { \"__type\": \"GeoPoint\", \"latitude\": 40.0, \"longitude\": -30.0 },\"avatar\": \"A string\",\"AccountType\": \"A string\",\"Provider\": \"A string\",\"Name\": \"A string\",\"company\": \"A string\",\"Full_Name\": \"A string\",\"phone\": \"A string\",\"currentCarSuitabilityForEverydayUseRatng\": \"A string\",\"posters\": [ 1, \"a string\" ],\"vip\": \"A string\",\"city\": \"A string\",\"confirmPassword\": \"A string\",\"address\": \"A string\",\"repass\": \"A string\",\"fisrtName\": \"A string\" }" \
https://parseapi.back4app.com/users/<USER_OBJECT_ID>

Example Response:

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

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

Code:

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

  try {
    // Finds the user by its ID
    let user = await query.get('hEPjkt4epS');
    // Updates the data we want
    user.set('username', 'A string');
    user.set('email', 'A string');
    user.set('firstName', 'A string');
    user.set('lastName', 'A string');
    user.set('birthDate', new Date());
    user.set('avatarPicture', new Parse.File("resume.txt", { base64: btoa("My file content") }));
    user.set('name', 'A string');
    user.set('imageUrl', 'A string');
    user.set('nativeFirstName', 'A string');
    user.set('nativeLastName', 'A string');
    user.set('mobilePhoneNumber', 'A string');
    user.set('role', 'A string');
    user.set('jobTitle', 'A string');
    user.set('active', true);
    user.set('fullName', 'A string');
    user.set('retypePassword', 'A string');
    user.set('phoneNumber', 'A string');
    user.set('repeatPassword', 'A string');
    user.set('idealCarSpeedRating', 'A string');
    user.set('currentCarYearWasMade', 'A string');
    user.set('idealCarHowMuchToBuyFor', 'A string');
    user.set('currentCarSpeedRating', 'A string');
    user.set('idealCarYearWasMade', 'A string');
    user.set('currentCarSpaceRating', 'A string');
    user.set('currentCarSafetyRating', 'A string');
    user.set('currentCarModel', 'A string');
    user.set('idealNextCarTrim', 'A string');
    user.set('currentCarSuitabilityForEverydayUseRating', 'A string');
    user.set('idealCarSuitabilityForEverydayUseRating', 'A string');
    user.set('idealCarSpaceRating', 'A string');
    user.set('currentCarWhenCarWasBought', 'A string');
    user.set('idealCarModel', 'A string');
    user.set('currentCarManufacturer', 'A string');
    user.set('currentCarTrim', 'A string');
    user.set('idealCarSafetyRating', 'A string');
    user.set('idealCarManufacturer', 'A string');
    user.set('idealCarWhenToPurchase', 'A string');
    user.set('idealCarComfortRating', 'A string');
    user.set('currentCarComfort', 'A string');
    user.set('currentCarHowMuchWasBoughtFor', 'A string');
    user.set('sessionToken', 'A string');
    user.set('currentGeoPoint', new Parse.GeoPoint({latitude: 40.0, longitude: -30.0}));
    user.set('avatar', 'A string');
    user.set('AccountType', 'A string');
    user.set('Provider', 'A string');
    user.set('Name', 'A string');
    user.set('company', 'A string');
    user.set('Full_Name', 'A string');
    user.set('phone', 'A string');
    user.set('currentCarSuitabilityForEverydayUseRatng', 'A string');
    user.set('posters', [1, 'a string']);
    user.set('vip', 'A string');
    user.set('city', 'A string');
    user.set('confirmPassword', 'A string');
    user.set('address', 'A string');
    user.set('repass', 'A string');
    user.set('fisrtName', 'A string');
    try {
      // Saves the user with the updated data
      let response = await user.save();
      console.log('Updated user', response);
    } catch (error) {
      console.error('Error while updating user', error);
    }
  } catch (error) {
    console.error('Error while retrieving user', error);
  }
})();
(async () => {
  const User: Parse.User = new Parse.User();
  const query: Parse.Query = new Parse.Query(User);

  try {
    // Finds the user by its ID
    let user: Parse.Object = await query.get('hEPjkt4epS');
    // Updates the data we want
    user.set('username', 'A string');
    user.set('email', 'A string');
    user.set('firstName', 'A string');
    user.set('lastName', 'A string');
    user.set('birthDate', new Date());
    user.set('avatarPicture', new Parse.File("resume.txt", { base64: btoa("My file content") }));
    user.set('name', 'A string');
    user.set('imageUrl', 'A string');
    user.set('nativeFirstName', 'A string');
    user.set('nativeLastName', 'A string');
    user.set('mobilePhoneNumber', 'A string');
    user.set('role', 'A string');
    user.set('jobTitle', 'A string');
    user.set('active', true);
    user.set('fullName', 'A string');
    user.set('retypePassword', 'A string');
    user.set('phoneNumber', 'A string');
    user.set('repeatPassword', 'A string');
    user.set('idealCarSpeedRating', 'A string');
    user.set('currentCarYearWasMade', 'A string');
    user.set('idealCarHowMuchToBuyFor', 'A string');
    user.set('currentCarSpeedRating', 'A string');
    user.set('idealCarYearWasMade', 'A string');
    user.set('currentCarSpaceRating', 'A string');
    user.set('currentCarSafetyRating', 'A string');
    user.set('currentCarModel', 'A string');
    user.set('idealNextCarTrim', 'A string');
    user.set('currentCarSuitabilityForEverydayUseRating', 'A string');
    user.set('idealCarSuitabilityForEverydayUseRating', 'A string');
    user.set('idealCarSpaceRating', 'A string');
    user.set('currentCarWhenCarWasBought', 'A string');
    user.set('idealCarModel', 'A string');
    user.set('currentCarManufacturer', 'A string');
    user.set('currentCarTrim', 'A string');
    user.set('idealCarSafetyRating', 'A string');
    user.set('idealCarManufacturer', 'A string');
    user.set('idealCarWhenToPurchase', 'A string');
    user.set('idealCarComfortRating', 'A string');
    user.set('currentCarComfort', 'A string');
    user.set('currentCarHowMuchWasBoughtFor', 'A string');
    user.set('sessionToken', 'A string');
    user.set('currentGeoPoint', new Parse.GeoPoint({latitude: 40.0, longitude: -30.0}));
    user.set('avatar', 'A string');
    user.set('AccountType', 'A string');
    user.set('Provider', 'A string');
    user.set('Name', 'A string');
    user.set('company', 'A string');
    user.set('Full_Name', 'A string');
    user.set('phone', 'A string');
    user.set('currentCarSuitabilityForEverydayUseRatng', 'A string');
    user.set('posters', [1, 'a string']);
    user.set('vip', 'A string');
    user.set('city', 'A string');
    user.set('confirmPassword', 'A string');
    user.set('address', 'A string');
    user.set('repass', 'A string');
    user.set('fisrtName', 'A string');
    try {
      // Saves the user with the updated data
      let response: Parse.Object = await user.save();
      console.log('Updated user', response);
    } catch (error: any) {
      console.error('Error while updating user', error);
    }
  } catch (error: any) {
    console.error('Error while retrieving user', error);
  }
})();

Example Output:

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

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

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

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

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

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

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

Request

URL

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

Method

PUT

Headers

X-Parse-Application-Id: 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:

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

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

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

Example Output:

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

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

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

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

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

Request

URL

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

Method

DELETE

Headers

X-Parse-Application-Id: 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.

Logging Out

Example Request:

# Don't forget to set the SESSION_TOKEN and USER_OBJECT_ID parameters
curl -X POST \
-H "X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-H "X-Parse-Session-Token: <SESSION_TOKEN>" \
https://parseapi.back4app.com/logout

Example Response:

{}

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

Code:

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

Example Output:

User logged out
import com.parse.ParseUser;

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

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

Request

URL

https://parseapi.back4app.com/logout

Method

POST

Headers

X-Parse-Application-Id: 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:

(async () => {
  // Creates a new Query object to help us fetch MyCustomClass objects
  const query = new Parse.Query('MyCustomClass');
  try {
    // Executes the query, which returns an array of MyCustomClass
    const results = await query.find();
    console.log(`ParseObjects found: ${JSON.stringify(results)}`);
  } catch (error) {
    console.log(`Error: ${JSON.stringify(error)}`);
  }
})();
(async () => {
  // Creates a new Query object to help us fetch MyCustomClass objects
  const query: Parse.Query = new Parse.Query('MyCustomClass');
  try {
    // Executes the query, which returns an array of MyCustomClass
    const results: Parse.Query[] = await query.find();
    console.log(`ParseObjects found: ${JSON.stringify(results)}`);
  } catch (error: any) {
    console.log(`Error: ${JSON.stringify(error)}`);
  }
})();
curl -X GET \
  -H "X-Parse-Application-Id: 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 void runQuery() {

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

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

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

NSArray* results = [query findObjects];

// or use the the non-blocking method findObjectsInBackgroundWithBlock

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

let results = query.findObjects()

// or use the the non-blocking method findObjectsInBackground

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

use Parse\ParseQuery;

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

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

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

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

Counting Objects

Counting objects is as simple as that:

Code:

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

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

  try {
    // Uses 'count' instead of 'find' to retrieve the number of objects
    const count: number = await query.count();
    console.log(`ParseObjects found: ${count}`);
  } catch (error: any) {
    console.log(`Error: ${error}`);
  }
})();
curl -X GET \
  -H "X-Parse-Application-Id: 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 void runQuery() {
  ParseQuery<ParseObject> query = ParseQuery.getQuery("MyCustomClass");
  //We can query in two ways

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

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

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

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

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

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

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

Distinct Results

Code:

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

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

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

Example Request:

curl -X GET \
  -H "X-Parse-Application-Id: 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:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

$query = new ParseQuery('Post');

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            select post;

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

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

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

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

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

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

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

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

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

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

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

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

Example Request:

# Finds the Posts with title equal to "My post title" and
# with likes greater than 100
curl -X GET \
  -H "X-Parse-Application-Id: 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:

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

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

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

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

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

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

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

Example Request:

curl -X GET \
  -H "X-Parse-Application-Id: 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 void runQuery() {
  ParseQuery<ParseObject> query = ParseQuery.getQuery("Post");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Limit and Skip

Code:

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

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

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

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

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

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

  try {
    const results: Parse.Query[] = await query.find();
    console.log(`Posts found: ${JSON.stringify(results)}`);
  } catch (error: any) {
    console.log(`Error: ${JSON.stringify(error)}`);
  }
})();
# Finds 10 Posts, skipping the first 100 results
curl -X GET \
  -H "X-Parse-Application-Id: 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 void runQuery() {
  ParseQuery<ParseObject> query = ParseQuery.getQuery("Post");

  query.setLimit(10); // limit to at most 10 results
  query.setSkip(10); // skip the first 10 results

  query.findInBackground((objects, e) -> {
    if(e == null){
      for (ParseObject result : objects) {
        Log.d("Object found ",result.getObjectId());
      }
    }else{
        Toast.makeText(this, "Error: "+e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
PFQuery *query = [PFQuery queryWithClassName:@"Post"];

query.limit = 10; // limit to at most 10 results

query.skip = 10; // skip the first 10 results

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

query.limit = 10; // limit to at most 10 results

query.skip = 10; // skip the first 10 results

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

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

$query->limit(10); // limit to at most 10 results

$query->skip(10); // skip the first 10 results

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

var query = from post in ParseObject.GetQuery("Post")
            // limit to at most 10 results
            .Limit(10)

            // skip the first 10 results
            .Skip(10)

            select post;

// or using LINQ
var query = ParseObject.GetQuery("Post")
    .Limit(10) // limit to at most 10 results
    .Skip(10); // skip the first 10 results

If you need to limit the number of results or skip the first N results (useful when implementing pagination), you can do like so:

Relational Queries

Using object reference as a constraint:

(async () => {
  // Creates the Post
  const myPostObject = new Parse.Object('Post');

  myPostObject.set('content', 'First post! Yay!');
  try {
    const myPost = await myPostObject.save();
    // Creates the Comment
    const myCommentObject = new Parse.Object('Comment');

    myCommentObject.set('content', 'Congrats!');
    myCommentObject.set('post', myPost); // Sets 'myPost' and its post
    try {
      const myComment = await myCommentObject.save();
      // Finds only the comments that has 'myPost' as a post
      const query = new Parse.Query(Comment);
      query.equalTo('post', myPost);

      query.find().then((comments) => {
        console.log(`Comments found: ${JSON.stringify(comments)}`);
      });
    } catch (error) {
      console.log(`Error saving object: ${error}`);
    }
  } catch (error) {
    console.log(`Error saving object: ${error}`);
  }
})();
(async () => {
  // Creates the Post
  const myPostObject: Parse.Object = new Parse.Object('Post');

  myPostObject.set('content', 'First post! Yay!');
  try {
    const myPost: Parse.Object = await myPostObject.save();
    // Creates the Comment
    const myCommentObject: Parse.Object = new Parse.Object('Comment');

    myCommentObject.set('content', 'Congrats!');
    myCommentObject.set('post', myPost); // Sets 'myPost' and its post
    try {
      const myComment: Parse.Object = await myCommentObject.save();
      // Finds only the comments that has 'myPost' as a post
      const query: Parse.Object = new Parse.Query(Comment);
      query.equalTo('post', myPost);

      try {
        const comments: Parse.Object[] = await query.find();
        console.log(`Comments found: ${JSON.stringify(comments)}`);
      } catch (error: any) {
        console.log(`Error fetching objects: ${error}`);  
      }
    } catch (error: any) {
      console.log(`Error saving object: ${error}`);
    }
  } catch (error: any) {
    console.log(`Error saving object: ${error}`);
  }
})();
# Creates the Post
curl -X POST \
-H "X-Parse-Application-Id: 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 void runQuery() throws ParseException {
  // Creates the Post
  ParseObject myPost = new ParseObject("Post");
  myPost.put("content", "First post! Yay!");
  myPost.save();

  // Creates the Comment
  ParseObject myComment = new ParseObject("Comment");
  myComment.put("content", "Congrats!");
  myComment.put("post", myPost); // Sets "myPost" and its post
  myComment.save();

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

  // Finds only the comments that has "myPost" as a post
  query.whereEqualTo("post", myPost);

  query.findInBackground((objects, e) -> {
    if(e == null){
      for (ParseObject result : objects) {
        Log.d("Object found ",result.getObjectId());
      }
    }else{
        Toast.makeText(this, "Error: "+e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
// Creates the Post
PFObject *myPost = [PFObject objectWithClassName:@"Post"];
myPost[@"content"] = @"First post! Yay!";
[myPost save];

// Creates the Comment
PFObject *myComment = [PFObject objectWithClassName:@"Comment"];
myComment[@"content"] = @"Congrats!";
myComment[@"post"] = myPost;
[myComment save];

PFQuery *query = [PFQuery queryWithClassName:@"Comment"];
// Finds only the comments that has "myPost" as a post
[query whereKey:@"post" equalTo:myPost];

[query findObjectsInBackgroundWithBlock:^(NSArray *comments, NSError *error) {
    // comments now contains the comments for myPost
}];
// Creates the Post
var myPost = PFObject(className:"Post")
myPost["content"] = "First post! Yay!"
myPost.save();

var myComment = PFObject(className:"Comment")
myComment["content"] = "Congrats!"
myComment["post"] = myPost
myComment.save()

let query = PFQuery(className:"Post")
query.whereKey("post", equalTo: myPost)

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

// Creates the Post
$myPost = new ParseObject("Post");
$myPost->set('content', 'First post! Yay!');
$myPost.save();

// Creates the Comment
$myComment = new ParseObject("Comment");
$myComment->set('content', 'Congrats!');
$myComment->set('post', myPost); // Sets "myPost" and its post
$myComment.save();

// Finds only the comments that has "myPost" as a post
$query = new ParseQuery("Comment");
$query->equalTo("post", myPost);
$comments = $query->find();
foreach($comments as $result) {
  echo 'Object found ' . $result->getObjectId() . '<br>';
}
using Parse;

// Creates the Post
ParseObject myPost = new ParseObject("Post");
myPost["content"] = "First post! Yay!";
await myPost.SaveAsync();

// Creates the Comment
ParseObject myComment = new ParseObject("Comment");
myComment["content"] = "Congrats!";
await myComment.SaveAsync();

// Finds only the comments that has "myPost" as a post
var query = from comment in ParseObject.GetQuery("Comment")
            where comment["post"] == myPost
            select comment;

// or using LINQ
var query = ParseObject.GetQuery("Comment")
    .WhereEqualTo("post", myPost);

var comments = await query.FindAsync();
//comments now contains the comments for myPost

Alternatively, you can create relational queries using the objectId:

(async () => {
  // ... creates the query out of a class that have a relation with Post
  const query = new Parse.Query('Blog');

  const myPost = new Parse.Object('Post');
  myPost.id = '<OBJECT_ID>';

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

  try {
    const results = await query.find();
    console.log(`Comments found: ${JSON.stringify(results)}`);
  } catch (error) {
    console.log(`Error: ${error}`);
  }
})();
(async () => {
  // ... creates the query out of a class that have a relation with Post
  const query: Parse.Query = new Parse.Query('Blog');

  const myPost: Parse.Object = new Parse.Object('Post');
  myPost.id = '<OBJECT_ID>';

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

  try {
    const results: Parse.Object[] = await query.find();
    console.log(`Comments found: ${JSON.stringify(results)}`);
  } catch (error: any) {
    console.log(`Error: ${error}`);
  }
})();
// ... creates the query out of a class that have a relation with Post

// Just the objectId is enough to compare the object
[query whereKey:@"post" equalTo:[PFObject objectWithoutDataWithClassName:@"Post" objectId:@"<OBJECT_ID>"]];

// ... runs the query
// ... creates the query out of a class that have a relation with Post

// Just the objectId is enough to compare the object
query.whereKey("post", equalTo: PFObject(withoutDataWithClassName: "Post", objectId: "<OBJECT_ID>"))
// ... runs the query
use Parse\ParseObject;

// ... creates the query out of a class that have a relation with Post
$post = new ParseObject("Post", "<OBJECT_ID>");
$query->equalTo("post", $post);
// ... runs the query
using Parse;

var query = from comment in ParseObject.GetQuery("Comment")
            where comment["post"] == ParseObject.CreateWithoutData("Post", "<OBJECT_ID>")
            select comment;

// or using LINQ
var query = ParseObject.GetQuery("Comment")
    .WhereEqualTo("post", ParseObject.CreateWithoutData("Post", "<OBJECT_ID>"));

Creating relational constraints:

(async () => {
  const innerQuery = new Parse.Query('Post');

  innerQuery.exists('content');

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

  try {
    // Fetches only the comments whose posts contains content
    const comments = await query.find();
    console.log(`Comments found: ${JSON.stringify(comments)}`);
  } catch (error) {
    console.log(`Error: ${error}`);
  }
})();
(async () => {
  const innerQuery: Parse.Query = new Parse.Query('Post');

  innerQuery.exists('content');

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

    try {
      // Fetches only the comments whose posts contains content
      const comments: Parse.Object[] = await query.find();
      console.log(`Comments found: ${JSON.stringify(comments)}`);
    } catch (error: any) {
      console.log(`Error: ${error}`);
    }
  }
)();
# Fetches only the comments whose posts contains image
curl -X GET \
-H "X-Parse-Application-Id: 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 void runQuery() {
  ParseQuery<ParseObject> innerQuery = ParseQuery.getQuery("Post");
  innerQuery.whereExists("image");

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

  query.findInBackground((commentList, e) -> {
    if(e == null){
      for (ParseObject comment : commentList) {
        ParseObject post = comment.getParseObject("post");
        Log.d("Object found ",post.getObjectId());
      }
    }else{
        Toast.makeText(this, "Error: "+e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
PFQuery *innerQuery = [PFQuery queryWithClassName:@"Post"];
[innerQuery whereKeyExists:@"image"];
PFQuery *query = [PFQuery queryWithClassName:@"Comment"];
[query whereKey:@"post" matchesQuery:innerQuery];
[query findObjectsInBackgroundWithBlock:^(NSArray *comments, NSError *error) {
    // comments now contains the comments for posts with images
}];
let innerQuery = PFQuery(className: "Post")
innerQuery.whereKeyExists("image")
let query = PFQuery(className: "Comment")
query.whereKey("post", matchesQuery: innerQuery)
query.findObjectsInBackground { (comments: [PFObject]?, error: Error?) in
    if let error = error {
        // The request failed
        print(error.localizedDescription)
    } else {
        // comments now contains the comments for posts with images

    }
}
use Parse\ParseQuery;

$innerQuery = new ParseQuery("Post");
$innerQuery->exists("image");

$query = new ParseQuery("Comment");
$query->matchesQuery("post", $innerQuery);

// comments now contains the comments for posts with images.
$comments = $query->find();
foreach($comments as $result) {
  echo 'Object found ' . $result->getObjectId() . '<br>';
}
using Parse;

var innerQuery = from post in ParseObject.GetQuery("Post")
                 where post.ContainsKey("image")
                 select post;
var query = from comment in ParseObject.GetQuery("Comment")
            join post in innerQuery on comment["post"] equals post
            select comment;

var comments = await query.FindAsync();
// comments now contains the comments for posts with images

// or using LINQ
var innerQuery = ParseObject.GetQuery("Post")
    .WhereExists("image");
var query = ParseObject.GetQuery("Comment")
    .WhereMatchesQuery("post", innerQuery);

var comments = await query.FindAsync();
// comments now contains the comments for posts with images

Creating relational constraints (negation):

(async () => {
  const innerQuery = new Parse.Query('Post');
  innerQuery.greaterThan('likes', 50);

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

  try {
    // Fetches only the comments whose posts does NOT contains more than 50 likes
    const comments = await query.find();
    console.log(`Comments found: ${JSON.stringify(comments)}`);
  } catch (error) {
    console.log(`Error: ${error}`);
  }
})();
(async () => {
  const innerQuery: Parse.Query = new Parse.Query('Post');
  innerQuery.greaterThan('likes', 50);

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

  try {
    // Fetches only the comments whose posts does NOT contains more than 50 likes
    const comments: Parse.Object[] = await query.find();
    console.log(`Comments found: ${JSON.stringify(comments)}`);
  } catch (error: any) {
    console.log(`Error: ${error}`);
  }
})();
# Fetches only the comments whose posts does NOT contains more than 50 likes
curl -X GET \
-H "X-Parse-Application-Id: 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 void runQuery() {
  ParseQuery<ParseObject> innerQuery = ParseQuery.getQuery("Post");
  innerQuery.whereGreaterThan("likes", 50);

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

  query.findInBackground((commentList, e) -> {
    if(e == null){
      for (ParseObject comment : commentList) {
        ParseObject post = comment.getParseObject("post");
        Log.d("Object found ",post.getObjectId());
      }
    }else{
        Toast.makeText(this, "Error: "+e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
PFQuery *innerQuery = [PFQuery queryWithClassName:@"Post"];
[innerQuery whereKey:@"likes" greaterThan:@50];
PFQuery *query = [PFQuery queryWithClassName:@"Comment"];
[query whereKey:@"post" doesNotMatchQuery:innerQuery];
[query findObjectsInBackgroundWithBlock:^(NSArray *comments, NSError *error) {
  // Fetches only the comments whose posts does NOT contains more than 50 likes
}];
let innerQuery = PFQuery(className: "Post")
innerQuery.whereKey("image", greaterThan: 50)
let query = PFQuery(className: "Comment")
query.whereKey("post", doesNotMatch: innerQuery)
query.findObjectsInBackground { (comments: [PFObject]?, error: Error?) in
  if let error = error {
    // The request failed
    print(error.localizedDescription)
  } else {
    // Fetches only the comments whose posts does NOT contains more than 50 likes
  }
}
use Parse\ParseQuery;

$innerQuery = new ParseQuery("Post");
$innerQuery->greaterThan("likes", 50);

$query = new ParseQuery("Comment");
$query->doesNotMatchQuery("post", $innerQuery);

// Fetches only the comments whose posts does NOT contains more than 50 likes
$results = $query->find();
foreach($results as $result) {
  echo 'Object found ' . $result->getObjectId() . '<br>';
}
using Parse;

var innerQuery = from post in ParseObject.GetQuery("Post")
                 where post.ContainsKey("image")
                 select post;
var query = ParseObject.GetQuery("Comment")
    .WhereDoesNotMatchQuery("post", innerQuery);

var comments = await query.FindAsync();
// comments now contains the comments for posts without images

// or using LINQ
var innerQuery = ParseObject.GetQuery("Post")
    .WhereExists("image");
var query = ParseObject.GetQuery("Comment")
    .WhereDoesNotMatchQuery("post", innerQuery);

var comments = await query.FindAsync();
// comments now contains the comments for posts without images

Initializing a related object:

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

  // Include the post data with each comment
  query.include('post');

  // You also can initialize multiple levels of relations
  // query.include(['post.author']); // Initializes the post and its author

  try {
    // Comments now contains the 'post' field initialized!
    const comments = await query.find();
    const posts = comments.map(function (comment) {
      return comment.get('post');
    });
    console.log(`Posts found: ${JSON.stringify(posts)}`);
  } catch (error) {
    console.log(`Error: ${error}`);
  }
})();
(async () => {
  const query: Parse.Query = new Parse.Query('Comment');

  // Include the post data with each comment
  query.include('post');

  // You also can initialize multiple levels of relations
  // query.include(['post.author']); // Initializes the post and its author

  try {
    // Comments now contains the 'post' field initialized!
    const comments: Parse.Object[] = await query.find();
    const posts: Parse.Object[] = comments.map(function (comment) {
      return comment.get('post');
    });
    console.log(`Posts found: ${JSON.stringify(posts)}`);
  } catch (error: any) {
    console.log(`Error: ${error}`);
  }
})();
curl -X GET \
-H "X-Parse-Application-Id: 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 void runQuery() {
  ParseQuery<ParseObject> query = ParseQuery.getQuery("Comment");

  // Include the post data with each comment
  query.include("post");

  // You also can initialize multiple levels of relations
  // query.include("post.author");

  query.findInBackground((commentList, e) -> {
    if(e == null){
      for (ParseObject comment : commentList) {
        // This does not require a network access.
        ParseObject post = comment.getParseObject("post");
        Log.d("Object found ",post.getObjectId());
      }
    }else{
        Toast.makeText(this, "Error: "+e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
PFQuery *query = [PFQuery queryWithClassName:@"Comment"];

// Include the post data with each comment
[query includeKey:@"post"];

// You also can initialize multiple levels of relations
// [query includeKey:@"post.author"];

[query findObjectsInBackgroundWithBlock:^(NSArray *comments, NSError *error) {
    // Comments now contains the "post" field
    // has been populated. For example:
    for (PFObject *comment in comments) {
         // This does not require a network access.
         PFObject *post = comment[@"post"];
         NSLog(@"retrieved related post: %@", post);
    }
}];
let query = PFQuery(className:"Comment")

// Include the post data with each comment
query.includeKey("post")

// You also can initialize multiple levels of relations
// query.includeKey("post.author")

query.findObjectsInBackground { (comments: [PFObject]?, error: Error?) in
  if let error = error {
    // The request failed
    print(error.localizedDescription)
  } else if let comments = comments {
    // Comments now contains the "post" field
    for comment in comments {
      // This does not require a network access.
      let post = comment["post"] as? PFObject
      print("retrieved related post: \(String(describing: post))")
    }
  }
}
use Parse\ParseQuery;

$query = new ParseQuery("Comment");

// Include the post data with each comment
query->includeKey("post");

// You also can initialize multiple levels of relations
// query->include("post.author"); // Initializes the post and its author

// Comments now contains the "post" field initialized!
$comments = query->find();
foreach($comments as $comment) {
  $post = $comment->get("post");
  echo 'Object found ' . $post->getObjectId() . '<br>';
}
using Parse;

var query = from comment in ParseObject.GetQuery("Comment")
            // Include the post data with each comment
            .Include("post")
            // You also can initialize multiple levels of relations
            // .Include("post.author")
            select comment;

var comments = await query.FindAsync();
// Comments now contains the "post" field

// or using LINQ
var query = ParseObject.GetQuery("Comment")
    // Include the post data with each comment
    .Include("post");
    // You also can initialize multiple levels of relations
    // .Include("post.author");

var comments = await query.FindAsync();
// Comments now contains the "post" field

Query supports creating constraints that evaluates if a field matches a particular Parse Object. It allows you to fetch only the objects that contains a specific relation with another object.

There are cases when you need to evaluate some related object fields in order to build a query with refined results.

That can be done by creating a inner query whose constraints will be applied only on the related field you want to evaluate, those are known as relational constraints and are also demonstrated in this section.

Using AND / OR operators

OR operator:

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

  const specificPostQuery = new Parse.Query(Post);
  specificPostQuery.equalTo('title', 'My great post');

  // The query is satisfied when one of the constraints matches
  const composedQuery = Parse.Query.or(manyLikesQuery, specificPostQuery);

  try {
    // Fetches the posts with more than 1000 likes OR posts with the title 'My great post'
    const posts = await composedQuery.find();
    console.log(`Posts found: ${JSON.stringify(posts)}`);
  } catch (error) {
    console.log(`Error: ${error}`);
  }
})();
(async () => {
  // 'Post' is just an arbitrary class, replace it with your custom class
  const manyLikesQuery: Parse.Query = new Parse.Query('Post');
  manyLikesQuery.greaterThan('likes', 1000);

  const specificPostQuery: Parse.Query = new Parse.Query(Post);
  specificPostQuery.equalTo('title', 'My great post');

  // The query is satisfied when one of the constraints matches
  const composedQuery: Parse.Query = Parse.Query.or(manyLikesQuery, specificPostQuery);

  try {
    // Fetches the posts with more than 1000 likes OR posts with the title 'My great post'
    const posts: Parse.Object[] = await composedQuery.find();
    console.log(`Posts found: ${JSON.stringify(posts)}`);
  } catch (error: any) {
    console.log(`Error: ${error}`);
  }
})();
curl -X GET \
-H "X-Parse-Application-Id: 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 void runQuery() {
  ParseQuery<ParseObject> manyLikesQuery = ParseQuery.getQuery("Post");
  manyLikesQuery.whereGreaterThan("likes", 1000);

  ParseQuery<ParseObject> specificPostQuery = ParseQuery.getQuery("Post");
  specificPostQuery.whereEqualTo("title", "My great post");

  List<ParseQuery<ParseObject>> queries = new ArrayList<ParseQuery<ParseObject>>();
  queries.add(manyLikesQuery);
  queries.add(specificPostQuery);

  ParseQuery<ParseObject> mainQuery = ParseQuery.or(queries);

  // Fetches the posts with more than 1000 likes OR posts with the title "My great post"
  mainQuery.findInBackground((postList, e) -> {
    if(e == null){
      for (ParseObject post : postList) {
        Log.d("Object found ",post.getObjectId());
      }
    }else{
        Toast.makeText(this, "Error: "+e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
PFQuery *manyLikesQuery = [PFQuery queryWithClassName:@"Post"];
[manyLikesQuery whereKey:@"likes" greaterThan:@1000];

PFQuery *specificPostQuery = [PFQuery queryWithClassName:@"Post"];
[specificPostQuery whereKey:@"title" equalTo:@"My great post"];

PFQuery *query = [PFQuery orQueryWithSubqueries:@[manyLikesQuery,specificPostQuery]];
[query findObjectsInBackgroundWithBlock:^(NSArray *results, NSError *error) {
  // Fetches the posts with more than 1000 likes OR posts with the title "My great post"
}];
let manyLikesQuery = PFQuery(className:"Post")
manyLikesQuery.whereKey("likes", greaterThan:1000)

let specificPostQuery = PFQuery(className:"Player")
specificPostQuery.whereKey("title", equalTo:"My great post")

let query = PFQuery.orQuery(withSubqueries: [manyLikesQuery, specificPostQuery])
query.findObjectsInBackground { (results: [PFObject]?, error: Error?) in
  if let error = error {
    // The request failed
    print(error.localizedDescription)
  } else {
    // Fetches the posts with more than 1000 likes OR posts with the title "My great post"
  }
}
use Parse\ParseQuery;

$manyLikesQuery = new ParseQuery("Post");
$manyLikesQuery->greaterThan("likes", 1000);

$specificPostQuery = new ParseQuery("Player");
$specificPostQuery->equalTo("title", "My great post");

// The query is satisfied when one of the constraints matches
$mainQuery = ParseQuery::orQueries([$manyLikesQuery, $specificPostQuery]);

// Fetches the posts with more than 1000 likes OR posts with the title "My great post"
$results = $mainQuery->find();
foreach($results as $result) {
  echo 'Object found ' . $result->getObjectId() . '<br>';
}
using Parse;

var manyLikesQuery = from post in ParseObject.GetQuery("Post")
                 where post.Get<int>("likes") > 1000
                 select post;

var specificPostQuery = from post in ParseObject.GetQuery("Post")
              where post.Get<string>("title") == "My great post"
              select post;

ParseQuery<ParseObject> query = manyLikesQuery.Or(specificPostQuery);

var results = await query.FindAsync();
// Fetches the posts with more than 1000 likes OR posts with the title "My great post"

// or using LINQ
var manyLikesQuery = ParseObject.GetQuery("Post")
    .WhereGreaterThan("likes", 1000);

var specificPostQuery = ParseObject.GetQuery("Post")
    .WhereEqualTo("title", "My great post");

ParseQuery<ParseObject> query = manyLikesQuery.Or(specificPostQuery);
// Fetches the posts with more than 1000 likes OR posts with the title "My great post"

AND operator:

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

  const specificPostQuery = new Parse.Query(Post);
  specificPostQuery.equalTo('title', 'My great post');

  const loggedUser = Parse.User.current();
  const authorQuery = new Parse.Query(Post);
  authorQuery.equalTo('author', loggedUser);

  // The query is satisfied when both of the constraints matches.
  // You can combine multiple AND and OR operators in order to create
  // even more complex queries
  const composedQuery = Parse.Query.and(
    Parse.Query.or(manyLikesQuery, specificPostQuery),
    authorQuery
  );

  try {
    // Fetches the posts with more than 1000 likes OR posts with the title 'My great post',
    // and the logged user is the author of the post
    const posts = await composedQuery.find();
    console.log(`Posts found: ${JSON.stringify(posts)}`);
  } catch (error) {
    console.log(`Error: ${error}`);
  }
})();
(async () => {
  // 'Post' is just an arbitrary class, replace it with your custom class
  const manyLikesQuery: Parse.Query = new Parse.Query('Post');
  manyLikesQuery.greaterThan('likes', 1000);

  const specificPostQuery: Parse.Query = new Parse.Query(Post);
  specificPostQuery.equalTo('title', 'My great post');

  const loggedUser: Parse.User = Parse.User.current();
  const authorQuery: Parse.Query = new Parse.Query(Post);
  authorQuery.equalTo('author', loggedUser);

  // The query is satisfied when both of the constraints matches.
  // You can combine multiple AND and OR operators in order to create
  // even more complex queries
  const composedQuery: Parse.Query = Parse.Query.and(
    Parse.Query.or(manyLikesQuery, specificPostQuery),
    authorQuery
  );

  try {
    // Fetches the posts with more than 1000 likes OR posts with the title 'My great post',
    // and the logged user is the author of the post
    const posts: Parse.Object[] = await composedQuery.find();
    console.log(`Posts found: ${JSON.stringify(posts)}`);
  } catch (error: any) {
    console.log(`Error: ${error}`);
  }
})();
# Fetches the posts with more than 1000 likes OR posts with the title "My great post",
# and a specific user is the author of the post
curl -X GET \
-H "X-Parse-Application-Id: 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 void runQuery() {
  String className = "Post";

  ParseQuery<ParseObject> manyLikesQuery = ParseQuery.getQuery(className);
  manyLikesQuery.whereGreaterThan("likes", 1000);

  ParseUser loggedUser = ParseUser.getCurrentUser();
  ParseQuery<ParseObject> specificPostQuery = ParseQuery.getQuery(className);
  specificPostQuery.whereEqualTo("title", "My great post"); // title equals to "My great post"
  specificPostQuery.whereEqualTo("author", loggedUser); // AND author equals loggedUser

  List<ParseQuery<ParseObject>> queries = new ArrayList<ParseQuery<ParseObject>>();
  queries.add(manyLikesQuery);
  queries.add(specificPostQuery);

  ParseQuery<ParseObject> mainQuery = ParseQuery.or(queries);

  // The query is satisfied when both of the constraints matches.
  // You can combine multiple AND and OR operators in order to create
  // even more complex queries

  // Fetches the posts with more than 1000 likes OR posts with the title "My great post"
  // and the logged user is the author of the post
  mainQuery.findInBackground((postList, e) -> {
    if(e == null){
      for (ParseObject post : postList) {
        Log.d("Object found ",post.getObjectId());
      }
    }else{
        Toast.makeText(this, "Error: "+e.getMessage(), Toast.LENGTH_SHORT).show();
    }
  });
}
PFQuery *manyLikesQuery = [PFQuery queryWithClassName:@"Post"];
[manyLikesQuery whereKey:@"likes" greaterThan:@1000];

PFQuery *specificPostQuery = [PFQuery queryWithClassName:@"Post"];
[specificPostQuery whereKey:@"title" equalTo:@"My great post"];

PFUser *loggedUser = [PFUser loggedUser];

PFQuery *query = [PFQuery orQueryWithSubqueries:@[manyLikesQuery,specificPostQuery]];
[query whereKey:@"author" equalTo:@loggedUser];

[query findObjectsInBackgroundWithBlock:^(NSArray *results, NSError *error) {
  // Fetches the posts with more than 1000 likes OR posts with the title "My great post",
  // and the logged user is the author of the post
}];
let manyLikesQuery = PFQuery(className:"Post")
manyLikesQuery.whereKey("likes", greaterThan:1000)

let specificPostQuery = PFQuery(className:"Post")
specificPostQuery.whereKey("title", equalTo:"My great post")

let loggedUser = PFUser.loggedUser()

let query = PFQuery.orQuery(withSubqueries: [manyLikesQuery, specificPostQuery])
query.whereKey("author", equalTo:loggedUser)

query.findObjectsInBackground { (results: [PFObject]?, error: Error?) in
  if let error = error {
    // The request failed
    print(error.localizedDescription)
  } else {
    // Fetches the posts with more than 1000 likes OR posts with the title "My great post",
    // and the logged user is the author of the post
  }
}
use Parse\ParseQuery;

$manyLikesQuery = new ParseQuery("Post");
$manyLikesQuery->greaterThan("likes", 1000);

$specificPostQuery = new ParseQuery("Player");
$specificPostQuery->equalTo("title", "My great post");

$loggedUser = ParseUser::getCurrentUser();

// The query is satisfied when one of the constraints matches
$mainQuery = ParseQuery::orQueries([$manyLikesQuery, $specificPostQuery]);

$mainQuery->equalTo("author", $loggedUser)

// Fetches the posts with more than 1000 likes OR posts with the title "My great post",
// and the logged user is the author of the post
$results = $mainQuery->find();
foreach($results as $result) {
  echo 'Object found ' . $result->getObjectId() . '<br>';
}

In order to create more complex queries, you will often need to create multiple constraints and combining them using logical operators OR and AND.

By using both operators, Query enables us to combine multiple subqueries, thus applying different sets of constraints. This way, we can achieve a higher level of complexity but also get even more refined results from our queries.

Aggregation

Grouping the results using a field value:

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

  // Grouping the results by the number of likes.
  // We need to use $ to indicate 'tags' is the name of the field
  // we want to use as our objectId
  const pipeline = {
    group: { objectId: '$tags' },
  };

  try {
    // results contains unique content values
    // The results are similar to the distinct feature
    const results = await query.aggregate(pipeline);
    console.log(`Posts grouped by tags found: ${JSON.stringify(results)}`);
  } catch (error) {
    console.log(`Error: ${error}`);
  }
})();
(async () => {
  // 'Post' is just an arbitrary class, replace it with your custom class
  const query: Parse.Query = new Parse.Query('Post');

  // Grouping the results by the number of likes.
  // We need to use $ to indicate 'tags' is the name of the field
  // we want to use as our objectId
  const pipeline: any = {
    group: { objectId: '$tags' },
  };

  try {
    // results contains unique content values
    // The results are similar to the distinct feature
    const results: Parse.Object[] = await query.aggregate(pipeline);
    console.log(`Posts grouped by tags found: ${JSON.stringify(results)}`);
  } catch (error: any) {
    console.log(`Error: ${error}`);
  }
})();
# Grouping the results by the number of likes.
# We need to use $ to indicate "content" is the name of the field
# we want to use as our objectId

curl -X GET \
-H "X-Parse-Application-Id: 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:

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

  const pipeline = {
    group: {
      objectId: null,
      total: { $sum: '$likes' }, // 'total' will be a created field to hold the sum of likes field
      average: { $avg: '$likes' }, // 'average' will be a created field to hold the average of likes field
      maxLikes: { $max: '$likes' }, // 'maxLikes' will be a created field to hold the maximum value of likes field
      minLikes: { $min: '$likes' }, // 'minLikes' will be a created field to hold the minimum value of likes field
    },
  };
  // Notice that 'total', 'average', 'maxLikes', 'minLikes' are just arbitrary names,
  // and could be anything you want

  try {
    // results[0] should contain 'total', 'average', 'maxLikes' and 'minLikes' as attribute
    // You can access them like this: results[0].total
    const results = await query.aggregate(pipeline);
    console.log(`Aggregated results: ${JSON.stringify(results)}`);
  } catch (error) {
    console.log(`Error: ${error}`);
  }
})();
(async () => {
  // 'Post' is just an arbitrary class, replace it with your custom class
  const query: Parse.Query = new Parse.Query('Post');

  const pipeline: any = {
    group: {
      objectId: null,
      total: { $sum: '$likes' }, // 'total' will be a created field to hold the sum of likes field
      average: { $avg: '$likes' }, // 'average' will be a created field to hold the average of likes field
      maxLikes: { $max: '$likes' }, // 'maxLikes' will be a created field to hold the maximum value of likes field
      minLikes: { $min: '$likes' }, // 'minLikes' will be a created field to hold the minimum value of likes field
    },
  };
  // Notice that 'total', 'average', 'maxLikes', 'minLikes' are just arbitrary names,
  // and could be anything you want

  try {
    // results[0] should contain 'total', 'average', 'maxLikes' and 'minLikes' as attribute
    // You can access them like this: results[0].total
    const results: Parse.Object[] = await query.aggregate(pipeline);
    console.log(`Aggregated results: ${JSON.stringify(results)}`);
  } catch (error: any) {
    console.log(`Error: ${error}`);
  }
})();
curl -X GET \
-H "X-Parse-Application-Id: 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