Entwickler » 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 before with the VK API, we recommend you learn about its usage principles.


You need to create an application: http://vk.com/editapp?act=create
For working by the client side choose "Standalone" platform. For working by the server side choose "Website" platform.

Fill in the title and save changes by verifying action via SMS. You will get to the app administration interface. Further you will need the "Application ID" (API_ID
 Âû ïîïàäåòå â èíòåðôåéñ àäìèíèñòðèðîâàíèÿ ïðèëîæåíèÿ.  äàëüíåéøåì Âàì ïîíàäîáÿòñÿ çíà÷åíèÿ ïîëåé «ID ïðèëîæåíèÿ» (â äîêóìåíòàöèè — API_ID, APP_ID, client_id) è «Çàùèùåííûé êëþ÷» (client_secret, app_secret).

Then you need to obtain access token for API methods calling. Use one of these ways: market scope should be requested from the user while authorizing. Possible scope values can be found at this page.

You can call 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.

By continuing to browse, you consent to our use of cookies. You can read our Cookie Policy here.