Get a planet
You’ll better learn a little bit more about the planets. It might come in handy once space travel is available for everyone.
curl -X GET "https://galaxy.scalar.com/planets/1"
fetch("https://galaxy.scalar.com/planets/1")
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://galaxy.scalar.com/planets/1"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import requests
url = "https://galaxy.scalar.com/planets/1"
response = requests.request("GET", url)
print(response.text)
{
"id": 1,
"name": "Mars",
"description": "The red planet",
"type": "terrestrial",
"habitabilityIndex": 0.68,
"physicalProperties": {
"mass": 0.107,
"radius": 0.532,
"gravity": 0.378,
"temperature": {
"min": 130,
"max": 308,
"average": 210
}
},
"atmosphere": [
{
"compound": "CO2",
"percentage": 95.3
}
],
"discoveredAt": "1610-01-07T00:00:00Z",
"image": "https://cdn.scalar.com/photos/mars.jpg",
"satellites": [
{
"name": "Phobos",
"diameter": 22.2
}
],
"creator": {
"id": 1,
"name": "Marc"
},
"tags": [
"solar-system",
"rocky",
"explored"
],
"lastUpdated": "2024-01-15T14:30:00Z",
"successCallbackUrl": "https://example.com/webhook",
"failureCallbackUrl": "https://example.com/webhook"
}
{
"type": "https://example.com/errors/not-found",
"title": "Not Found",
"status": 404,
"detail": "The resource you are trying to access does not exist."
}
How is this guide?