• Introducing WebPros Cloud - a fully managed infrastructure platform purpose-built to simplify the deployment of WebPros products !  WebPros Cloud enables you to easily deliver WebPros solutions — without the complexity of managing the infrastructure.
    Join the pilot program today!
  • Support for BIND DNS has been removed from Plesk for Windows due to security and maintenance risks.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS.

Question problem with plesk rest-api

millerbln

New Pleskian
Server operating system version
Ubuntu 24.04 x86_64
Plesk version and microupdate number
Plesk Obsidian 18.0.70.1
hello,
i have problems to get the traffic with rest-api ;-(

this and other commands working very well:
Code:
curl -X GET -H "X-API-Key: 12345678-1234-5678-1234-123456789012" -H "Content-Type: application/json" -H "Accept: application/json" "https://xx-yy.de:8443/api/v2/server"
i get all Infos About the server.

but this command not working, i have try with several changes,
Nothing helps ;-(

Code:
curl -X POST -H "X-API-Key: 12345678-1234-5678-1234-123456789012" -H "Content-Type: application/json" -H "Accept: application/json" -d @/root/pleskapi/plesk-traffic1.json "https://xx-xx.de:8443/api/v2/cli/webspace/get_traffic"

Code:
my plesk-traffic1.json is this:
{
<packet>
    <webspace>
      <get_traffic>
         <filter-id>5</filter-id>     
           <since_date>2025-03-01</since_date>
       </get_traffic>
    </webspace>
  </packet>
 }

can anybody help me please ??

thanks & regards
millerbln

 
No need to write your whole post in large and bold text. It doesn't make it any more readable for others (on the contrary).

Anyway, /api/v2/cli/webspace/get_traffic is not a valid end point for the REST API. You've seem to have mixed up the REST API and XML API, which won't work (as you've noticed). You can call the /api/v2/cli/commands end point to see which exact CLI command are available for the REST API.

For example to get the traffic for a particular domain you can use the /api/v2/cli/domain/call end-point, which runs the CLI command (plesk bin domain example.com --info) to fetch all kinds of information domain from that particular domain. Including traffic usage. Have a look at the REST API playround in Plesk for example on how to use the CLI parameters on the REST API.

Alternatively you can use the XML API instead to get traffic usage on a domain, for which you can look at the documentation for more details.

Hope this helps.
 
Last edited:
i write large and bold not for others, i do i for me, that i can see, what i write.
i am an old man, my eyes have the same age like me.

i wrote now:
/api/v2/cli/domain/call mydomain.xx -info"
and
/api/v2/cli/domain/call/mydomain.xx -info"

result:
URL rejected: Malformed input to a URL function
:-(

when i look at the "agent_input.svg" , than i see, my "plesk-traffic1.json" is not for the rest api.

but how can i give in XML API to the "enterprise/control/agent.php" this, what i want ?
agent.php?x1=5&x2=3 ????

but always thanks for try to help me, kaspar
 
You'll need to to provide the required parameters in the body of the API call. For example with the REST API you can do:
Code:
curl -X POST \
'https://xx-xx.de:8443/api/v2/cli/domain/call' \
-H 'X-API-Key: 12345678-1234-5678-1234-123456789012' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json'  \
-d '{"params": [ "--info", "example.com"]}'
This uses the -d (--data) flag to send the required parameters for the call in the JSON format {"params": [ "--info", "example.com"]}.

You'll find more information and example's in the REST API playground. When you're logged in to Plesk go to Tools & Settings > Remote API (REST) > Plesk REST API.

For the XML API you'll need send the XML payload into the body. For example
Code:
curl -X POST \
'https://xx-xx.de:8443/api/v2/cli/domain/call' \
-H 'KEY:12345678-1234-5678-1234-123456789012' \
-H 'Content-Type: text/xml' \
-H 'Accept: text/xml' \
-d '<packet><webspace><get_traffic><filter><name>example.com</name></filter><since_date>2025-01-01</since_date></get_traffic></webspace></packet>'
More information about making calls with the XMP API can be read in the XML API documentation.

i write large and bold not for others, i do i for me, that i can see, what i write.
i am an old man, my eyes have the same age like me.
I understand, my eyesight has diminished too as I get older (and spend too much time behind a computer screen). Perhaps it helps to configure your display scale or use the browser zoom feature. Here is a related video that explains the display scale option (on Windows 10 and 11) that might be helpful.
 
Back
Top