Manage In-App Products with the API
Use these APIs to retrieve, create, or update your app's products from your server. Call these services only server to server.
Send requests from your server. Do not put the X-Access-Token in a client app; exposing it could allow the app's access to be misused.
Authentication
For every request, obtain the app access token from the Developer Panel and send it in the X-Access-Token header. In the examples, {PACKAGE_NAME} is your app's package name.
List products
- cURL
- Python
curl --request GET \
'https://developer.myket.ir/api/partners/applications/{PACKAGE_NAME}/products?limit=10&offset=0' \
--header 'X-Access-Token: {ACCESS_TOKEN}'
import requests
package_name = "org.example.app"
url = f"https://developer.myket.ir/api/partners/applications/{package_name}/products"
headers = {"X-Access-Token": "YOUR_ACCESS_TOKEN"}
params = {"limit": 10, "offset": 0}
response = requests.get(url, headers=headers, params=params)
print(response.status_code, response.json())
limit: Number of products in the response; defaults to100and has a maximum of1000.offset: Page offset; defaults to0, which is the first page.
Example response:
{
"skus": [
{
"skuId": "GEM1",
"farsiTitle": "الماس مرحله اول",
"price": 10000,
"creationDate": "2024-07-27T00:00:05.41",
"isActive": true
}
],
"totalCount": 1
}
Create a product
To create a consumable in-app product, send this POST request:
- cURL
- Python
curl --request POST \
'https://developer.myket.ir/api/partners/applications/{PACKAGE_NAME}/products' \
--header 'X-Access-Token: {ACCESS_TOKEN}' \
--header 'Content-Type: application/json' \
--data '{
"skuId": "100GOLD2000",
"farsiTitle": "صد طلا",
"price": 20000,
"isActive": false
}'
import requests
package_name = "org.example.app"
url = f"https://developer.myket.ir/api/partners/applications/{package_name}/products"
headers = {"X-Access-Token": "YOUR_ACCESS_TOKEN"}
payload = {
"skuId": "100GOLD2000",
"farsiTitle": "صد طلا",
"price": 20000,
"isActive": False,
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code, response.json())
Create products in a batch
Create up to 200 in-app products in one request. Send the products directly as a JSON array.
Endpoint
POST https://developer.myket.ir/api/partners/applications/{PACKAGE_NAME}/products/batch
Replace {PACKAGE_NAME} with your app's package name.
Request structure
Request headers:
X-Access-Token: {ACCESS_TOKEN}
Content-Type: application/json
The request body must be a direct array of products:
[
{
"skuId": "COINS_100",
"farsiTitle": "بسته ۱۰۰ سکه",
"price": 10000,
"isActive": true
},
{
"skuId": "COINS_500",
"farsiTitle": "بسته ۵۰۰ سکه",
"price": 50000,
"isActive": false
}
]
Do not send AccountId or the package name in the body. The developer account is determined by the access token, and the package name comes from the request path.
Fields for each product
| Field | Type | Required | Description |
|---|---|---|---|
skuId | string | Yes | Unique product ID within the app; up to 100 characters |
farsiTitle | string | Yes | Persian product title; up to 150 characters |
price | Integer | Yes | Price in rials; minimum 1,000 and maximum 2,000,000,000 rials |
isActive | boolean | No | Whether the product is active; defaults to false if omitted |
Example request
- cURL
- Python
curl --request POST \
'https://developer.myket.ir/api/partners/applications/{PACKAGE_NAME}/products/batch' \
--header 'X-Access-Token: {ACCESS_TOKEN}' \
--header 'Content-Type: application/json' \
--data '[
{
"skuId": "COINS_100",
"farsiTitle": "بسته ۱۰۰ سکه",
"price": 10000,
"isActive": true
},
{
"skuId": "COINS_500",
"farsiTitle": "بسته ۵۰۰ سکه",
"price": 50000,
"isActive": false
}
]'
import requests
package_name = "org.example.app"
access_token = "YOUR_ACCESS_TOKEN"
url = (
"https://developer.myket.ir/api/partners/applications/"
f"{package_name}/products/batch"
)
headers = {
"X-Access-Token": access_token,
}
products = [
{
"skuId": "COINS_100",
"farsiTitle": "بسته ۱۰۰ سکه",
"price": 10000,
"isActive": True,
},
{
"skuId": "COINS_500",
"farsiTitle": "بسته ۵۰۰ سکه",
"price": 50000,
"isActive": False,
},
]
response = requests.post(
url,
headers=headers,
json=products,
timeout=30,
)
print(response.status_code)
print(response.text)
Limits and validation
- Each request must contain at least one and at most 200 products. Split larger sets into separate requests.
- IDs must not repeat within the array. This duplicate check is case-insensitive:
COINS_100andcoins_100count as duplicates. - None of the IDs may already exist for the app; inactive products are included in this check.
- Every product must meet the field constraints above. A
nullarray entry is not accepted. - This service creates new products. Use the update service to change an existing product.
Product validity and duplicate IDs are checked before inserting SKUs. If even one product is invalid or conflicts with an existing product, the entire request is rejected and none of its new products are created.
For example, if the last ID in a batch of 10 products already exists, the other nine products are not created either.
Successful response
On successful creation, the service returns 200 OK and a success message. Use the list-products service to view the created products:
GET https://developer.myket.ir/api/partners/applications/{PACKAGE_NAME}/products
Possible errors
| HTTP status | Error code | Cause |
|---|---|---|
400 | SkuListIsRequired | The product list is empty |
400 | SkuBatchLimitExceeded | More than 200 products were sent |
400 | SkuIdIsDuplicate | An ID repeats within the array or already exists for the app |
400 | SkuIdIsRequired | The product ID is missing or empty |
400 | SkuIdMaxLengthExceeded | The product ID exceeds 100 characters |
400 | SkuTitleIsRequired | The Persian title is missing or empty |
400 | SkuTitleMaxLengthExceeded | The Persian title exceeds 150 characters |
400 | SkuPriceMinValueNotReached | The price is below 1,000 rials or missing |
400 | SkuPriceMaxValueExceeded | The price exceeds 2 billion rials |
400 | InValidSkuFormat | Product data is invalid, for example a null array entry |
401 | — | The token is invalid or does not have access to the app |
500 | — | An internal error occurred while processing the request |
A non-JSON body or a structure incompatible with an array of products also returns 400.
If you receive 500 or the connection drops before a response arrives, check the product list before retrying. A missing success response alone does not mean the products were not created.
Update a product
To update a product, include its ID in the path and send only the fields you want to change:
- cURL
- Python
curl --request PUT \
'https://developer.myket.ir/api/partners/applications/{PACKAGE_NAME}/products/{SKU_ID}' \
--header 'X-Access-Token: {ACCESS_TOKEN}' \
--header 'Content-Type: application/json' \
--data '{
"farsiTitle": "صد طلا",
"price": 20000,
"isActive": true
}'
import requests
package_name = "org.example.app"
sku_id = "100GOLD2000"
url = (
f"https://developer.myket.ir/api/partners/applications/{package_name}"
f"/products/{sku_id}"
)
headers = {"X-Access-Token": "YOUR_ACCESS_TOKEN"}
payload = {
"farsiTitle": "صد طلا",
"price": 20000,
"isActive": True,
}
response = requests.put(url, headers=headers, json=payload)
print(response.status_code, response.json())
Product fields
| Field | Description |
|---|---|
skuId | Unique product ID; required on creation, up to 100 characters |
farsiTitle | Persian title; required on creation, up to 150 characters |
price | Price in rials; required on creation, at least 1,000 rials |
isActive | Whether the product is active; defaults to false when created |
A successful response returns code 200 and a success message. An invalid token or package name may result in 401 Unauthorized. Invalid requests, duplicate IDs, and values outside the allowed limits also return errors.