Creating an order

API method
HTTP
POST https://api.tronmart.net/v1/Order/Create

Request parameters
FieldTypeDescription
resource_typeinteger0 … bandwidth
1 … energy
only 1 is allowed now
receive_addressstringResource receiving address
resource_valueintegerThe number of resources to rent
rent_durationinteger1 – 23 for 'h'
1 – 30 for 'd'
1200 - etc. for 'T' (20 tron time units equals 1 minute)
rent_time_unitchar'h' … hour
'd' … day
'T' … tron time unit

Example of request parameters
JSON
{
    "resource_type": 1,
    "receive_address": "HCjRQtYH..................KHUarM3w",
    "resource_value": 32000,
    "rent_duration": 1,
    "rent_time_unit": "h"
}

Response parameters
FieldTypeDescription
codestringThe return code of the request call, the list of error codes is here
msgstringDetailed information about a possible error
errorsarrayDetailed information on errors
request_idstringAn internal request identifier that is used to identify the request in case of problems
datajsonOrder details, details is here

Example of response parameters
JSON
{
    "code": "Success",
    "msg": "Success",
    "errors": [],
    "request_id": "e98e15e4-ea49-45e1-a37e-c71ee72775bf",
    "data": {
        "order_no": "0010a464-b5be-4047-ab53-66fcc2178e62",
        "resource_type": 1,
        "receivers": [
            {
                "receive_address": "HCjRQtYH..................KHUarM3w",
                "resource_value": 32000,
                "price_in_sun": 95,
                "fixed_tax": 0.560000,
                "price": 3.600000
            }
        ],
        "create_time": 1715437599596,
        "expire_time": 1715523999596,
        "settle_address": "YEg7yUff..................72j78oH4",
        "resource_value": 32000,
        "resource_split_value": 1000000,
        "rent_duration": 1200,
        "rent_time_unit": "T",
        "frozen_balance": null,
        "payment_address": "TThsE7hE..................r1dEF4zH",
        "pay_amount": 3.600000,
        "pay_time": null,
        "refund_tx_id": null,
        "refund_time": 0,
        "refund_amount": 0,
        "refund_status": null,
        "status": "New",
        "sub_order": null
    }
}

Example of a call
HTTP
POST /v1/Order/Create HTTP/1.1
Host: api.tronmart.net
key: C2CC6C80-B86A-4E08-AE69-E28DA009A50F
Content-Type: application/json
{
    "resource_type": 1,
    "receive_address": "HCjRQtYH..................KHUarM3w",
    "resource_value": 32000,
    "rent_duration": 1,
    "rent_time_unit": "h"
}
cURL
curl -X POST https://api.tronmart.net/v1/Order/Create
     -H 'Content-Type: application/json'
     -H 'key: C2CC6C80-B86A-4E08-AE69-E28DA009A50F'
     -d '{ 
            "resource_type": 1,
            "receive_address": "HCjRQtYH..................KHUarM3w",
            "resource_value": 32000,
            "rent_duration": 1,
            "rent_time_unit": "h" 
     }'
C# (HttpClient)
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.tronmart.net/v1/Order/Create");
request.Headers.Add("key", "C2CC6C80-B86A-4E08-AE69-E28DA009A50F");
var content = new StringContent("{\r\n    \"resource_type\": 1,\r\n    \"receive_address\": \"HCjRQtYH..................KHUarM3w\",\r\n    \"resource_value\": 32000,\r\n    \"rent_duration\": 1,\r\n    \"rent_time_unit\": \"h\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
Java (OkHttp)
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"resource_type\": 1,\r\n    \"receive_address\": \"HCjRQtYH..................KHUarM3w\",\r\n    \"resource_value\": 32000,\r\n    \"rent_duration\": 1,\r\n    \"rent_time_unit\": \"h\"\r\n}");
Request request = new Request.Builder()
  .url("https://api.tronmart.net/v1/Order/Create")
  .method("POST", body)
  .addHeader("key", "C2CC6C80-B86A-4E08-AE69-E28DA009A50F")
  .addHeader("Content-Type", "application/json")
  .build();
Response response = client.newCall(request).execute();
Go (native)
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.tronmart.net/v1/Order/Create"
  method := "POST"

  payload := strings.NewReader(`{`+"
"+`
    "resource_type": 1,`+"
"+`
    "receive_address": "HCjRQtYH..................KHUarM3w",`+"
"+`
    "resource_value": 32000,`+"
"+`
    "rent_duration": 1,`+"
"+`
    "rent_time_unit": "h"`+"
"+`
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("key", "C2CC6C80-B86A-4E08-AE69-E28DA009A50F")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}