forked from lthn/blockchain
Renamed Go SDK API services and documentation from BlockAPI/InfoAPI to BlockUtilsSdkClientGo/InfoUtilsSdkClientGo for consistency. Updated all references, method receivers, and usage examples accordingly. Added new Java SDK client, models, API, documentation, and build files under utils/sdk/client/java. Updated Go module dependencies and added go.sum. Enhanced Go models to support additional properties in JSON unmarshalling.
8.9 KiB
Generated
8.9 KiB
Generated
BlockApi
All URIs are relative to http://127.0.0.1:36943
| 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
BlockTemplateModel createBlockTemplate(blockTemplateRequestModel)
Create a block template for mining
Example
// Import classes:
import invalidPackageName.ApiClient;
import invalidPackageName.ApiException;
import invalidPackageName.Configuration;
import invalidPackageName.models.*;
import lthn.BlockApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://127.0.0.1:36943");
BlockApi apiInstance = new BlockApi(defaultClient);
BlockTemplateRequestModel blockTemplateRequestModel = new BlockTemplateRequestModel(); // BlockTemplateRequestModel |
try {
BlockTemplateModel result = apiInstance.createBlockTemplate(blockTemplateRequestModel);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling BlockApi#createBlockTemplate");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| blockTemplateRequestModel | BlockTemplateRequestModel |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: application/json
- Accept: application/json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 500 | text/plain | - |
| 400 | text/plain | - |
| 200 | OK | - |
getBlock
BlockDetailsModel getBlock(identifier)
Get a block by its hash or height (ID)
Example
// Import classes:
import invalidPackageName.ApiClient;
import invalidPackageName.ApiException;
import invalidPackageName.Configuration;
import invalidPackageName.models.*;
import lthn.BlockApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://127.0.0.1:36943");
BlockApi apiInstance = new BlockApi(defaultClient);
String identifier = "identifier_example"; // String | The hash (hex string) or height (integer) of the block to retrieve.
try {
BlockDetailsModel result = apiInstance.getBlock(identifier);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling BlockApi#getBlock");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| identifier | String | The hash (hex string) or height (integer) of the block to retrieve. |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: application/json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 404 | text/plain | - |
| 400 | text/plain | - |
| 200 | OK | - |
getBlocks
List<BlockDetailsModel> getBlocks()
Get one or more blocks, with optional pagination.
Example
// Import classes:
import invalidPackageName.ApiClient;
import invalidPackageName.ApiException;
import invalidPackageName.Configuration;
import invalidPackageName.models.*;
import lthn.BlockApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://127.0.0.1:36943");
BlockApi apiInstance = new BlockApi(defaultClient);
try {
List<BlockDetailsModel> result = apiInstance.getBlocks();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling BlockApi#getBlocks");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
This endpoint does not need any parameter.
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: application/json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 404 | text/plain | - |
| 400 | text/plain | - |
| 200 | A list of block objects. | - |
getHeight
HeightModel getHeight()
Get the current blockchain height
Example
// Import classes:
import invalidPackageName.ApiClient;
import invalidPackageName.ApiException;
import invalidPackageName.Configuration;
import invalidPackageName.models.*;
import lthn.BlockApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://127.0.0.1:36943");
BlockApi apiInstance = new BlockApi(defaultClient);
try {
HeightModel result = apiInstance.getHeight();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling BlockApi#getHeight");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
This endpoint does not need any parameter.
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: application/json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | OK | - |
submitBlock
SubmitBlockResponseModel submitBlock(submitBlockRequestModel)
Submit a new block to the network
Example
// Import classes:
import invalidPackageName.ApiClient;
import invalidPackageName.ApiException;
import invalidPackageName.Configuration;
import invalidPackageName.models.*;
import lthn.BlockApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://127.0.0.1:36943");
BlockApi apiInstance = new BlockApi(defaultClient);
SubmitBlockRequestModel submitBlockRequestModel = new SubmitBlockRequestModel(); // SubmitBlockRequestModel |
try {
SubmitBlockResponseModel result = apiInstance.submitBlock(submitBlockRequestModel);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling BlockApi#submitBlock");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| submitBlockRequestModel | SubmitBlockRequestModel |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: application/json
- Accept: application/json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 406 | text/plain | - |
| 400 | text/plain | - |
| 200 | OK | - |