Products REST API
API request #index
GET /products.xml or /products.json
GET /projects/
Example:
GET https://www.demo.redmineup.com/products.json
Response:
{"products":
[
{"id":7,
"code":"consult",
"name":"Redmine consulting",
"price":"75.0",
"currency":"USD",
"description":"",
"category":{"id":2,"code":"001/1","name":"Service"},
"project":
{"id":12,"name":"Redmine Products plugin demo"},
"status_id":1,
"author":
{"id":4,"name":"Smith Paul"},
"tag_list":[],
"custom_fields":
[{"id":17,"name":"Vendor","value":"45"}],
"created_at":"2014-10-28T22:16:55Z",
"updated_at":"2014-10-28T22:19:53Z"},
{"id":4,
...........
...........
},
....
],
"total_count":6,
"offset":0,
"limit":25
}
API request #show
GET /products/
GET /projects/
Example:
GET https://www.demo.redmineup.com/products/4.json
Response:
{
"product": {
"id": 1,
"image": {"attachment_id": 44},
"code": "001P",
"name": "CRM plugin",
"price": "99.0",
"currency": "USD",
"description": "This is a product CRM description",
"category": {"id": 2,"code": "001/1","name": "Service"},
"project": {"id": 12,"name": "Redmine Products plugin demo"},
"status_id": 1,
"author": {"id": 11,"name": "Kutcher Ashton"},
"tag_list": ["CRM","plugin","pro"],
"custom_fields": [
{"id": 17,"name": "Vendor","value": null}
],
"created_at": "2013-09-11T10:22:38Z",
"updated_at": "2014-10-28T22:21:20Z"
}
}
Bundles and versions in the response PRO
For a bundle the response has "bundle": true, total_price (the sum of price multiplied by quantity of the products you can see; empty when they have different currencies) and total_price_currency. The parameter include accepts, separated by commas:
items: the composition of a bundleversions: versions linked to the productattachments: product files (without the image)
Example:
GET https://www.demo.redmineup.com/products/21.json?include=items,versions
Response (fragment):
{
"product": {
"id": 21,
"code": "crm_bundle",
"name": "CRM + Helpdesk",
"price": "599.0",
"currency": "USD",
"bundle": true,
"total_price": 698.0,
"total_price_currency": "USD",
"items": [
{"id": 21, "product": {"id": 15, "name": "Redmine CRM plugin"}, "quantity": 1},
{"id": 20, "product": {"id": 2, "name": "Redmine Helpdesk plugin"}, "quantity": 1}
],
"versions": [
{"id": 8, "name": "2.4.0", "product_version_id": 3}
]
}
}
API request #create
POST /products.xml or /products.json
POST /projects/
Example:
POST https://www.demo.redmineup.com/products.json?key=9a1acbd3a18eb1370
{
"product": {
"name": "Redmine cookbook",
"price": "50.0",
"currency": "USD",
"description": "This is a book ",
"status_id": 1,
"project_id": 12
}
}
Note: Required parameters: name, status_id where status_id: 1 - Active, 2 - Inactive.
Response:
{
"product": {
"id": 8,
"code": null,
"name": "Redmine cookbook",
"price": "50.0",
"currency": "USD",
"description": "This is a book ",
"project": {"id": 12,"name": "Redmine Products plugin demo"},
"status_id": 1,
"author": {"id": 4,"name": "Smith Paul"},
"tag_list": [],
"custom_fields": [
{"id": 17,"name": "Vendor","value": null}
],
"created_at": "2023-06-05T06:59:21Z",
"updated_at": "2023-06-05T06:59:21Z"
}
}
API request #update
PUT /products/<product_id>.json
{
"product": {
"name": "Redmine cookbook 2nd edition",
"price": "100.0",
"description": "This is a updated book"
}
}
Example:
PUT https://www.demo.redmineup.com/products/1.json?key=9a13f3
{
"product": {
"price": "100.0",
"description": "This is a updated plugin"
}
}
Note: PRO Create and update accept bundle (true or false) and items, a list like {"product_id": 15, "quantity": 2}. items replaces the whole composition; quantity is 1 by default. A product that is not found, inactive, a bundle or not visible to you is skipped. A bundle needs a code.
API request #delete
DELETE /products/
Example:
DELETE https://www.demo.redmineup.com/products/10.json?key=9a13f3
Bundle items and versions REST API PRO
You need the Edit products permission. In the requests below ITEM_ID is the id of an element of items, and LINK_ID is product_version_id of an element of versions. To change quantities of the whole composition use items in the product update.
Add a product to a bundle
POST /products/
POST https://www.demo.redmineup.com/products/21/bundle_items.json?key=9a13f3
{"bundle_item": {"product_id": 15, "quantity": 2}}
The response is empty (204). Several products can be added at once with product_ids. Products that are not found, inactive, bundles or not visible are skipped; if nothing is added, the response is 422.
Remove a product from a bundle
DELETE /products/
Link a version to a product
POST /products/
POST https://www.demo.redmineup.com/products/15/product_versions.json?key=9a13f3
{"product_version": {"version_id": 8}}
Several versions can be linked at once with version_ids.
Unlink a version
DELETE /products/
Only the link is removed; the version and its files stay.
Orders REST API
API request #index
GET /orders.xml or /orders.json
GET /projects/
Example:
GET https://www.demo.redmineup.com/orders.json
API request #show
GET /orders/
GET /projects/
Example:
GET https://www.demo.redmineup.com/orders/21805.json
API request #create
POST /projects/
POST /orders.xml or /orders.json
Example:
POST https://www.demo.redmineup.com/orders.json
{
"order": {
"number": "SO-0047",
"subject": "Sales order for plugin Products",
"order_date": "2023-05-16",
"currency": "USD",
"project_id": 12,
"lines_attributes": {
"0": {"description":"Test","quantity":"2","price":"10"},
"1": {"product_id":"1","quantity":"2","price":"100","tax":"10","discount":"10"}
}
}
}
Note: Required parameters: number, order_date, project_id.
API request #update
PUT /orders/<order_id>.xml or /orders/<order_id>.json
{
"order": {
"subject": "New subject for order #29"
}
}
Example:
PUT https://www.demo.redmineup.com/orders/14.json
{
"order": {
"lines_attributes": {
"3": {"product_id":"2","quantity":"5","price":"156","tax":"10","discount":"10"}
}
}
}
API request #delete
DELETE /orders/
DELETE https://www.demo.redmineup.com/orders/14.json