Skip to main content

cPanel/WHM API v3

Comments

5 comments

  • AndrewH.
    [url=http://docs.cpanel.net/twiki/bin/view/ApiDocs/UapiModuleHome]UAPI Module Listing UAPI is Api version 3. You can use the API Shell (in 11.40) to easily see nearly all the calls as it will literally parse the system for all API2, UAPI and WHM API1 calls. It will also parse 3rd party plugins for valid API calls.
    0
  • ruyrocha
    Thanks, @cPAndrewHodge! Is there any way to call UAPI functions as root? Looks like
    0
  • AndrewH.
    You can call them the same way you call API2 calls, just specify version=3 (this is how I've been using it internally anyway).
    0
  • ruyrocha
    Hey @cPAndrewHodge, I'm still trying to call UAPI as root without success, e.g: ? ~ curl -k -H $auth1 'https://dev2:2087/json-api/execute?user=sup&api.version=3&api.module=Ftp&api.function=get_port' ; echo {"metadata":{"command":"execute","version":"3","reason":"Unknown app requested for this version (3) of the api.","result":0}} ? ~ curl -k -H $auth1 'https://dev2:2087/json-api/cpanel?user=sup&api.version=3&api.module=Ftp&api.function=get_port' ; echo {"cpanelresult":{"apiversion":"2","error":"api call failed. Module name is required.","data":{"reason":"api call failed. Module name is required.","result":"0"},"type":"text"}} ? ~ curl -k -H $auth1 'https://dev2:2087/json-api/cpanel?user=sup&cpanel_jsonapi_version=3&cpanel_jsonapi_module=Ftp&cpanel_jsonapi_func=get_port' ; echo {"cpanelresult":{"data":{"result":0,"reason":"Could not find function 'get_port' in module 'Ftp'"},"error":"Could not find function 'get_port' in module 'Ftp'","module":"Ftp","apiversion":2,"func":"get_port"}}
    I've tried also to run it from command line, e.g: /usr/local/cpanel/uapi --json-connect
    Do you have any thoughts here?
    0
  • AndrewH.
    Looks like I gave you bad advice before, try this: (UAPI) https://mydevserver:2083/sessionkey/execute/Ftp/get_port
    (API2) https://mydevserver:2083/sessionkey/json-api/cpanel?cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=Ftp&cpanel_jsonapi_func=listftp
    Here's an example passing in arguments /execute/Resellers/list_accounts?user=taco&anotherKey=burrito
    And here's one with filtering /execute/Resellers/list_accounts?api.filter_column_0=user&api.filter_type_0=contains&api.filter_term_0=taco
    I highly recommend getting the latest 11.40 and playing with the API shell, it will make development a lot easier. To clarify, when I had specified swapping the version number it was mostly because my familiarity is using the CPANEL.api JavaScript object which we use to develop our pages with.
    0

Please sign in to leave a comment.