Astronomical Unit Converter
curl --request POST \
--url https://api.iotools.cloud/v1/tool/astronomical-unit-converter \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"value": "1",
"fromUnit": "au",
"precision": "6"
}
'import requests
url = "https://api.iotools.cloud/v1/tool/astronomical-unit-converter"
payload = {
"value": "1",
"fromUnit": "au",
"precision": "6"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({value: '1', fromUnit: 'au', precision: '6'})
};
fetch('https://api.iotools.cloud/v1/tool/astronomical-unit-converter', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.iotools.cloud/v1/tool/astronomical-unit-converter",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'value' => '1',
'fromUnit' => 'au',
'precision' => '6'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.iotools.cloud/v1/tool/astronomical-unit-converter"
payload := strings.NewReader("{\n \"value\": \"1\",\n \"fromUnit\": \"au\",\n \"precision\": \"6\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.iotools.cloud/v1/tool/astronomical-unit-converter")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"value\": \"1\",\n \"fromUnit\": \"au\",\n \"precision\": \"6\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.iotools.cloud/v1/tool/astronomical-unit-converter")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"value\": \"1\",\n \"fromUnit\": \"au\",\n \"precision\": \"6\"\n}"
response = http.request(request)
puts response.read_body{
"tool": "astronomical-unit-converter",
"tool_version": "1.0.2",
"outputs": {
"table": [
{
"unit": "Astronomical units (AU)",
"value": "1"
},
{
"unit": "Kilometers (km)",
"value": "149597870.7"
},
{
"unit": "Miles (mi)",
"value": "92955807.273026"
},
{
"unit": "Light-seconds",
"value": "499.004784"
},
{
"unit": "Light-minutes",
"value": "8.316746"
},
{
"unit": "Light-hours",
"value": "0.138612"
},
{
"unit": "Light-days",
"value": "0.005776"
},
{
"unit": "Light-years (ly)",
"value": "0.000016"
},
{
"unit": "Parsecs (pc)",
"value": "0.000005"
},
{
"unit": "Light travel time",
"value": "8 min 19 s"
}
]
},
"credits_used": 5,
"credits_remaining": null
}Converters
Astronomical Unit Converter API
Convert astronomical distances between AU, kilometers, miles, light-seconds, light-minutes, light-hours, light-days, light-years and parsecs at once, with the light travel time for the distance.
POST
/
v1
/
tool
/
astronomical-unit-converter
Astronomical Unit Converter
curl --request POST \
--url https://api.iotools.cloud/v1/tool/astronomical-unit-converter \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"value": "1",
"fromUnit": "au",
"precision": "6"
}
'import requests
url = "https://api.iotools.cloud/v1/tool/astronomical-unit-converter"
payload = {
"value": "1",
"fromUnit": "au",
"precision": "6"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({value: '1', fromUnit: 'au', precision: '6'})
};
fetch('https://api.iotools.cloud/v1/tool/astronomical-unit-converter', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.iotools.cloud/v1/tool/astronomical-unit-converter",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'value' => '1',
'fromUnit' => 'au',
'precision' => '6'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.iotools.cloud/v1/tool/astronomical-unit-converter"
payload := strings.NewReader("{\n \"value\": \"1\",\n \"fromUnit\": \"au\",\n \"precision\": \"6\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.iotools.cloud/v1/tool/astronomical-unit-converter")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"value\": \"1\",\n \"fromUnit\": \"au\",\n \"precision\": \"6\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.iotools.cloud/v1/tool/astronomical-unit-converter")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"value\": \"1\",\n \"fromUnit\": \"au\",\n \"precision\": \"6\"\n}"
response = http.request(request)
puts response.read_body{
"tool": "astronomical-unit-converter",
"tool_version": "1.0.2",
"outputs": {
"table": [
{
"unit": "Astronomical units (AU)",
"value": "1"
},
{
"unit": "Kilometers (km)",
"value": "149597870.7"
},
{
"unit": "Miles (mi)",
"value": "92955807.273026"
},
{
"unit": "Light-seconds",
"value": "499.004784"
},
{
"unit": "Light-minutes",
"value": "8.316746"
},
{
"unit": "Light-hours",
"value": "0.138612"
},
{
"unit": "Light-days",
"value": "0.005776"
},
{
"unit": "Light-years (ly)",
"value": "0.000016"
},
{
"unit": "Parsecs (pc)",
"value": "0.000005"
},
{
"unit": "Light travel time",
"value": "8 min 19 s"
}
]
},
"credits_used": 5,
"credits_remaining": null
}Authorizations
Body
application/json
Response
Tool output
Was this page helpful?