Developers » Market API
Market API
1. Prepare for Using
2. Actions with Items
    2.1. Adding Items
    2.2. Other Actions
3. Images Uploading
    3.1. Uploading a Main Market Item Photo
    3.2. Uploading Additional Market Item Photos
    3.3. Uploading a Market Collection Photo
4. Existing Tools

market section methods are used for working with Products. In this manual we will describe what you can do with them.
1. Prepare for Using
Learning API — if you have never worked with the VK API before, we recommend you familiarize yourself with its usage principles.

Enable the “Products” section in your community settings or using the groups.edit method.

Create an application: http://vk.com/editapp?act=create.
To work client-side (for example, in a mobile application) choose the "Standalone" platform. For working server-side, choose the "Website" platform.

Input title and save changes by verifying the action via SMS. You will get to the app administration interface. The values of “Application ID” (API_ID, APP_ID, client_id in documentation) and “Secret key” (client_secret, app_secret) will be needed later.

Then you need to obtain the access token for calling API methods. You can do it in one of the following ways: While authorizing, you should request the market permission from the user. Possible permission values can be found on this page.

You can call our market API methods directly or using our SDK.
2. Actions with Items
2.1. Adding Items
Use the method market.add to add a new item to the community. In owner_id, it is necessary to pass your community ID with a minus
sign (-). The name and description is set by the parameters name è description and price by the parameter price. The category_id is the item’s category (for example, «Accessories»). A list of categories is available by using the method market.getCategories. If an item is not yet available, then to hide it from users, pass deleted = 1.

In main_photo_id and photo_ids, it is necessary to pass picture IDs (main and additional) for an item. To learn more about uploading photos, go to the next section.

After successfully adding an item, the method will return its ID in the field market_item_id. The item can be used as an attachment in wall posts and personal messages. To do this, pass within the parameter attachments (attachment) its string ID in the format market-{owner_id}_{market_item_id}. For example, market-12345_54321.

2.2. Other Actions
3. Images Uploading
3.1. Uploading a Main Market Item Photo
Supported formats: JPG, PNG, GIF, BMP.
Limits: minimum photo size 400x400px, width+height not more than 14000px, file size up to 50 MB.
POST request field: file.

Receiving an Address
Call photos.getMarketUploadServer with main_photo=1 to receive an upload server address.

Sending Files
Send a file to upload_url received before forming a POST request with file field containing an image in multipart/form-data format.

When uploaded successfully server returns a JSON object with server, photo, hash, crop_data, crop_hash fields:
{
"server":625831,
"photo":"[{\"photo\":\"8d81799f90:w\",\"sizes\":[[\"s\",\"625831075\",\"45839\",\"-5fbUeQq1YY\",75,56],[\"m\",\"625831075\",\"4583a\",\"G8yAYbsk7M4\",130,97]]}]",
"hash":"8954a4da5ba06d4e",
"crop_data":"oAAmMpwAAAAAlTWyjA",
"crop_hash":"729155760247b391134"
}

For additional photos crop_data and crop_hash are not returned.

The server field contains numeric value, hash, crop_data and crop_hash are strings, photo is a JSON object that should be saved as it is (but remove symbols screening before using further). In PHP json_decode() can be used for the whole reply and then stripslashes() for the photo object.

Saving Results
To save a photo call photos.saveMarketPhoto with received server, photo, crop_data, crop_hash parameters.

After successful upload you may attach it to a market item using market.add or market.edit with a photo id in main_photo_id'.

3.2. Uploading Additional Market Item Photos
Supported formats: JPG, PNG, GIF, BMP.
Limits: minimum photo size 400x400px, width+height not more than 14000px, file size up to 50 MB.
POST request field: file.

Receiving an Address
Call photos.getMarketUploadServer to receive an upload server address. To upload an item's main photo add main_photo=1.

Sending Files
Send a file to upload_url received before forming a POST request with file field containing an image in multipart/form-data format.

When uploaded successfully server returns a JSON object with server, photo, hash fields:
{
"server":625831,
"photo":"[{\"photo\":\"8d81799f90:w\",\"sizes\":[[\"s\",\"625831075\",\"45839\",\"-5fbUeQq1YY\",75,56],[\"m\",\"625831075\",\"4583a\",\"G8yAYbsk7M4\",130,97]]}]",
"hash":"8954a4da5ba06d4e",
}


The server field contains numeric value, hash is string, photo is a JSON object that should be saved as it is (but remove symbols screening before using further). In PHP json_decode() can be used for the whole reply and then stripslashes() for the photo object.

Saving Results
To save a photo call photos.saveMarketPhoto with received server, hash, photo parameters.

After successful upload you may attach it to a market item using market.add or market.edit with a photo id in photo_id.

3.3. Uploading a Market Collection Photo
Supported formats: JPG, PNG, GIF, BMP.
Limits: minimum photo size 1280x720px, width+height not more than 14000px, file size up to 50 MB.
POST request field: file.

Receiving an Address
Call photos.getMarketAlbumUploadServer to get an upload server address.

Sending Files
Send a file to upload_url received previously by forming a POST request with file field containing an image in multipart/form-data format.

When uploaded successfully server returns a JSON object with server, photo, gid, hash fields:
{
"server":999,
"photo":"eyJwaG90byI6IntcInBob",
"gid":102416739,
"hash":"0adc3bd6509fdcf97052b0594c4063ff"
}

Server and gid contain numeric values, photo and hash are strings.

Saving Results
To save a photo call photos.saveMarketAlbumPhoto with received server, photo, hash parameters.

After successful upload you may attach it to a market album with market.addAlbum or market.editAlbum sending a photo id in photo_id.