This commit is contained in:
progr76@gmail.com
2019-02-16 20:08:41 +03:00
parent 4087d50a65
commit 5affe69fe0
19 changed files with 304 additions and 77 deletions

View File

@@ -23,7 +23,7 @@ http://194.1.237.94/api/v2/GenerateKeys
As a result, JSON is returned, which contains the required result field with the value:
* 0 - the request contains errors or the result is not possible to get (for example, there is no such account),
* 1 - successful execution of the query
* 1 or >1 - successful execution of the query
text - the optional field contains a detailed description of the result
@@ -52,20 +52,28 @@ return:
2)**/api/v2/CreateAccount** - create a new account (account). In Tere free account creation is possible only in the intervals of 10 seconds. The paid version is given in the example of 2 methods **Send**
#### Parameters:
* Name - account name up to 40 bytes
* PubKey - public key in hex-format
* PrivKey - private key in hex-format
* Wait - if the number 1 is set, the response to the request is not returned until the transaction is written to the blockchain (the response time to the request is increased to 18 seconds)
example:
```js
http://127.0.0.1/api/v2/CreateAccount
{
"Name": "Hellow, world",
"PubKey": "0240EDF5ECB25D886FD58DB92A53914FAC975078C1C2EDD1AC292B70C7BC13461F"
"Name": "PrivTest02",
"PrivKey": "A2D45610FE8AC931F32480BFE3E78D26E45B0A4F88045D6518263DA12FA9C033",
"Wait":1
}
```
return:
```js
{"result":1,"text":"Added to timer","TxID":"DC316BD766AC654E0AF7260F2E010000","BlockNum":19795750}
{
"result": 190552,
"text": "Add to blockchain",
"TxID": "04711036904F1F2DDF49CC7B2F010000",
"BlockNum": 19889100
}
```
result - returns the id (number) of the created account
## Send
@@ -77,6 +85,7 @@ return:
* ToID - the account number of the recipient, the number or public key in hex format (in this case, it will create a new account with the name specified in the first line of the description of the payment and the payment the account will be charged 10 Tera)
* Amount - sum, floating-point number, or object format {SumCOIN,SumCENT}
* Description - description of payment order (optional)
* Wait - if the number 1 is set, the response to the request is not returned until the transaction is written to the blockchain (the response time to the request is increased to 8 seconds)
example1:
@@ -87,28 +96,50 @@ http://127.0.0.1/api/v2/Send
"FromPrivKey": "A2D45610FE8AC931F32480BFE3E78D26E45B0A4F88045D6518263DA12FA9C033",
"ToID":190165,
"Amount":10.5,
"Description":"Test"
"Description":"Тест",
"Wait":1
}
```
example2 (create a new account):
return:
```js
{
"result": 1,
"text": "Add to blockchain",
"TxID": "C08A0C18C1ABF4062B149B7C2F010000",
"BlockNum": 19889307
}
```
example2 (создание нового счета):
```js
http://127.0.0.1/api/v2/Send
{
"FromID": 190085,
"FromID": 190059,
"FromPrivKey": "A2D45610FE8AC931F32480BFE3E78D26E45B0A4F88045D6518263DA12FA9C033",
"ToID22":190516,
"ToID":"0240EDF5ECB25D886FD58DB92A53914FAC975078C1C2EDD1AC292B70C7BC13461F",
"Amount":10,
"Description":"New account"
"Description":"New account",
"Wait":1
}
```
return:
```js
{"result":1,"text":"OK","TxID":"BE10810FDE7A1317D9DF51D62D010000","BlockNum":19781201}
{
"result": 190551,
"text": "Add to blockchain",
"TxID": "9DD4869C4515B2A3340E887A2F010000",
"BlockNum": 19888776
}
```
result - returns the id (number) of the created account
## GetBalance
4)**/api/v2/GetBalance** - get account balance
@@ -119,15 +150,16 @@ example:
```js
http://127.0.0.1/api/v2/GetBalance
{
"AccountID": 0
"AccountID": 9
}
```
return:
```js
{
"result": 1,
"SumCOIN": 580222966,
"SumCENT": 527313901
"SumCOIN": 5589146,
"SumCENT": 555765670,
"PubKey": "02769165A6F9950D023A415EE668B80BB96B5C9AE2035D97BDFB44F356175A44FF"
}
```
@@ -137,7 +169,7 @@ return:
#### Parameters:
* TxID - Transaction ID in hex format
example:
example1:
```js
http://127.0.0.1/api/v2/GetTransaction
{
@@ -166,6 +198,26 @@ return:
"result": 1
}
```
example2:
```js
http://127.0.0.1/api/v2/GetTransaction
{
"TxID": "04711036904F1F2DDF49CC7B2F010000"
}
```
return:
```js
{
"Type": 100,
"Currency": 0,
"PubKey": "0240EDF5ECB25D886FD58DB92A53914FAC975078C1C2EDD1AC292B70C7BC13461F",
"Name": "PrivTest02",
"Adviser": 0,
"Smart": 0,
"Reserve": "000000",
"result": 190552
}
```
## GetHistoryTransactions

View File

@@ -1,6 +1,6 @@
# API v2 (для бирж и обменников)
API предназначено для облегчения написания сторонних приложений. На стороне сервера выполняется криптография и операции POW. Поэтому оно не рекомендуется для публичного доступа, т.к. не защищено от DDOS атак. Используйте его, если приложения такие как сервер биржи находятся в одной приватной сети.
API предназначено для облегчения написания сторонних приложений. На стороне сервера выполняется криптография и операции POW. Поэтому оно не рекомендуется для публичного доступа, т.к. нет защиты от DDOS атак. Используйте его, если приложения такие как сервер биржи находятся в одной приватной сети.
Данный API доступен если на ноде запущен http-хостинг и включена константа USE_HARD_API_V2.
@@ -22,7 +22,7 @@ http://194.1.237.94/api/v2/GenerateKeys
В качестве результат возвращается JSON, который содержит обязательное поле result со значением:
* 0 - запрос содержит ошибки или результат не возможно получить (например нет такого счета),
* 1 - успешное выполнение запроса
* 1 или >1 - успешное выполнение запроса (в случае запросов создания новых счетов и режимом Wait:1 здесь возвращается номер созданного счета)
text - опциональное поле содержит подробное описание результата
@@ -51,20 +51,28 @@ return:
2)**/api/v2/CreateAccount** - создание нового счета (аккаунта). В Тере бесплатное создание счета возможно только в промежутках из 10 секунд. Платный вариант приведен в примере 2 метода **Send**
#### Параметры:
* Name - имя счета до 40 байт
* PubKey - публичный ключ в hex-формате
* PrivKey - приватный ключ в hex-формате
* Wait - если установлена цифра 1, то ответ на запрос не возвращается до тех пор пока транзакция не будет записана в блокчейн (время ответа на запрос увеличивается до 18 сек)
example:
```js
http://127.0.0.1/api/v2/CreateAccount
{
"Name": "Hellow, world",
"PubKey": "0240EDF5ECB25D886FD58DB92A53914FAC975078C1C2EDD1AC292B70C7BC13461F"
"Name": "PrivTest02",
"PrivKey": "A2D45610FE8AC931F32480BFE3E78D26E45B0A4F88045D6518263DA12FA9C033",
"Wait":1
}
```
return:
```js
{"result":1,"text":"Added to timer","TxID":"DC316BD766AC654E0AF7260F2E010000","BlockNum":19795750}
{
"result": 190552,
"text": "Add to blockchain",
"TxID": "04711036904F1F2DDF49CC7B2F010000",
"BlockNum": 19889100
}
```
result - возвращает номер созданного аккаунта
## Send
@@ -76,6 +84,7 @@ return:
* ToID - номер счета получателя, число или публичный ключ в hex-формате (в этом случае будет создан новый счет с именем заданным в первой строке описания платежа и в качестве оплаты создания счета спишется 10 Тера)
* Amount - сумма, число с плавающей точкой или объект в формате {SumCOIN,SumCENT}
* Description - описание платежка (необязательный параметр)
* Wait - если установлена цифра 1, то ответ на запрос не возвращается до тех пор пока транзакция не будет записана в блокчейн (время ответа на запрос увеличивается до 8 сек)
example1:
@@ -86,27 +95,49 @@ http://127.0.0.1/api/v2/Send
"FromPrivKey": "A2D45610FE8AC931F32480BFE3E78D26E45B0A4F88045D6518263DA12FA9C033",
"ToID":190165,
"Amount":10.5,
"Description":"Тест"
"Description":"Тест",
"Wait":1
}
```
return:
```js
{
"result": 1,
"text": "Add to blockchain",
"TxID": "C08A0C18C1ABF4062B149B7C2F010000",
"BlockNum": 19889307
}
```
example2 (создание нового счета):
```js
http://127.0.0.1/api/v2/Send
{
"FromID": 190085,
"FromID": 190059,
"FromPrivKey": "A2D45610FE8AC931F32480BFE3E78D26E45B0A4F88045D6518263DA12FA9C033",
"ToID22":190516,
"ToID":"0240EDF5ECB25D886FD58DB92A53914FAC975078C1C2EDD1AC292B70C7BC13461F",
"Amount":10,
"Description":"New account"
"Description":"New account",
"Wait":1
}
```
return:
```js
{"result":1,"text":"OK","TxID":"BE10810FDE7A1317D9DF51D62D010000","BlockNum":19781201}
{
"result": 190551,
"text": "Add to blockchain",
"TxID": "9DD4869C4515B2A3340E887A2F010000",
"BlockNum": 19888776
}
```
result - возвращает номер созданного аккаунта
## GetBalance
@@ -136,7 +167,7 @@ return:
#### Параметры:
* TxID - ИД транзакции в hex-формате
example:
example1:
```js
http://127.0.0.1/api/v2/GetTransaction
{
@@ -166,6 +197,27 @@ return:
}
```
example2:
```js
http://127.0.0.1/api/v2/GetTransaction
{
"TxID": "04711036904F1F2DDF49CC7B2F010000"
}
```
return:
```js
{
"Type": 100,
"Currency": 0,
"PubKey": "0240EDF5ECB25D886FD58DB92A53914FAC975078C1C2EDD1AC292B70C7BC13461F",
"Name": "PrivTest02",
"Adviser": 0,
"Smart": 0,
"Reserve": "000000",
"result": 190552
}
```
## GetHistoryTransactions
6)**/api/v2/GetHistoryTransactions** - получить историю транзакций счета