comecerodocs
Concepts

Customizing output

Use the show and hide query parameters to return only the fields you need from the Comecero API, which keeps responses small, especially for long lists.

Most objects have many fields, and you often need only a few. With show or hide you choose which fields come back, which makes responses smaller and faster, most of all for lists.

Show only some fields

show takes a comma-separated list of fields. Only those fields come back, plus the object's url, which is always kept.

Request
curl "https://api.comecero.com/api/v1/carts/0091307952465CafhFSTa1?show=subtotal,tax,total" \
  -H "Authorization: Bearer $COMECERO_TEST_TOKEN"
Response
{
  "url": "https://api.comecero.com/api/v1/carts/0091307952465CafhFSTa1",
  "subtotal": 119.9,
  "tax": 9.38,
  "total": 129.28
}

Hide some fields

hide does the opposite: every field comes back except the ones you name.

Request
curl "https://api.comecero.com/api/v1/carts/0091307952465CafhFSTa1?hide=items,customer" \
  -H "Authorization: Bearer $COMECERO_TEST_TOKEN"

You cannot send show and hide in the same request. The API answers 400.

Fields inside child objects

Use dot notation for a field inside a child object. For an array such as items, the path applies to every item.

# Only the total and each item's name and price
curl "https://api.comecero.com/api/v1/carts/0091307952465CafhFSTa1?show=total,items.name,items.price" \
  -H "Authorization: Bearer $COMECERO_TEST_TOKEN"
  • With show, naming a child field keeps its parent, so show=customer.email returns customer with only email in it.
  • With show, naming a child object without any of its fields (show=customer) returns the whole child object.
  • With hide, hide=items.date_created removes date_created from every item and keeps the rest.

With expand

show and hide also reach into expanded objects. This returns each item's product, without its images:

Request
curl "https://api.comecero.com/api/v1/carts/0091307952465CafhFSTa1?expand=items.product&hide=items.product.images" \
  -H "Authorization: Bearer $COMECERO_TEST_TOKEN"

In lists

On a list, the fields you name apply to each item in data. The paging fields such as next_page_url are kept.

Request
curl "https://api.comecero.com/api/v1/orders?show=order_id,total,currency" \
  -H "Authorization: Bearer $COMECERO_TEST_TOKEN"

When you also send formatted=true, the formatted object follows the same choice: it holds only the formatted versions of the fields you show (see Localized formatting).

A field name that does not exist is ignored, not refused, so check the spelling if a field is missing.

Next steps

On this page