### Install Parse Server and Start MongoDB Runner Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/graphql/api-doc.md Install the necessary packages globally and start the MongoDB runner before launching the Parse Server. ```bash $ npm install -g parse-server mongodb-runner $ mongodb-runner start $ parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongodb://localhost/test --mountGraphQL --mountPlayground ``` -------------------------------- ### GET Request with Redirects Enabled (Example) Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/cloudcode/cloud-code-advanced.md Demonstrates enabling redirects for GET requests. This is a repeat of a previous example for clarity. ```javascript Parse.Cloud.httpRequest({ url: 'http://www.example.com/', followRedirects: true }).then(function(httpResponse) { console.log(httpResponse.text); }, function(httpResponse) { console.error('Request failed with response code ' + httpResponse.status); }); ``` -------------------------------- ### Bootstrap Parse Server Locally Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/parse-server/getting-started.md Use this script to quickly set up Parse Server and its dependencies for local development. Ensure Node.js and MongoDB are installed. This command installs the Parse Server globally, starts a MongoDB runner, and then starts the Parse Server. ```bash sh <(curl -fsSL https://raw.githubusercontent.com/parse-community/parse-server/master/bootstrap.sh) npm install -g mongodb-runner mongodb-runner start npm start ``` -------------------------------- ### Install and Run Parse GraphQL Server via CLI Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/graphql/getting-started.md Install necessary packages and start the Parse GraphQL Server using the command line. Ensure you replace placeholder values for appId, masterKey, and databaseURI. ```bash npm install -g parse-server mongodb-runner mongodb-runner start parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongodb://localhost/test --mountGraphQL --mountPlayground ``` -------------------------------- ### Querying Installations Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/rest/push-notifications.md Retrieve multiple installations by sending a GET request to the root installations URL. This requires authentication with the X-Parse-Master-Key header. ```APIDOC ## GET /parse/installations ### Description Retrieves a list of all installations. This endpoint requires master key authentication. ### Method GET ### Endpoint /parse/installations ### Parameters #### Headers - **X-Parse-Application-Id** (string) - Required - Your Parse Application ID. - **X-Parse-Master-Key** (string) - Required - Your Parse Master Key. ### Response #### Success Response (200) - **results** (array) - An array of installation objects. ### Response Example ```json { "results": [ { "deviceType": "ios", "deviceToken": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", "channels": [ "" ], "createdAt": "2022-01-01T12:23:45.678Z", "updatedAt": "2022-01-01T12:23:45.678Z", "objectId": "mrmBZvsErB" } ] } ``` ``` -------------------------------- ### Project Setup for Express.js Integration Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/graphql/getting-started.md Create a new project directory, initialize npm, and install the required parse-server and express dependencies. ```bash mkdir my-app cd my-app npm init npm install parse-server express --save ``` -------------------------------- ### Retrieving Installations Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/rest/push-notifications.md You can retrieve the contents of an installation object by sending a GET request to the URL returned in the location header when it was created. ```APIDOC ## GET /parse/installations/ ### Description Retrieves a specific installation object. ### Method GET ### Endpoint /parse/installations/ ### Parameters #### Path Parameters - **installation_id** (string) - Required - The unique identifier for the installation. #### Headers - **X-Parse-Application-Id** (string) - Required - Your Parse application ID. - **X-Parse-REST-API-Key** (string) - Required - Your Parse REST API Key. ### Response #### Success Response (200) - **deviceType** (string) - The type of device (e.g., "ios", "android"). - **deviceToken** (string) - The device token for push notifications. - **channels** (array) - An array of channels the installation is subscribed to. - **createdAt** (string) - The date and time the installation was created. - **updatedAt** (string) - The date and time the installation was last updated. - **objectId** (string) - The unique identifier for the installation object. #### Response Example ```json { "deviceType": "ios", "deviceToken": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", "channels": [ "" ], "createdAt": "2022-01-01T12:23:45.678Z", "updatedAt": "2022-01-01T12:23:45.678Z", "objectId": "mrmBZvsErB" } ``` ``` -------------------------------- ### Query Installations with Master Key Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/rest/push-notifications.md Retrieve multiple installations using a GET request to the installations endpoint. Requires `X-Parse-Master-Key` for authentication, bypassing ACLs. Use this from a trusted environment. ```bash curl -X GET \ -H "X-Parse-Application-Id: ${APPLICATION_ID}" \ -H "X-Parse-Master-Key: ${MASTER_KEY}" \ https://YOUR.PARSE-SERVER.HERE/parse/installations ``` ```python import http.client import json connection = http.client.HTTPSConnection('YOUR.PARSE-SERVER.HERE', 443) connection.connect() connection.request('GET', '/parse/installations', '', { "X-Parse-Application-Id": "${APPLICATION_ID}", "X-Parse-Master-Key": "${MASTER_KEY}" }) result = json.loads(connection.getresponse().read()) print(result) ``` -------------------------------- ### Install PostgreSQL Server Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/parse-server/deploying-aws-ubuntu.md Install the PostgreSQL database server on the Ubuntu instance. ```bash sudo apt-get -y install postgresql ``` -------------------------------- ### Send Push to Installations Matching a Query Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/rest/push-notifications.md Use a 'where' clause in your push request to target installations that match specific criteria. This example targets installations where 'injuryReports' is true. ```bash curl -X POST \ -H "X-Parse-Application-Id: ${APPLICATION_ID}" \ -H "X-Parse-REST-API-Key: ${REST_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "where": { "injuryReports": true }, "data": { "alert": "Willie Hayes injured by own pop fly." } }' \ https://YOUR.PARSE-SERVER.HERE/parse/push ``` ```python import http.client import json connection = http.client.HTTPSConnection('YOUR.PARSE-SERVER.HERE', 443) connection.connect() connection.request('POST', '/parse/push', json.dumps({ "where": { "injuryReports": True }, "data": { "alert": "Willie Hayes injured by own pop fly." } }), { "X-Parse-Application-Id": "${APPLICATION_ID}", "X-Parse-REST-API-Key": "${REST_API_KEY}", "Content-Type": "application/json" }) result = json.loads(connection.getresponse().read()) print(result) ``` -------------------------------- ### Start Push Notification Service Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/arduino/push-notifications.md Call this function in your `setup` function to enable the Arduino to receive push notifications. ```cpp Parse.startPushService(); ``` -------------------------------- ### Send Push to Installations Matching Multiple Query Conditions Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/php/push-notifications.md Combine multiple query conditions to filter installations. This example targets iOS devices subscribed to the 'Giants' channel who also want score updates. ```php $query = ParseInstallation::query(); $query->equalTo("channels", "Giants"); $query->equalTo("scores", true); ParsePush::send(array( "where" => $query, "data" => array( "alert" => "Giants scored against the A's! It's now 2-2." ) ), true); ``` -------------------------------- ### Send Push to Installations Matching a Query Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/php/push-notifications.md Use a Parse query to target a subset of devices for push notifications. This example targets installations with the 'design' field set to 'rad'. ```php $query = ParseInstallation::query(); $query->equalTo("design", "rad"); ParsePush::send(array( "where" => $query, "data" => $data ), true); ``` -------------------------------- ### Installation Creation Success Response Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/rest/push-notifications.md Upon successful creation of an installation object, the API returns a 201 Created status and a Location header containing the URL to the newly created installation. ```javascript Status: 201 Created Location: https://YOUR.PARSE-SERVER.HERE/parse/installations/mrmBZvsErB ``` -------------------------------- ### Basic GET Request Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/cloudcode/cloud-code-advanced.md This example demonstrates a basic GET request to a specified URL. The `then` function handles both successful responses and errors. ```APIDOC ## GET Parse.Cloud.httpRequest ### Description Sends an HTTP GET request to the specified URL. ### Method GET ### Endpoint `Parse.Cloud.httpRequest` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript Parse.Cloud.httpRequest({ url: 'https://www.awesomewebsite.com/' }).then(function(httpResponse) { // success console.log(httpResponse.text); },function(httpResponse) { // error console.error('Request failed with response code ' + httpResponse.status); }); ``` ### Response #### Success Response (200) - **text** (string) - The response body as text. #### Response Example ```json { "text": "Response body content" } ``` ``` -------------------------------- ### Basic ParseQueryAdapter Setup Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/android/user-interface.md Instantiate a ParseQueryAdapter to display data from a Parse class in a ListView. This example sets the text and image keys for the displayed items. ```java public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ParseQueryAdapter adapter = new ParseQueryAdapter(this, "Instrument"); adapter.setTextKey("name"); adapter.setImageKey("photo"); ListView listView = (ListView) findViewById(R.id.listview); listView.setAdapter(adapter); } ``` -------------------------------- ### Send Push to Installation Query Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/js/push-notifications.md Send a push notification to a subset of Installation objects that match a specific query. This allows for targeted messaging based on Installation data. ```javascript const query = new Parse.Query(Parse.Installation); query.equalTo('injuryReports', true); Parse.Push.send({ where: query, // Set our Installation query data: { alert: "Willie Hayes injured by own pop fly." } }) .then(function() { // Push was successful }, function(error) { // Handle error }); ``` -------------------------------- ### Installations API Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/rest/quick-reference.md Endpoints for managing installation data. ```APIDOC ## POST /parse/installations ### Description Uploads installation data. ### Method POST ### Endpoint /parse/installations ``` ```APIDOC ## GET /parse/installations/ ### Description Retrieves a specific installation by its object ID. ### Method GET ### Endpoint /parse/installations/ ``` ```APIDOC ## PUT /parse/installations/ ### Description Updates an existing installation. ### Method PUT ### Endpoint /parse/installations/ ``` ```APIDOC ## GET /parse/installations ### Description Queries for installations based on specified criteria. ### Method GET ### Endpoint /parse/installations ``` ```APIDOC ## DELETE /parse/installations/ ### Description Deletes a specific installation by its object ID. ### Method DELETE ### Endpoint /parse/installations/ ``` -------------------------------- ### Install NodeJS Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/parse-server/deploying-aws-ubuntu.md Install NodeJS on the Ubuntu instance. This is a prerequisite for running Parse Server. ```bash sudo apt install nodejs ``` -------------------------------- ### Install Yarn Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/parse-server/deploying-aws-ubuntu.md Install Yarn, a package manager for JavaScript, globally on the system. ```bash sudo npm install yarn –g ``` -------------------------------- ### Install Build Tools for Embedded C SDK Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/embedded_c/getting-started.md Installs necessary tools for building the SDK on a Linux system. ```bash sudo apt-get update sudo apt-get install autoconf automake libtool sudo apt-get install libcurl4-openssl-dev uuid-dev ``` -------------------------------- ### Retrieve Installation Object Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/rest/push-notifications.md Use this to fetch the details of a specific push notification installation. Ensure you have the correct installation object ID. ```bash curl -X GET \ -H "X-Parse-Application-Id: ${APPLICATION_ID}" \ -H "X-Parse-REST-API-Key: ${REST_API_KEY}" \ https://YOUR.PARSE-SERVER.HERE/parse/installations/mrmBZvsErB ``` ```python import http.client import json connection = http.client.HTTPSConnection('YOUR.PARSE-SERVER.HERE', 443) connection.connect() connection.request('GET', '/parse/installations/mrmBZvsErB', '', { "X-Parse-Application-Id": "${APPLICATION_ID}", "X-Parse-REST-API-Key": "${REST_API_KEY}" }) result = json.loads(connection.getresponse().read()) print(result) ``` -------------------------------- ### Install npm Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/parse-server/deploying-aws-ubuntu.md Install npm (Node Package Manager) on the Ubuntu instance. This is used for managing Node.js packages. ```bash sudo apt install npm ``` -------------------------------- ### Install Jekyll and npm Packages Source: https://github.com/parse-community/docs/blob/gh-pages/README.md Install Jekyll and node packages required for running the Parse documentation site locally. Ensure Ruby and npm are installed first. ```bash bundle install npm install ``` -------------------------------- ### Full LiveQuery Server Configuration Example Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/parse-server/live-query.md This is a comprehensive example of the configuration object for the LiveQuery server. It includes required and optional parameters for setting up the server, such as application IDs, keys, server URLs, and timeouts. ```javascript { appId: 'myAppId', masterKey: 'myMasterKey', keyPairs: { "restAPIKey": "", "javascriptKey": "", "clientKey": "", "windowsKey": "", "masterKey": "" }, serverURL: 'serverURL', websocketTimeout: 10 * 1000, cacheTimeout: 60 * 600 * 1000, logLevel: 'VERBOSE' } ``` -------------------------------- ### Start Express.js Application Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/graphql/getting-started.md Run the MongoDB runner and then start your Node.js application to serve the Parse Server and GraphQL API. ```bash npx mongodb-runner start node index.js ``` -------------------------------- ### Initialize LiveQuery Server Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/parse-server/live-query.md Set up and start the LiveQuery server by creating an HTTP server and passing it to ParseServer.createLiveQueryServer. ```javascript // Initialize a LiveQuery server instance, app is the express app of your Parse Server let httpServer = require('http').createServer(app); httpServer.listen(port); var parseLiveQueryServer = ParseServer.createLiveQueryServer(httpServer); ``` -------------------------------- ### Get Installation ID Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/embedded_c/push-notifications.md Retrieves the current installation ID associated with the Parse client. This ID is persisted across reboots. ```cpp char* installation_id = parseGetInstallationId(client); ``` -------------------------------- ### Start Parse Server for Development Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/parse-server/development.md Start the Parse Server using npm, providing essential configuration parameters like appId, masterKey, and serverURL. Use this command to run your local development instance. ```sh npm start -- --appId APPLICATION_ID --masterKey MASTER_KEY --serverURL http://localhost:1337/parse ``` -------------------------------- ### Get Installation ID on Arduino Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/arduino/push-notifications.md Retrieve the unique installation ID for the Arduino device. This ID is persisted across reboots. ```cpp String installationId = Parse.getInstallationId(); ``` -------------------------------- ### Start Parse Docs Site (Linux/OS X) Source: https://github.com/parse-community/docs/blob/gh-pages/README.md Start the Parse documentation site using npm on Linux or macOS. This command builds the site and enables auto-refresh for file changes. ```bash npm start ``` -------------------------------- ### Send Push to Query Based on Installation Data Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/dotnet/push-notifications.md Create a Parse push notification targeted at installations that match a specific query. This example targets installations where 'injuryReports' is true. ```csharp var push = new ParsePush(); push.Query = from installation in ParseInstallation.Query where installation.Get("injuryReports") == true select installation; push.Alert = "Willie Hayes injured by own pop fly."; await push.SendAsync(); ``` -------------------------------- ### Instantiate and Present PFSignUpViewController Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/ios/user-interface.md Instantiate PFSignUpViewController and present it modally. Ensure the delegate is set to handle callbacks. ```objective_c PFSignUpViewController *signUpController = [[PFSignUpViewController alloc] init]; signUpController.delegate = self; [self presentViewController:signUpController animated:YES completion:nil]; ``` ```swift let signUpController = PFSignUpViewController() signUpController.delegate = self self.present(signUpController, animated: true, completion: nil) ``` -------------------------------- ### Create Installation Object Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/rest/push-notifications.md This operation allows you to create a new installation object, typically used to subscribe a device to push notification channels. It requires specific fields like `deviceType`, `deviceToken`, and `channels`. ```APIDOC ## POST /parse/installations ### Description Creates a new installation object for push notifications. ### Method POST ### Endpoint /parse/installations ### Request Body - **deviceType** (string) - Required - The type of device (e.g., "ios", "android"). - **deviceToken** (string) - Required - The device token for push notifications. - **channels** (array of strings) - Required - The list of channels to subscribe to. - **badge** (number) - Optional - The application badge number for iOS installations. - **timeZone** (string) - Optional - The IANA time zone identifier for the device. - **appName** (string) - Optional - The display name of the client application. - **appVersion** (string) - Optional - The version string of the client application. - **parseVersion** (string) - Optional - The version of the Parse SDK used. - **appIdentifier** (string) - Optional - A unique identifier for the client application. ### Request Example ```json { "deviceType": "ios", "deviceToken": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", "channels": [ "" ] } ``` ### Response #### Success Response (201 Created) - **Location** (string) - The URL of the newly created installation. #### Response Example ``` Status: 201 Created Location: https://YOUR.PARSE-SERVER.HERE/parse/installations/mrmBZvsErB ``` ``` -------------------------------- ### Get Subscribed Channels in Android Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/android/push-notifications.md Retrieves a list of all channels the current installation is subscribed to. The list is fetched from the local cache of the Installation object. ```java List subscribedChannels = ParseInstallation.getCurrentInstallation().getList("channels"); ``` -------------------------------- ### Regex Query Example Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/rest/queries.md This example demonstrates how to find barbecue sauces whose names start with 'Big Daddy' using a regular expression query. ```APIDOC ## GET /classes/BarbecueSauce ### Description Finds barbecue sauces where the 'name' field starts with 'Big Daddy'. ### Method GET ### Endpoint /parse/classes/BarbecueSauce ### Query Parameters - **where** (string) - Required - A JSON string representing the query constraints. For this example, it's `{"name": {"$regex": "^Big Daddy"}}`. ### Request Example ```python import http.client import json import urllib.parse connection = http.client.HTTPSConnection('YOUR.PARSE-SERVER.HERE', 443) params = urllib.parse.urlencode({"where": json.dumps({ "name": { "$regex": "^Big Daddy" } })}) connection.connect() connection.request('GET', '/parse/classes/BarbecueSauce?%s' % params, '', { "X-Parse-Application-Id": "${APPLICATION_ID}", "X-Parse-REST-API-Key": "${REST_API_KEY}" }) result = json.loads(connection.getresponse().read()) print(result) ``` ### Response #### Success Response (200) - **results** (array) - An array of matching BarbecueSauce objects. #### Response Example ```json { "results": [ { "name": "Big Daddy's BBQ Sauce", "createdAt": "2023-01-01T12:00:00.000Z", "updatedAt": "2023-01-01T12:00:00.000Z", "objectId": "someObjectId" } ] } ``` ``` -------------------------------- ### LiveQueryClient Initialization Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/js/live-queries.md Initialize a LiveQueryClient instance with application credentials and server URL. ```APIDOC ## LiveQueryClient A `LiveQueryClient` is a wrapper of a standard WebSocket client. We add several useful methods to help you connect/disconnect to LiveQueryServer and subscribe/unsubscribe a `ParseQuery` easily. ### Initialize ```javascript let Parse = require('parse/node'); let LiveQueryClient = Parse.LiveQueryClient; let client = new LiveQueryClient({ applicationId: '', serverURL: '', javascriptKey: '', masterKey: '' }); ``` * `applicationId` is mandatory, it's the `applicationId` of your Parse app * `serverURL` is mandatory, it's the URL of your LiveQuery server * `javascriptKey` and `masterKey` are optional, they are used for verifying the `LiveQueryClient` when it tries to connect to the LiveQuery server. If you set them, they should match your Parse app. You can check LiveQuery protocol [here](https://github.com/parse-community/parse-server/wiki/Parse-LiveQuery-Protocol-Specification) for more details. ``` -------------------------------- ### GET Request with Port Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/cloudcode/cloud-code-advanced.md This example shows how to specify a port number in the URL for a GET request. Valid port numbers are 80, 443, and 1025-65535. ```APIDOC ## GET Parse.Cloud.httpRequest with Port ### Description Sends an HTTP GET request to a specified URL including a port number. ### Method GET ### Endpoint `Parse.Cloud.httpRequest` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript Parse.Cloud.httpRequest({ url: 'https://www.awesomewebsite.com:8080/' }).then(function(httpResponse) { console.log(httpResponse.text); }, function(httpResponse) { console.error('Request failed with response code ' + httpResponse.status); }); ``` ### Response #### Success Response (200) - **text** (string) - The response body as text. #### Response Example ```json { "text": "Response body content" } ``` ``` -------------------------------- ### Setup Server URL Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/js/live-queries.md Manually set the LiveQuery server URL if needed, especially if using a different protocol like wss. ```APIDOC ## Setup server URL ```javascript Parse.liveQueryServerURL = 'ws://XXXX' ``` Most of the time you do not need to manually set this. If you have setup your `Parse.serverURL`, we will try to extract the hostname and use `ws://hostname` as the default `liveQueryServerURL`. However, if you want to define your own `liveQueryServerURL` or use a different protocol such as `wss`, you should set it by yourself. ``` -------------------------------- ### Get Subscribed Channels Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/dotnet/push-notifications.md Retrieves the list of channels the current installation is subscribed to. Ensure the installation object is up-to-date by calling FetchAsync if changes were made outside the client. ```csharp var installation = ParseInstallation.CurrentInstallation IEnumerable subscribedChannels = installation.Channels; ``` -------------------------------- ### Start Parse Docs Site (Windows) Source: https://github.com/parse-community/docs/blob/gh-pages/README.md Start the Parse documentation site using npm on Windows. This command is specific to the Windows command prompt and enables auto-refresh for file changes. ```bash npm run dev-win ``` -------------------------------- ### Create iOS Installation for Push Notifications Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/rest/push-notifications.md Use this endpoint to create a new installation object for an iOS device, subscribing it to the broadcast channel. Ensure you include the necessary Parse Application ID and REST API Key headers. ```bash curl -X POST \ -H "X-Parse-Application-Id: ${APPLICATION_ID}" \ -H "X-Parse-REST-API-Key: ${REST_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "deviceType": "ios", "deviceToken": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", "channels": [ "" ] }' \ https://YOUR.PARSE-SERVER.HERE/parse/installations ``` ```python import http.client import json connection = http.client.HTTPSConnection('YOUR.PARSE-SERVER.HERE', 443) connection.connect() connection.request('POST', '/parse/installations', json.dumps({ "deviceType": "ios", "deviceToken": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", "channels": [ "" ] }), { "X-Parse-Application-Id": "${APPLICATION_ID}", "X-Parse-REST-API-Key": "${REST_API_KEY}", "Content-Type": "application/json" }) result = json.loads(connection.getresponse().read()) print(result) ``` -------------------------------- ### Send Push to Installations Based on Related User Data Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/php/push-notifications.md Query installations based on relationships to other Parse objects, such as users. This example sends a push to users near a specific location. ```php // Find users near a given location $userQuery = ParseUser::query(); $userQuery->withinMiles("location", $stadiumLocation, 1.0); // Find devices associated with these users $pushQuery = ParseInstallation::query(); $pushQuery->matchesQuery('user', $userQuery); // Send push notification to query ParsePush::send(array( "where" => $pushQuery, "data" => array( "alert" => "Free hotdogs at the Parse concession stand!" ) ), true); ``` -------------------------------- ### Querying String Values with Prefix Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/ios/queries.md Examples for restricting string values to those that start with a particular string. ```APIDOC ## Querying String Values with Prefix ### Description Restrict results to string values that start with a specified prefix. This is an indexed operation for efficiency. ### Method `whereKey:hasPrefix:` ### Parameters #### Query Parameters - **key** (string) - The key of the string field to query. - **hasPrefix** (string) - The prefix string to match. ### Request Example (Objective-C) ```objective_c // Finds barbecue sauces that start with "Big Daddy's". PFQuery *query = [PFQuery queryWithClassName:@"BarbecueSauce"]; [query whereKey:@"name" hasPrefix:@"Big Daddy's"]; ``` ### Request Example (Swift) ```swift // Finds barbecue sauces that start with "Big Daddy's". let query = PFQuery(className: "BarbecueSauce") query.whereKey("name", hasPrefix: "Big Daddy's") ``` ``` -------------------------------- ### Initialize Parse Server Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/parse-server/usage.md Instantiate Parse Server with essential configuration options. Ensure all required parameters like databaseURI, appId, and masterKey are provided. ```javascript const api = new ParseServer({ databaseURI: 'mongodb://your.mongo.uri', cloud: './cloud/main.js', appId: 'myAppId', fileKey: 'myFileKey', masterKey: 'mySecretMasterKey', push: { ... }, // See the Push wiki page filesAdapter: ..., }); ``` -------------------------------- ### Webhook Request Data Example Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/cloudcode/cloud-code-advanced.md Example of JSON data sent to a Cloud function webhook. Includes master key status, user details, installation ID, parameters, and function name. ```json // Sent to webhook { "master": false, "user": { "createdAt": "2015-03-24T20:19:00.542Z", "objectId": "lValKpphWN", "sessionToken": "orU3ClA7sqMIN8g4KtmLe7eDM", "updatedAt": "2015-03-24T20:19:00.542Z", "username": "Matt" }, "installationId": "b3ab24c6-2282-69fa-eeea-c1b36ea497c2", "params": {}, "functionName": "helloWorld" } ``` -------------------------------- ### User Sign Up (REST) Source: https://context7.com/parse-community/docs/llms.txt Create a new user by sending a POST request to the `/users` endpoint with user credentials like username, password, and email in the JSON body. ```bash curl -X POST "$BASE/users" \ -H "X-Parse-Application-Id: $APP_ID" \ -H "X-Parse-REST-API-Key: $REST_KEY" \ -H "Content-Type: application/json" \ -d '{"username":"alice","password":"secret","email":"alice@example.com"}' ``` -------------------------------- ### Sign Up a New User Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/dotnet/users.md Use SignUpAsync to create a new user account. This method automatically handles password hashing and checks for username/email uniqueness. Subsequent updates should use SaveAsync. ```csharp public async void SignUpButton_Click(object sender, RoutedEventArgs e) { var user = new ParseUser() { Username = "my name", Password = "my pass", Email = "email@example.com" }; // other fields can be set just like with ParseObject user["phone"] = "415-392-0202"; await user.SignUpAsync(); } ``` -------------------------------- ### JavaScript SDK Initialization Source: https://context7.com/parse-community/docs/llms.txt Initialize the JS SDK once at app startup with your app credentials. This example shows initialization for both browser/Node.js environments and for Node.js with master key access. ```APIDOC ## JavaScript SDK — Initialize Initialize the JS SDK once at app startup with your app credentials. ```javascript // Browser / Node.js Parse.initialize('YOUR_APP_ID', 'YOUR_JS_KEY'); Parse.serverURL = 'https://your-parse-server.com/parse'; // For Node.js with master key access (Cloud Code or server scripts) const Parse = require('parse/node'); Parse.initialize('YOUR_APP_ID', 'YOUR_JS_KEY', 'YOUR_MASTER_KEY'); Parse.serverURL = 'https://your-parse-server.com/parse'; ``` ``` -------------------------------- ### Create LiveQuery Server with Redis Configuration Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/parse-server/live-query.md Initialize the LiveQuery server, passing the HTTP server and configuration options including the Redis URL. This allows the LiveQuery server to leverage Redis for its pub/sub needs. ```javascript let httpServer = require('http').createServer(app); httpServer.listen(port); var parseLiveQueryServer = ParseServer.createLiveQueryServer(httpServer, { ..., redisURL: 'redis://localhost:6379' }); ``` -------------------------------- ### Send Push to Query and Channel Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/dotnet/push-notifications.md Send a push notification to devices subscribed to a specific channel that also meet certain installation data criteria. This example targets the 'Giants' channel and installations wanting score updates. ```csharp var push = new ParsePush(); push.Query = from installation in ParseInstallation.Query where installation.Get("scores") == true select installation; push.Channels = new List { "Giants" }; push.Alert = "Giants scored against the A's! It's now 2-2."; await push.SendAsync(); ``` -------------------------------- ### Get Session Token Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/embedded_c/users.md Retrieves the current session token. The token is persistent across reboots and is tied to a specific installation. ```cpp char* session_token = parseGetSessionToken(client); ``` -------------------------------- ### Sign Up a New User Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/android/users.md Use `signUpInBackground` to asynchronously create a new user. This method ensures username and email uniqueness and securely hashes the password. Subsequent updates should use `save`. ```java ParseUser user = new ParseUser(); user.setUsername("my name"); user.setPassword("my pass"); user.setEmail("email@example.com"); // other fields can be set just like with ParseObject user.put("phone", "650-253-0000"); user.signUpInBackground(new SignUpCallback() { public void done(ParseException e) { if (e == null) { // Hooray! Let them use the app now. } else { // Sign up didn't succeed. Look at the ParseException // to figure out what went wrong } } }); ``` -------------------------------- ### Query ParseObject Subclasses Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/android/objects.md Use `ParseQuery.getQuery()` to get a query for a specific subclass. This example queries for armors affordable by the current user. ```java ParseQuery query = ParseQuery.getQuery(Armor.class); query.whereLessThanOrEqualTo("rupees", ParseUser.getCurrentUser().get("rupees")); query.findInBackground(new FindCallback() { @Override public void done(List results, ParseException e) { for (Armor a : results) { // ... } } }); ``` -------------------------------- ### Get Subscribed Channels Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/ios/push-notifications.md Retrieve the list of channels a device is currently subscribed to. This cached list can be accessed directly from the current Installation object. ```objective-c NSArray *subscribedChannels = [PFInstallation currentInstallation].channels; ``` ```swift let subscribedChannels = PFInstallation.currentInstallation().channels ``` -------------------------------- ### Configure and Use Live Queries Source: https://context7.com/parse-community/docs/llms.txt Set up the LiveQuery server URL and subscribe to real-time updates for object changes. Includes handling connection events and unsubscribing. ```javascript // Configure LiveQuery server URL (defaults to ws://hostname from serverURL) Parse.liveQueryServerURL = 'wss://your-parse-server.com/'; // --- SUBSCRIBE --- const query = new Parse.Query('Message'); query.equalTo('room', 'general'); const subscription = await query.subscribe(); subscription.on('open', () => console.log('Connected')); subscription.on('create', (object) => console.log('New message:', object.get('text'))); subscription.on('update', (object) => console.log('Edited:', object.get('text'))); subscription.on('enter', (object) => console.log('Object entered query:', object.id)); subscription.on('leave', (object) => console.log('Object left query:', object.id)); subscription.on('delete', (object) => console.log('Deleted:', object.id)); subscription.on('close', () => console.log('Subscription closed')); // --- UNSUBSCRIBE --- subscription.unsubscribe(); // --- CLOSE ALL --- Parse.LiveQuery.close(); // --- GLOBAL CONNECTION EVENTS --- Parse.LiveQuery.on('open', () => console.log('WS connected')); Parse.LiveQuery.on('close', () => console.log('WS disconnected')); Parse.LiveQuery.on('error', (error) => console.error('WS error:', error)); // --- ADVANCED: Multiple LiveQuery servers --- const LiveQueryClient = Parse.LiveQueryClient; const client = new LiveQueryClient({ applicationId: 'YOUR_APP_ID', serverURL: 'wss://lq-server-2.example.com/', javascriptKey: 'YOUR_JS_KEY', }); client.open(); const sub = client.subscribe(query, Parse.User.current()?.getSessionToken()); sub.on('create', obj => console.log('From client 2:', obj.id)); ``` -------------------------------- ### Querying Comments with Included Author Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/rest/queries.md This example demonstrates how to query the 'Comment' class and include the associated 'author' information using a GET request. ```APIDOC ## GET /classes/Comment ### Description Queries the Comment class and includes related post author data. ### Method GET ### Endpoint https://YOUR.PARSE-SERVER.HERE/parse/classes/Comment ### Query Parameters - **limit** (integer) - Optional - The maximum number of results to return. - **include** (string) - Optional - A comma-separated list of keys to include related data for. Example: "post.author" ### Request Example ```bash curl -G \ -H "X-Parse-Application-Id: YOUR_APP_ID" \ -H "X-Parse-REST-API-Key: YOUR_REST_API_KEY" \ --data-urlencode 'limit=10' \ --data-urlencode 'include=post.author' \ https://YOUR.PARSE-SERVER.HERE/parse/classes/Comment ``` ### Response #### Success Response (200) - **results** (array) - An array of comment objects, with author data included if requested. #### Response Example ```json { "results": [ { "objectId": "someObjectId", "createdAt": "2023-01-01T12:00:00.000Z", "post": { "__type": "Pointer", "className": "Post", "objectId": "postObjectId" }, "author": { "objectId": "authorObjectId", "username": "john_doe", "createdAt": "2023-01-01T10:00:00.000Z", "updatedAt": "2023-01-01T10:00:00.000Z" }, "comment": "This is a great post!" } ] } ``` ``` -------------------------------- ### Retrieve Parse.File URL Source: https://context7.com/parse-community/docs/llms.txt Get the URL of a Parse.File attached to a Parse Object. This URL can be used to display the file, for example, in an image tag. ```javascript const avatarUrl = profile.get('avatar').url(); document.getElementById('profileImg').src = avatarUrl; ``` -------------------------------- ### Perform an Aggregate Query Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/rest/queries.md This example demonstrates how to construct and execute an aggregate query. Ensure you have the necessary Parse Server keys for authentication. ```python import json import httplib2 connection = httplib2.HTTPSConnectionWithTimeout("localhost:8443") connection.connect() connection.request('POST', '/parse/classes/_User', json.dumps({ "where": { "$or": [ { "score": { "$gt": 100 } }, { "name": { "$regex": "(?i)foobar" } } ] }, "pipeline": [ { "$group": { "_id": "$city", "averageScore": { "$avg": "$score" }, "count": { "$sum": 1 } } }, { "$match": { "averageScore": { "$gt": 50 } } } ] }), { "X-Parse-Application-Id": "APP_ID", "X-Parse-Master-Key": "MASTER_KEY" "X-Parse-REST-API-Key": "REST_API_KEY" }) result = json.loads(connection.getresponse().read()) print(result) ``` -------------------------------- ### GET Request with Redirects Enabled Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/cloudcode/cloud-code-advanced.md This example demonstrates how to enable following HTTP redirects (3xx response codes) by setting `followRedirects: true`. ```APIDOC ## GET Parse.Cloud.httpRequest with Redirects ### Description Sends an HTTP GET request and follows HTTP redirects. ### Method GET ### Endpoint `Parse.Cloud.httpRequest` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript Parse.Cloud.httpRequest({ url: 'https://www.awesomewebsite.com/', followRedirects: true }).then(function(httpResponse) { console.log(httpResponse.text); }, function(httpResponse) { console.error('Request failed with response code ' + httpResponse.status); }); ``` ### Response #### Success Response (200) - **text** (string) - The response body as text. #### Response Example ```json { "text": "Response body content" } ``` ``` -------------------------------- ### Configure FSAdapter with a subdirectory Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/parse-server/file-adapters.md Initialize the FSAdapter for local file storage. This example specifies a custom subdirectory for storing files. ```javascript var FSFilesAdapter = require('@parse/fs-files-adapter'); var fsAdapter = new FSFilesAdapter({ "filesSubDirectory": "my/files/folder" // optional, defaults to ./files }); var api = new ParseServer({ appId: 'my_app', masterKey: 'master_key', filesAdapter: fsAdapter }) ``` -------------------------------- ### afterSave Webhook Request Data Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/cloudcode/cloud-code-advanced.md Example JSON payload received by an afterSave webhook. This data includes information about the user, installation, and the saved object. ```jsonc // Sent to webhook { "master": false, "user": { "createdAt": "2015-03-24T20:19:00.542Z", "objectId": "lValKpphWN", "sessionToken": "orU3ClA7sqMIN8g4KtmLe7eDM", "updatedAt": "2015-03-24T20:19:00.542Z", "username": "Matt" }, "installationId": "b3ab24c6-2282-69fa-eeea-c1b36ea497c2", "triggerName": "afterSave", "object": { "objectId": "zPnDyvj0vd", "className": "Comment", "createdAt": "2015-03-25T00:00:57.055Z", "updatedAt": "2015-03-25T00:00:57.055Z", "post": { "__type": "Pointer", "className": "Post", "objectId": "jsUd72Sd2l" } } } ``` -------------------------------- ### Initialize LiveQueryClient Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/js/live-queries.md Initialize a `LiveQueryClient` for managing multiple LiveQuery server connections. Provide `applicationId` and `serverURL` as mandatory parameters. `javascriptKey` and `masterKey` are optional for verification. ```javascript let Parse = require('parse/node'); let LiveQueryClient = Parse.LiveQueryClient; let client = new LiveQueryClient({ applicationId: '', serverURL: '', javascriptKey: '', masterKey: '' }); ``` -------------------------------- ### Subscribe to a Channel Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/dotnet/push-notifications.md Use this to subscribe the current installation to a specific channel. The channel name must start with a letter and can contain alphanumeric characters, underscores, and dashes. ```csharp var installation = ParseInstallation.CurrentInstallation; installation.Channels = new List { "Giants" }; await installation.SaveAsync(); ``` ```csharp var installation = ParseInstallation.CurrentInstallation; installation.AddUniqueToList("channels", "Giants"); await installation.SaveAsync(); ``` ```csharp await ParsePush.SubscribeAsync("Giants"); ``` -------------------------------- ### Install Parse PHP SDK with Git Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/php/installation.md Clone the SDK repository using Git. Include the 'autoload.php' file in your project to automatically load SDK classes. ```bash git clone https://github.com/parse-community/parse-php-sdk.git ``` ```php require 'autoload.php'; ``` -------------------------------- ### GET Request with Query Parameters Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/cloudcode/cloud-code-advanced.md This example shows how to append query parameters to the URL using the `params` option, either as a JSON object or a raw string. ```APIDOC ## GET Parse.Cloud.httpRequest with Query Parameters ### Description Sends an HTTP GET request with specified query parameters. ### Method GET ### Endpoint `Parse.Cloud.httpRequest` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript // Using JSON object for params Parse.Cloud.httpRequest({ url: 'http://www.google.com/search', params: { q : 'Sean Plott' } }).then(function(httpResponse) { console.log(httpResponse.text); }, function(httpResponse) { console.error('Request failed with response code ' + httpResponse.status); }); // Using raw string for params Parse.Cloud.httpRequest({ url: 'http://www.google.com/search', params: 'q=Sean Plott' }).then(function(httpResponse) { console.log(httpResponse.text); }, function(httpResponse) { console.error('Request failed with response code ' + httpResponse.status); }); ``` ### Response #### Success Response (200) - **text** (string) - The response body as text. #### Response Example ```json { "text": "Response body content" } ``` ``` -------------------------------- ### Implementing Accessors and Mutators in a ParseObject Subclass Source: https://github.com/parse-community/docs/blob/gh-pages/_includes/android/objects.md Provides an example of how to create getter and setter methods within a ParseObject subclass to interact with its fields using get() and put(). ```java // Armor.java @ParseClassName("Armor") public class Armor extends ParseObject { public String getDisplayName() { return getString("displayName"); } public void setDisplayName(String value) { put("displayName", value); } } ```