The Orders API provides a simple interface to manage orders.

An Order is a list ofLine Itemsassociated with a deal.

该API允许s you to create, delete and update your orders. You can also retrieve a single order as well as list of all orders.

Line Items, Products and Orders are available only to users who are on theEnterpriseplan.

Account administrators can disable changes to these entities in the accountsettings. When disabled, all data are preserved but only GET requests are allowed.

JSON format

Name Type Read only Description
id number true Unique identifier of the order.
deal_id number true Id of the deal the order is associated to.
discount number true Discount on the whole order in percents.
created_at string true Date and time of when the order was created in UTC (ISO8601 format).
updated_at string true Date and time of the last update in UTC (ISO8601 format).

Retrieve all orders

             
GET/v2/orders

Returns all orders available to the user according to the parameters provided.

Name Type In Required Description
page number 查询 false Page number to start from. Page numbering starts at 1, and omitting thepageparameter will return the first page. e.g.?page=2
per_page number 查询 false Number of records to return per page. Default limit is25and the maximum number that can be returned is100. e.g.?per_page=20
ids number 查询 false Comma-separated list of IDs to be returned in request. e.g.?ids=1,2,3
sort_by string 查询 false A field to sort by. Default ordering isascending. If you want to change the sort ordering to descending, append:descto the field e.g.sort_by=value:desc.
deal_id number 查询 false Id of the deal order is associated to. e.g.?deal_id=12

Allowed for

  • Agents

Using cURL

             
旋度-v -X GET https://api.getbase.com/v2/orders\-H"Accept: application/json"\-H"Authorization: Bearer$ACCESS_TOKEN"

Example response

             
HTTP/1.1200OKContent-Type:application/json; charset=utf-8Content-Language:en{"items":[{"data":{"id":1,"deal_id":12,"discount":5,"created_at":"2015-07-06T16:32:56Z","updated_at":"2015-07-06T16:32:56Z"},"meta":{"type":"order"}}],"meta":{"type":"collection","count":1,"links":{"self":"http://api.getbase.com/v2/orders?page=1&per_page=25"}}}

Create an order

             
POST/v2/orders
Name Type In Required Description
deal_id number Body true e.g."deal_id": "12"
discount number Body true e.g.e.g. "discount": "50"

Allowed for

  • Agents

Using cURL

             
旋度-v -X POST https://api.getbase.com/v2/orders\-H"Accept: application/json"\-H"Content-Type: application/json"\-H"Authorization: Bearer$ACCESS_TOKEN"\-d'{"data": {"deal_id": 12,"discount": 50},"meta": {"type": "order"}}'

Example response

             
HTTP/1.1200OKContent-Type:application/json; charset=utf-8Content-Language:en{"data":{"id":19,"deal_id":12,"discount":50,"updated_at":"2015-07-07T10:03:19Z","created_at":"2015-07-07T10:03:19Z"},"meta":{"type":"order"}}

Retrieve a single order

             
GET/v2/orders/:id

Returns a single order available to the user, according to the unique order ID provided. If the specified order does not exist, the request will return an error.

Name Type In Required Description
id number 查询 true Unique identifier of the order.

Allowed for

  • Agents

Using cURL

             
旋度-v -X GET https://api.getbase.com/v2/orders/1\-H"Accept: application/json"\-H"Authorization: Bearer$ACCESS_TOKEN"

Example response

             
HTTP/1.1200OKContent-Type:application/json; charset=utf-8Content-Language:en{"data":{"id":19,"deal_id":12,"discount":50,"updated_at":"2015-07-07T10:03:19Z","created_at":"2015-07-07T10:03:19Z"},"meta":{"type":"order"}}

Update an order

             
PUT/v2/orders/:id

Updates order information. If the specified order does not exist, the request will return an error.

Name Type In Required Description
deal_id number Body false e.g."deal_id": "12"
discount number Body false e.g."discount": "25"

Allowed for

  • Agents

Using cURL

             
旋度-v -X PUT https://api.getbase.com/v2/orders/1\-H"Accept: application/json"\-H"Content-Type: application/json"\-H"Authorization: Bearer$ACCESS_TOKEN"\-d'{"data": {"discount": 25}}'

Example response

             
HTTP/1.1200OKContent-Type:application/json; charset=utf-8Content-Language:en{"data":{"id":1,"deal_id":12,"discount":25,"updated_at":"2015-07-08T13:03:19Z","created_at":"2015-07-07T10:03:19Z"},"meta":{"type":"order"}}

Delete an order

             
PUT/v2/orders/:id

Delete an existing order and remove all of the associated line items in a single call. If the specified order does not exist, the request will return an error. This operation cannot be undone.

Name Type In Required Description
id number 查询 true Unique id of the order.

Allowed for

  • Agents

Using cURL

             
旋度-v -X DELETE https://api.getbase.com/v2/orders/1\-H"Authorization: Bearer$ACCESS_TOKEN"

Example response

             
HTTP/1.1204NoContent