Array
(
    [0] => Warning
    [1] => Undefined array key "language"
    [2] => /home/whmcsdev/public_repo/wbteampro.major-release/installation/modules/addons/wbteampro/initialize.php
    [3] => 282
)
Array
(
    [0] => Warning
    [1] => Undefined property: stdClass::$state
    [2] => /home/whmcsdev/public_repo/wbavatax.master/installation/modules/addons/wbavatax/hooks.php
    [3] => 942
)
Array
(
    [0] => Deprecated
    [1] => htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated
    [2] => /home/whmcsdev/public_repo/wbavatax.master/installation/modules/addons/wbavatax/hooks.php
    [3] => 279
)
9.3 - Remote API Methods - Knowledgebase - WHMCS Dev
Dev License: This installation of WHMCS is running under a Development License and is not authorized to be used for production use. Please report any cases of abuse to abuse@whmcs.com

9.3 - Remote API Methods Print

  • 2

Remote API Methods allow you to develop stand-alone applications that can communicate with the wbTeamPro database.  wbTeamPro uses a RESTful Service Model to provide remote access to the data and data operations within the system.  Method requests made to the Remote API utilize the HTTP protocol, with all payload data being submitted and returned in the JSON format. 

Using the API Developers Sandbox

Included with your installation package is an API Developers Sandbox script that allows you to view and test the methods provided by the Remote API.  The API Developers Sandbox source code also serves as a PHP example of how to perform a request and parse the results.

To use our API Developers Sandbox you will need to upload the API Developers Sandbox folder included with your installation.  Once uploaded you will access the sandbox.php file and be prompted to enter the API URL, API User, and API Pass for the sandbox to use when connecting to your server.  The API URL will be a url pointing to the wbTeamPro api.php file (ie: {yourwebsite_url}/modules/addons/wbteampro/api.php).  The API User must be an administrator that has an Administrative Role that was give access to the wbTeamPro system.

Anatomy of an API Request

Remote API requests are made by querying the api.php file provided with your installation.  API Requests can be constructed using a "Clean URL" format, where each request URL will define the resource request being performed.  Optionally the resource "action" can be passed as a parameter with the request.

  • Clean URL Example
    {yourwebsite_url}/modules/addons/wbteampro/api.php/v1/projects/100/json?params={...}

    - or - using URI Rewrite Rules (htaccess rules included with installation)

    {yourwebsite_url}/modules/addons/wbteampro/api/v1/projects/100/json?params={...}
     
  • Direct URL Example
    {yourwebsite_url}/modules/addons/wbteampro/api.php?action=v1.projects.100.json&params={...}
     

The response provided by the Remote API is encoded in either a JSON or XML format, defined as the last key the resource "action" request chain.

  • JSON Response Format
    {yourwebsite_url}/modules/addons/wbteampro/api.php/v1/projects/100/json
     
  • XML Response Format
    {yourwebsite_url}/modules/addons/wbteampro/api.php/v1/projects/100/xml
     

When performing a Remote API request the following information must be provided:

  • API USERNAME (username=adminuser)
    This is a valid Administrator username that is within a WHMCS Administrative Role that has been granted access to the wbTeamPro system.

  • API PASSWORD (password=MD5HASH)
    This is the password for the valid Administrator, encoded into an MD5 HASH.
    * NOTE * The wbTeamPro API will ban the IP address of any connection that fails to login after 3 attempts.

  • API VERSION
    The API Version is specified as the FIRST key in the RESOURCE ACTION chain (ie: v1.project.100.json).
     
  • API RESPONSE FORMAT
    The API Response Format (json or xml) is specified as the LAST key in the RESOURCE ACTION chain (ie: v1.project.100.json).
     
  • HTTP METHOD (method=get)
    The http method defines the operation to be performed on the requested resource.  The http method value can be passed as the parameter "method", or by using the correct http mehod for the request.  The following http methods are allowed:

      GET - Retrieve a record (or list of records)
      PUT - Update a record
      POST - Create a record
      DELETE - Delete a record
     
  • RESOURCE ACTION (action=v1.projects.100.json)
    The resource action represents the method request chain for the query, specifying the Version, Method(s), and Response Format.  For example, the resource action "v1.projects.100.json" would instruct API V1 to perform an action on Project ID #100 and return the results in the JSON format.
     
  • RESOURCE PARAMETERS (params={"project_id":"100"})
    The request parameters are additional values, unique for each method, that control or filter the resource request being performed.  The params value can be provided as an ARRAY or JSON string.
     

Combining Resources

Resource requests can be chained together to create a more comprehensive response, minimizing the number of requests needed for simple operations.  For example, to load a project and the actions for the project, you can create a single request that will return the response from both resourses.

  • Example A - Perform Dual Requests
    {yourwebsite_url}/modules/addons/wbteampro/api.php/v1/projects/100/json
    {yourwebsite_url}/modules/addons/wbteampro/api.php/v1/actions/json?params={"project_id":"100"}
     
  • Example B - Perform a Combined Request
    {yourwebsite_url}/modules/addons/wbteampro/api.php/v1/projects/100/actions/json
     

Anatomy of the Response

The response data, whether in JSON or XML, will decode into an object containing a request and response dataset.  In the following example we have requested all Tickets for Project #100.

stdClass Object (
  [request] => stdClass Object
    (
      [action] => projects/219/whmcstickets
      [method] => GET
      [format] => json
      [code] => 200
      [message] => Success
    )
  [response] => stdClass Object
    (
      [data] => stdClass Object
        (
          [total] => 1
          [page] => 1
          [pages] => 0
          [limit] => 50
          [offset] => 0
          [filters] => stdClass Object
            (
              [project_id] => 219
            )
        )
      [project] => stdClass Object
        (
          [project_id] => 219
          ... project fields ...
        )
      [whmcstickets] => Array
        (
          [0] => stdClass Object
            (
              [id] => 2038
              ... ticket fields ...
              [ticketxref] => stdClass Object
                (
                  [xref_id] => 91
                  ... ticketxref fields ...
                )
            )
        )
    )
)

 

Remote API Resource Action Reference

Please use the API Developers Sandbox to learn more about the request parameters required and response data provided by the following methods.

api

  • findResources - Return the API Resource List
    api.resources

config

  • getConfig - Return a Config Option
    config

projects

  • findProjects - Return a Project List
    projects
  • createProject - Create a Project
    projects
  • getProject - Return a Project
    projects.{project_id}
  • getProjectActions - Return a Project Action List
    projects.{project_id}.actions
  • getProjectTopics - Return a Project Topic List
    projects.{project_id}.topics
  • getProjectFiles - Return a Project File List
    projects.{project_id}.files
  • getProjectTickets - Return a Project Ticket List
    projects.{project_id}.whmcstickets
  • getProjectTimelogs - Return a Project Timelog List
    projects.{project_id}.timelogs
  • updateProject - Update a Project
    projects.{project_id}
  • deleteProject - Delete a Project
    projects.{project_id}

actions

  • findActions - Return a Action List
    actions
  • createAction - Create a Action
    actions
  • getAction - Return a Action
    actions.{action_id}
  • getActionTopics - Return a Action Topic List
    actions.{action_id}.topics
  • getActionFiles - Return a Action File List
    actions.{action_id}.files
  • getActionTickets - Return a Action Ticket List
    actions.{action_id}.whmcstickets
  • getActionTimelogs - Return a Action Timelog List
    actions.{action_id}.timelogs
  • updateAction - Update a Action
    actions.{action_id}
  • deleteAction - Delete a Action
    actions.{action_id}

topics

  • findTopics - Return a Topic List
    topics
  • findTopicThreads - Return a Topic Thread List
    topics.bythread
  • createTopic - Create a Topic
    topics
  • getTopic - Return a Topic
    topics.{topic_id}
  • updateTopic - Update a Topic
    topics.{topic_id}
  • deleteTopic - Delete a Topic
    topics.{topic_id}

files

  • findFiles - Return a File List
    files
  • findFileThreads - Return a File Thread List
    files.bythread
  • createFile - Create a File
    files
  • getFile - Return a File
    files.{file_id}
  • downloadFile - Download a File
    files.{file_id}.download
  • updateFile - Update a File
    files.{file_id}
  • deleteFile - Delete a File
    files.{file_id}

whmcstickets

  • findWHMCSTickets - Return a WHMCS Ticket List
    whmcstickets
  • getWHMCSTicket - Return a WHMCS Ticket
    whmcstickets.{ticket_id}

ticketxrefs

  • findTicketXrefs - Return a TicketXref List
    ticketxrefs
  • createTicketXref - Create a TicketXref
    ticketxrefs
  • getTicketXref - Return a TicketXref
    ticketxrefs.{xref_id}
  • updateTicketXref - Update a TicketXref
    ticketxrefs.{xref_id}
  • deleteTicketXref - Delete a TicketXref
    ticketxrefs.{xref_id}

timelogs

  • findTimelogs - Return a Timelog List
    timelogs
  • createTimelog - Create a Timelog
    timelogs
  • getTimelog - Return a Timelog
    timelogs.{timelog_id}
  • updateTimelog - Update a Timelog
    timelogs.{timelog_id}
  • deleteTimelog - Delete a Timelog
    timelogs.{timelog_id}

 


Was this answer helpful?

« Back

Powered by WHMCompleteSolution