WAPI – communication in JSON

JSON – JavaScript Object Notation is a simple text format for the transmission of data structures. Its syntax is derived from JavaScript, but it is independent of the language and in practice, every programming language has available tools to use it.

To send commands in JSON format, use this address https://api.wedos.com/wapi/json  

When you communicate with WAPI by using JSON, the server will respond in the appropriate format, notification (whether on e-mail, or URL) will also be sent in the same format. For poll, notification depends on the format of a particular query (ie, when the order will be sent in XML, but poll-req already in JSON, a notification will be returned in JSON).

If it is not obvious in what format it should communicate (such as system notifications) system will be controlled by the option Preferred protocol, which you can set in the client center in the WAPI Settings section (https://client.wedos.com/client/wapi.html).

Structure of command in JSON is equivalent with XML. 

Request written in XML:

<request>
 <user>tester</user>
 <auth>463870369aef393f3b82274107c9ade4b5b2a414</auth>
 <command>contact-create</command>
 <data>
  <tld>cz</tld>
  <contact>
   <cname>JAN-NOVAK</cname>
   <fname>Honza</fname>
   <lname>Novák</lname>
   <email>novak@example.com</email>
   <addr_street>Zelená 15</addr_street>
   <addr_city>Minas Morgull</addr_city>
   <addr_zip>12345</addr_zip>
   <addr_country>vg</addr_country>
   <notify_email>jan.novak@example.com</notify_email>
  </contact>
 </data>
</request>

responds to this in JSON:

{
  "request":
  {
    "user":     "tester",
    "auth":     "463870369aef393f3b82274107c9ade4b5b2a414",
    "command":  "contact-create",
    "data":
    {
      "tld":      "cz",
      "contact":
      {
        "cname":        "JAN-NOVAK",
        "fname":        "Honza",
        "lname":        "Novák",
        "email":        "novak@example.com",
        "addr_street":  "Zelená 15",
        "addr_city":    "Minas Morgull",
        "addr_zip":     "12345",
        "addr_country": "vg",
        "notify_email": "jan.novak@example.com"
      }
    }
  }
} 

which responds to this field (PHP)

Array
(    
  [request] => Array
    (
      [user] => tester
      [auth] => 463870369aef393f3b82274107c9ade4b5b2a414
      [command] => contact-create
      [data] => Array
        (
          [tld] => cz
          [contact] => Array
            (
              [cname] => JAN-NOVAK
              [fname] => Honza
              [lname] => Novák
              [email] => novak@example.com
              [addr_street] => Zelená 15
              [addr_city] => Minas Morgull
              [addr_zip] => 12345
              [addr_country] => vg
              [notify_email] => jan.novak@example.com
            )
        )
    )
)

Děkujeme za zpětnou vazbu!