JSONP

You can specify the name of a JavaScript callback function on GET requests to the high performance API endpoint.

To avoid cross-domain restrictions when invoking API requests from web pages, on GET requests from embedded JavaScript <script>s you can specify the name of a JavaScript callback function by using the callback query string parameter. This is supported only on GET requests.

Note: For performance, JSONP is available only from the high performance cached API. For more information, see High Performance API Endpoint.

In the following example, a standard GET request returns all labels within the account:

[GET]/v2/labels

Backlot returns a response similar to the following:

{  
   "items":[  
      {  
         "full_name":"/Hobbies/Hockey",
         "id":"85042f300fc143c093e8f4ee01892af8",
         "name":"Hockey",
         "parent_id":"d5751b77a0c24972888bf906734d8c34"
      },
      {  
         "full_name":"/Hobbies",
         "id":"d5751b77a0c24972888bf906734d8c34",
         "name":"Hobbies",
         "parent_id":null
      },
      {  
         "full_name":"/Sports/Motorcycle Racing",
         "id":"bace921fdea44cc18a5a273155514522",
         "name":"Motorcycle Racing",
         "parent_id":"814efb109416490a98ee3f4fcd6784cf"
      },
      {  
         "full_name":"/Sports",
         "id":"814efb109416490a98ee3f4fcd6784cf",
         "name":"Sports",
         "parent_id":null
      }
   ]
}

In the following example, when the GET request is triggered from a <script>, the results are returned with the get_my_labels function.

[GET]/v2/labels?callback=get_my_labels

Backlot returns a response similar to the following:

 get_my_labels({"items":
[{"name":"Hobbies","full_name":"/Hobbies","id":"d5751b77a0c24972888bf906734d8c34","parent_id":null},
{"name":"Hockey","full_name":"/Hobbies/Hockey","id":"85042f300fc143c093e8f4ee01892af8","parent_id":"d5751b77a0c24972888bf906734d8c34"},
{"name":"Motorcycle Racing","full_name":"/Sports/Motorcycle Racing","id":"bace921fdea44cc18a5a273155514522","parent_id":"814efb109416490a98ee3f4fcd6784cf"},
{"name":"Sports","full_name":"/Sports","id":"814efb109416490a98ee3f4fcd6784cf","parent_id":null}]})
  

Was this article helpful?