1
0
Fork 0
forked from lthn/blockchain
blockchain/utils/sdk/client/php/docs/Api/BlockApi.md
Snider 88d4357628
New API Interface (#27)
This pull request introduces a comprehensive new API interface for the blockchain, leveraging OpenAPI v3 to facilitate direct consumption of chain data by GUI and web applications. This change significantly refines the project's build infrastructure, incorporating Conan for dependency management and CMake for configuration, alongside the integration of an OpenAPI Generator to produce SDKs for multiple languages. 

### Highlights

* **New API Interface**: Introduced a new API interface using OpenAPI v3 to enable GUI/WEB development to consume chain data without needing custom server applications.
* **Build System Enhancements**: Significant updates to the build system, including Makefile, CMake, and Conan configurations, to streamline the build process and support new functionalities.
* **Multi-language SDK Generation**: Integrated OpenAPI Generator to automatically create SDKs for various programming languages, including Go, Angular, and PHP, simplifying client-side integration.
2025-10-19 19:12:37 +01:00

7 KiB
Generated

lthn\BlockApi

All URIs are relative to http://127.0.0.1:36943, except if the operation defines another base path.

Method HTTP request Description
createBlockTemplate() POST /block/template Create a block template for mining
getBlock() GET /block/{identifier} Get a block by its hash or height (ID)
getBlocks() GET /block Get one or more blocks, with optional pagination.
getHeight() GET /block/height Get the current blockchain height
submitBlock() POST /block/submit Submit a new block to the network

createBlockTemplate()

createBlockTemplate($block_template_request_model): \lthn\lthn\BlockTemplateModel

Create a block template for mining

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');



$apiInstance = new lthn\Api\BlockApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client()
);
$block_template_request_model = new \lthn\lthn\BlockTemplateRequestModel(); // \lthn\lthn\BlockTemplateRequestModel

try {
    $result = $apiInstance->createBlockTemplate($block_template_request_model);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling BlockApi->createBlockTemplate: ', $e->getMessage(), PHP_EOL;
}

Parameters

Name Type Description Notes
block_template_request_model \lthn\lthn\BlockTemplateRequestModel

Return type

\lthn\lthn\BlockTemplateModel

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

getBlock()

getBlock($identifier): \lthn\lthn\BlockDetailsModel

Get a block by its hash or height (ID)

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');



$apiInstance = new lthn\Api\BlockApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client()
);
$identifier = 'identifier_example'; // string | The hash (hex string) or height (integer) of the block to retrieve.

try {
    $result = $apiInstance->getBlock($identifier);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling BlockApi->getBlock: ', $e->getMessage(), PHP_EOL;
}

Parameters

Name Type Description Notes
identifier string The hash (hex string) or height (integer) of the block to retrieve.

Return type

\lthn\lthn\BlockDetailsModel

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

getBlocks()

getBlocks(): \lthn\lthn\BlockDetailsModel[]

Get one or more blocks, with optional pagination.

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');



$apiInstance = new lthn\Api\BlockApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client()
);

try {
    $result = $apiInstance->getBlocks();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling BlockApi->getBlocks: ', $e->getMessage(), PHP_EOL;
}

Parameters

This endpoint does not need any parameter.

Return type

\lthn\lthn\BlockDetailsModel[]

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

getHeight()

getHeight(): \lthn\lthn\HeightModel

Get the current blockchain height

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');



$apiInstance = new lthn\Api\BlockApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client()
);

try {
    $result = $apiInstance->getHeight();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling BlockApi->getHeight: ', $e->getMessage(), PHP_EOL;
}

Parameters

This endpoint does not need any parameter.

Return type

\lthn\lthn\HeightModel

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

submitBlock()

submitBlock($submit_block_request_model): \lthn\lthn\SubmitBlockResponseModel

Submit a new block to the network

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');



$apiInstance = new lthn\Api\BlockApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client()
);
$submit_block_request_model = new \lthn\lthn\SubmitBlockRequestModel(); // \lthn\lthn\SubmitBlockRequestModel

try {
    $result = $apiInstance->submitBlock($submit_block_request_model);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling BlockApi->submitBlock: ', $e->getMessage(), PHP_EOL;
}

Parameters

Name Type Description Notes
submit_block_request_model \lthn\lthn\SubmitBlockRequestModel

Return type

\lthn\lthn\SubmitBlockResponseModel

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]