# CompuDime Public API: who am I, products and orders, for the VS Code REST Client extension. # Docs: https://api.compudime.com/docs (this file and the other samples: https://api.compudime.com/docs/samples) # # @baseUrl is the API address. To call another address, change it here. # @apiKey reads PUBLIC_API_KEY from a .env file next to this one. Never write a key into this file. # # Two order APIs share this address. /v1/orders, used below, is the CompuDime Public API: your app sends # an order into a store's POS, then reads where it stands. /api/v1/orders/... is the CompuDime Orders API, # where delivery and ordering services push orders into a store's queue. They are separate APIs with their # own requests and answers; this file covers /v1/orders only. @baseUrl = https://api.compudime.com @apiKey = {{$dotenv PUBLIC_API_KEY}} ### Who am I: the key's store, mode (live or test), fields, rate limit and credits; free GET {{baseUrl}}/v1/me Authorization: Bearer {{apiKey}} X-Request-Id: http-who-am-i ### List projected products GET {{baseUrl}}/v1/products?fields=productCode,description,price&limit=50 Authorization: Bearer {{apiKey}} X-Request-Id: http-products-page-1 ### Lookup one product GET {{baseUrl}}/v1/products/SKU-100?fields=productCode,description,price Authorization: Bearer {{apiKey}} X-Request-Id: http-product-lookup ### POST /v1/orders requires orders.write and a safe Idempotency-Key # With a test key (cc_test_ or cd_test_) the order is validated and simulated: the 202 says # dispatchState simulated and an orderId starting test_, and the order never reaches the store. POST {{baseUrl}}/v1/orders Authorization: Bearer {{apiKey}} Idempotency-Key: web-order-1001 X-Request-Id: http-order-create-1001 Content-Type: application/json { "externalOrderId": "web-1001", "customer": "Pickup customer", "notes": "Paid online", "orderMethod": "pickup", "lines": [ { "productCode": "SKU-100", "quantity": 2, "unitPrice": "3.99" } ] } ### A delivery with its address (shipTo): street, city, state and zip together; limits are the POS invoice widths POST {{baseUrl}}/v1/orders Authorization: Bearer {{apiKey}} Idempotency-Key: web-order-1002 X-Request-Id: http-order-create-1002 Content-Type: application/json { "externalOrderId": "web-1002", "customer": "(732) 555-0142", "notes": "Ring twice", "shipTo": { "firstName": "Rivka", "lastName": "Klein", "street": "1200 Madison Ave", "street2": "Apt 4B", "city": "Lakewood", "state": "NJ", "zip": "08701-1234", "phone": "(732) 555-0199" }, "lines": [ { "productCode": "SKU-100", "quantity": 2, "unitPrice": "3.99" } ] } ### A line without unitPrice is priced by the store at dispatch under its price rule (register: what the store's register charges, with the customer's discount; order_screen: the regular price), or the customer's contract price; an item sold by weight sends its weight in pounds; the order reads return what the store charged as storePrices and storeDiscount POST {{baseUrl}}/v1/orders Authorization: Bearer {{apiKey}} Idempotency-Key: web-order-1003 X-Request-Id: http-order-create-1003 Content-Type: application/json { "externalOrderId": "web-1003", "customer": "(732) 555-0142", "lines": [ { "productCode": "SKU-100", "quantity": 2, "unitPrice": "3.99" }, { "productCode": "0006009", "quantity": 1 }, { "productCode": "4011", "quantity": 1, "weight": "1.37" } ] } ### GET /v1/orders/{orderId} requires orders.read; put the orderId from the 202 in place of GET {{baseUrl}}/v1/orders/ Authorization: Bearer {{apiKey}} X-Request-Id: http-order-status-1001 ### What the store charged for the lines sent without unitPrice, and the customer's discount on them (after dispatch) GET {{baseUrl}}/v1/orders/external/web-1003?fields=dispatchState,storePrices,storeDiscount Authorization: Bearer {{apiKey}} X-Request-Id: http-order-store-prices-1003 # Errors are problem JSON sent as application/json (not application/problem+json); every code, for example # rate_limited, usage_exhausted, billing_card_missing, is at https://api.compudime.com/docs/errors