Monaca also allows you to manage your Monaca Backend from your server rather than from Monaca IDE. For example, you may create a new user, a new collection and send a push notification from your sever to your Monaca app. In order to do this, you will need to implement Monaca Backend Management APIs which will be described in this section. These APIs are based on JSON-RPC version 2.0. For information about its specification, please refer to JSON-RPC 2.0 Specification .
Prior to implementing these APIs, you should be aware of the following specifications:
You can get endpoint URL from Backend Management API Key panel in which it is called Management API URL (See Backend Management API Key).
Here is an example of a JSON-RPC request:
{
"jsonrpc": "2.0",
"method": "CollectionItem.list",
"params": {
"collectionName": "GameScore",
"page": 1,
"itemsInPage": 10,
"sortProperty": "score",
"sortOrder": "desc"
},
"id": 1
}
jsonrpc
should be 2.0
and id
should be 1
.
X-Monaca-Backend-Management-API-Key: *********
Here is an example of a successful JSON-RPC response:
{
"jsonrpc":"2.0",
"id":1,
"result":{
"items":[ {...}, {...}, {...} ],
"totalItems":3
}
}
Here is an example of a failure JSON-RPC response (if method was wrong):
{
"jsonrpc":"2.0",
"id":1,
"error":{
"code":-32601,
"message":"Method not found"
}
}
An example of a failure JSON-RPC response (if collectionName was wrong):
{
"jsonrpc":"2.0",
"id":1,
"error":{
"code":-32602,
"message":"Invalid params",
"data":{
"collectionName":"Collection not found."
}
}
}