The category tree is a structure where Mercado Libre organizes its listings. Each country has its own category tree that is different from each other. Listings can only be posted on the leaf categories of the tree. Sometimes, the category tree changes because a new category is created, or an existing category is split in two or more categories. All the listings posted in the old category are automatically moved to the new category.
Synchronize the Category Tree
It is recommended making a dump of the whole category tree for a given country site for offline processing on a daily basis, so you are up to date with new categories. It is very useful when you are giving your user the possibility of mapping categories from his side to Global Selling´s category tree.
Working with Category Tree dumpThis API returns the category tree in JSON format within a gzip-encoded response. To get the categories for Global Selling, for example, use this URL:
curl -X GET https://api.mercadolibre.com/sites/CBT/categories/all > categoriesCBT.gz
This URL contains 2 headers that can be used to check when the last dump was generated.
- X-Content-Created: contains the date of the last generation.
- X-Content-MD5: contains the MD5 checksum of the last generation.
curl -I https://api.mercadolibre.com/sites/CBT/categories/all HTTP/1.1 200 OK Server: nginx/1.0.4 Date: Tue, 24 Jul 2012 15:14:58 GMT Content-Type: application/json;charset=UTF-8 Connection: keep-alive X-MLAPI-Version: 1.9.5 Content-Encoding: gzip X-Content-Created: 2012-07-24T14:00:59.716Z X-Content-MD5: 943541196986770119b4af1e66bda2dc
Category dump with attributes
Since categories have attributes of their own that you also need to map, by making the following call you can get a file that contains the category tree with each of it's attributes.
curl -X GET https://api.mercadolibre.com/sites/$SITE_ID/categories/all?withAttributes=true > mla.gz
curl -X GET https://api.mercadolibre.com/sites/CBT/categories/all?withAttributes=true > cbt.gz