hscore/hsapi

REST api for B2B partners of Hifi Station Kft.

1.0.7 2022-07-06 13:09 UTC

This package is auto-updated.

Last update: 2025-06-06 19:50:39 UTC


README

In Hifi Station Kft we decided to create a new automation system for our B2B partners. You can connect your webshop, ecommerce, or any other system to our API.

We won't be able to write your backend code but we will help you to create the connection.

The api does not support OpenCart/Magento/PrestaShop/WooCommerce/Unas/Shoprenter/etc. You need to write your own code to connect to your system.

Requirements

  • PHP 7.4
  • Composer
  • ext-openssl: *
  • ext-simlexml: *
  • ext-json: *

Features

  • List products with informations
  • Secure authentication (HTTP Basic Auth + API Key)
  • JSON/XML REST output

Installation

"hscore/hsapi": "*"

or run

composer require hscore/hsapi

Note that the vendor folder and the vendor/autoload.php script are generated by Composer; they are not part of the api.

Alternatively, if you're not using Composer, you can download HSApi as a zip file, then copy the contents of the HSApi folder into one of the include_path directories specified in your PHP configuration and load class file manually:

use hscore\RequestGenerator;
require 'path/to/src/RequestGenerator.php'; /* or wherever the file is located */

Authentication

In order to use the API you need to authenticate. You can do this by using the authenticate method.

We prepared a simlified authentication method.

You can use the authentication credentails in the following way: https://api.hifi-station.hu/v2/products?username=USERNAME&password=PASSWORD&api_key=API_KEY In the email that we send you after a successful registration copy the data and change the UPPERCASE strings. You can change the output (JSON or XML) by adding the extension to "products". https://api.hifi-station.hu/v2/products.xml or json

$request->authenticate('api_username', 'api_password', 'api_key');

Output format

We provide two output formats: JSON and XML. To change the output format, use the setOutputFormat method.

$request->setOutputFormat('json'); // or 'xml', default is 'json'

Use this method before the send() method.

Usage

$request = new RequestGenerator('products');
$request->authenticate('api_username', 'api_password', 'api_key');

$response = $request->send();

echo $response;

Other informations

Note, that the API is not stable yet. In the result the stock tag is not always correct. If we have more than 10 product in stock the value always will be 10.

Functions

send() return the response in the format you specified.

authenticate(string $username, string $password, string $api_key) authenticate the request.

setOutputFormat(string $type) set the output format.

public $disablePrettyHeader = false; disable the php header() function.

Security

Please submit bug reports, or you found a mistake in the docs, or want to add something suggestions create a pull request or go ahead and create an issue at Github issue tracker

Disclaimer

This is an open source project. We are not responsible for any damage caused by this software. If you want to update the prices of the product automatically, please note that it may differ from the price you offer.