Search code examples
curlplesk

Using curl to get a specific value from Plesk Remote API (REST)


I use curl to get a DNS record from my Plesk server:

curl -X GET -H 'authorization: Basic xxx' -H 'accept: application/json' 'https://example.com:8443/api/v2/dns/records/15781/'

result:

{
    "id": 15781,
    "type": "A",
    "host": "home.example.com",
    "value": "123.123.123.123",
    "opt": "",
    "ttl": 600
}

But what if I only want 123.123.123.123?


Solution

  • Use jq

    Try this:

    curl -s -X GET -H 'authorization: Basic xxx' -H 'accept: application/json' 'https://example.com:8443/api/v2/dns/records/15781/' | jq '.value'
    

    See more in the documentation.