Let's grow together
Performance based marketing & sales

API documentation

REST API

Connect Marketplace provides an API to interact with the store.

 

Supported Entities

 

Overview

Connect Marketplace API:

  • Is RESTful
  • Uses basic HTTP authentication, with admin e-mail as login and auto-generated API key as password
  • Relies on user group-defined privileges. User group assignment is defined directly in the objects
  • Uses HTTP 1.1 to implement REST.

4 methods are available to view and modify objects:

  • GET—get object data
  • PUT—update object data
  • POST—create new object
  • DELETE—delete object
  • Accepts and returns data in JSON format

Useful Tools

cURL is a cross-platform command line application that allows you to easily send HTTP requests. In UNIX-based systems, it is usually available by default with a simple curl command.

Note

All examples in this guide are given as cURL commands.

Postman is an extension for the popular Google Chrome browser. Similar extensions exist for all popular web-browsers.

Activate API Access

API access is activated/disabled on a per-user basis.

API is activated by Connect Marketplace administrator:

  1. Log in to your admin panel -> https://marketplace.connect.hr/marketplace-partner.php
  2. Go to Vendors → Message Center
  3. Write admin account you want to activate API access (for example example@company.com)
  4. Adminitrators will review your access request and activate API for you
  5. On your email you will receive API key.

The automatically generated API key will be used by this user along with their e-mail to access the API.

URLs

An API request is a regular HTTP request sent to a particular URL.

By default, Connect Marktplace uses API 1.0 with the URLs built as follows:

  • http://example.com/api/:object—refer to all objects of a certain type
  • http://example.com/api/:object/:id—refer to a single object
  • http://example.com/api/:object/:id/:nested_object:—refer to all nested objects of a certain object
  • http://example.com/api/:object/:id/:nested_object/:id—refer to a single nested object of a certain object

For example, http://example.com/api/product/1/features refers to all the features of the product with the ID 1.

Note

If mod_rewrite is disabled for you, you will have to use different URLs:

  • http://example.com/api.php?_d=:object&ajax_custom=1—refer to all objects of a certain type
  • http://example.com/api.php?_d=:object/:id&ajax_custom=1—refer to a single object
  • http://example.com/api.php?_d=:object/:id/:nested_object&ajax_custom=1—refer to all nested objects of a certain object
  • http://example.com/api.php?_d=:object/:id/:nested_object/:id&ajax_custom=1—refer to a single nested object of a certain object

Nonetheless, API 2.0 is recommended. In API 2.0 the URLs have the following structure:

  • http://example.com/api/2.0/:object—refer to all objects of a certain type
  • http://example.com/api/2.0/:object/:id—refer to a single object
  • http://example.com/api/2.0/:object/:id/:nested_object:—refer to all nested objects of a certain object
  • http://example.com/api/2.0/:object/:id/:nested_object/:id—refer to a single nested object of a certain object

Authentication

Each request must be authenticated with user’s e-mail and API key. There are 3 ways to submit authentication data in an API request:

  • Via the --user parameter (this is used in all the examples):

    curl --user admin@example.com:APIkey -X GET 'http://example.com/api/users/'
    
  • Inline passing in the URL:

    curl --basic -X GET 'http://admin%40example.com:APIkey@example.com/api/users/'
    

    Note

    @ must be replaced with %40

  • In the request header:

    curl --header 'Authorization: Basic <base64-encoded email:APIkey pair>=' -X GET 'http://example.com/api/users/'
    

    Note

    The email:APIkey pair must be encoded in base64.

    PHP example:

    $token = base64_encode("email:APIkey");
    $authHeaderString = 'Authorization: Basic ' . $token;
    

Get Data GET

To get object data, send a GET HTTP request to the URL that refers to the according object.

Request Example

Get data about the product with the ID 1:

curl --user admin@example.com:APIkey -X GET 'http://example.com/api/products/1'

Filtering

It is possible to send additional URL parameters to particularize the selection.

For example, you get all products with non-free shipping:

curl --user admin@example.com:APIkey -X GET 'http://example.com/api/products?free_shipping=N'

You can combine conditions.

Get all downloadable products with company_id 1:

curl --user admin@example.com:APIkey -X GET 'http://example.com/api/products?is_edp=Y&company_id=1'

Response

JSON array of matching objects (e.g. the products key) and the search query (the search key), or an error.

The matching objects value is an array of object IDs as keys and object field arrays as values.

Refer to the API objects page for a complete list of supported fields for all supported objects.

Comments

No posts found

Write a review