API version: 1.13

Every API call must be made through the subdomain: https://api.saleslayer.com

To increase security, all calls should be done via SSL, but they can also be open.

Sending requests from the client

The client that sends a data request to api.saleslayer.com must include the necessary parameters to execute the query. These parameters can be included in the URL itself via GET or in the body of the call using POST.

Required identification and securitization parameters

code= Identification code of the connector
time= timestamp() (UNIX international date)
unique= mt_rand() or rand() (Random security number)
key= SHA1 code with the combination of ‘code’ + ‘secret_key’ + ‘time’ + ‘unique’.

These three parameters are used to ensure that the client that sends the request is allowed to do so. The generator code is:

SHA1 (code + secret_key + time + unique);

Other parameters

last_update = Timestamp (UNIX date) of last database update. If this parameter is not sent is assumed to return the whole catalogue data structure. In other words, excluding a timestamp would be like requesting to import data for the very first time or trying to refresh the database completely.
version = API version to be used. Omitting this parameter assumes the last existing version. It can also be indicated the ​​relative subversion values using the ‘x’ value. For example: version: 2.x
output = Output mode: JSON / XML. Default: JSON
compression = Boolean to indicate whether you prefer compressed version or not. Default: 1 (yes, if possible).

General structure API response:

Basic structure of the customizable APIs:



[version] = version of the API 

[date] = datetime response

[action] = action to be done with data (update = update changes, refresh = refresh all data)

[error] = if there is an error, this variable would contain the error code. You can find a list of possible errors at the end of this document.

[schema] = specific configuration (only appears if there are changes, in full postbacks or if it's requested specifically) 

[data] = [ data matrix

	[sections] = [ matrix with the section structure ]

	[products] = [ matrix with the product structure + formats + images gallery ]

	[locations] = [ locations matrix ]
	
	[ {table name} ] = [ matrix with the names of the variables ] ...


]

[image_packs] = [ URLs of the offline TAR files ]

The data of the sub-matrix contained in [data] will provide a status indicator: STATUS = M/D (M=modified, D=deleted). Example:



[data_schema] = [
	'{table name}' = [ 0=STATUS, 1=ID,  2=name, … ],
	...
] ,

[data_schema_info] = [
	'{table name}' = [
		'{field name}' = [
			'type' = '{string|numeric|boolean|datetime|image|file}',
			'language_code' => '{en|es|fr|...}', 
			'basename' => '{name of the field without language code}',
			'sizes' => [
				'{extension}' => array ( 'width', 'height' ),
				...
			]
		], ...
	], ...
] ,

[data] = [
	[ {table name} ] = [
		[0] = [ 0=M, 2=123, 2='section 1', … ]


All the fields of the [data] tables have the same format except images and files that have a matrix structure with the following parameters:


[n] = [ ← 'n' field related to an image or file

			Gallery element 1:
			[0] = [
				[0] = STATUS (M = modified , U=unmodified),
				[1] = ID (unique ID of the md5 format file),
				[2] = file URL (to one of the image sizes),
				[3] = file URL (to other of the image sizes),
				…
			],
			Gallery element 2:
			[1] = [
				…
			],
			...
		]
	], ...
] ,

Offline mode information:


[offline_files] = only appears in “action”=”refresh” and only if the connector contains mode_offline=1

List of API error codes

1 Validation error Error
2 Invalid connector code (‘code’) Error
3 Invalid unique key (‘unique’) Error
4 Invalid codification key (‘key’) Error
5 Date of last update incorrect Informative, returns all data
6 The specified API version does not exist Informative
7 Invalid output mode (‘output’) Informative, returns all data in JSON mode.
8 Invalid compression type (‘compression’) Informative, does not compress.
9 Invalid private key Error
10 Service temporary blocked Alert
11 Service temporary not available Alert
12 Invalid timestamp (‘time’) Error
13 Expired timestamp (‘time’) Error

 

Example of data structure returned by the API



	 Array
	(
    [version] => 1.1 Beta
    [time] => 1401558085
    [action] => refresh
    [schema] => Array
        (
            [languages] => Array
                (
                    [0] => en
                    [1] => es
                )

            [default_language] => es
            [offline_mode] => 0
            [connector_type] => default
        )

    [data_schema] => Array
        (
            [catalogue] => Array
                (
                    [0] => STATUS
                    [1] => ID
                    [2] => ID_PARENT
                    [3] => section_reference
                    [4] => section_name_en
                    [5] => section_name_es
                    [6] => parent_section_reference
                    [7] => Array
                        (
                            [image_reference] => Array
                                (
                                    [0] => STATUS
                                    [1] => ID
                                    [2] => TH
                                    [3] => THM
                                )
                        )
                )
        )

    [data_schema_info] => Array
        (
            [catalogue] => Array
                (
                    [section_reference] => Array
                        (
                            [type] => string
                        )

                    [section_name_en] => Array
                        (
                            [type] => string
                            [basename] => section_name
                            [language_code] => en
                        )

                    [section_name_es] => Array
                        (
                            [type] => string
                            [basename] => section_name
                            [language_code] => es
                        )

                    [parent_section_reference] => Array
                        (
                            [type] => string
                        )

                    [image_reference] => Array
                        (
                            [type] => image
                            [sizes] => Array
                                (
                                    [TH] => Array
                                        (
                                            [width] => 100
                                            [height] => 85
                                        )

                                    [THM] => Array
                                        (
                                            [width] => 300
                                            [height] => 250
                                        )
                                )
                        )
                )
        )

    [data] => Array
        (
            [catalogue] => Array
                (
                    [0] => Array
                        (
                            [0] => M
                            [1] => 1
                            [2] => 0
                            [3] => CAT01
                            [4] => 
                            [5] => cat 1
                            [6] => 
                            [7] => Array
                                (
                                    [0] => Array
                                        (
                                            [0] => M
                                            [1] => 7a6d46b1d7f200d99783f40742d3e065
                                            [2] => http://127.0.0.1/saleslayer/cloud/Files/Temp/CMP113/Tile_TH.jpg
                                            [3] => http://127.0.0.1/saleslayer/cloud/Files/Temp/CMP113/Tile_THM.jpg
                                        )
                                )
                        )

                    [1] => Array
                        (
                            [0] => M
                            [1] => 2
                            [2] => 0
                            [3] => CAT02
                            [4] => 
                            [5] => cat 2
                            [6] => 
                            [7] => Array
                                (
                                )
                        )
                )
        )
)



Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>