Send Requests

After you've set everything up, you can send requests to the Search Console URL Testing Tools API.

The Search Console URL Testing Tools API is a fairly simple API to call: simply call the API with information needed to run the tests that you want. At present the API runs only a single test, mobile friendliness, which takes a URL to query and a flag indicating whether you want a screenshot of how Googlebot sees your page.

Run the mobile-friendliness test

Here's an example of running the mobile-friendliness test:

Protocol

 curl -H 'Content-Type: application/json' --data '{url: "https://support.google.com/webmasters"}' 'https://searchconsole.googleapis.com/v1/urlTestingTools/mobileFriendlyTest:run?key=123456789'
{
  "testStatus": {
    "status": "COMPLETE"
  },
  "mobileFriendliness": "MOBILE_FRIENDLY",
  "resourceIssues": [
    {
      "blockedResource": {
        "url": "https://support.google.com/webmasters/apis/metrics?v=0&key=support-content&mendel_ids=10800027,10800108"
      }
    },
    {
      "blockedResource": {
        "url": "https://support.google.com/webmasters/apis/top?key=support-content&mendel_ids=10800027,10800108"
      }
    },
    {
      "blockedResource": {
        "url": "https://ssl.gstatic.com/support/realtime/operatorParams"
      }
    }
  ]
}

Python

This runs the Python sample app (here named pysample.py):

$ python ./pysample.py
{
  "testStatus": {
    "status": "COMPLETE"
  },
  "mobileFriendliness": "MOBILE_FRIENDLY",
  "resourceIssues": [
    {
      "blockedResource": {
        "url": "https://www.gstatic.com/og/_/ss/k=og.mob.-1sfqetbr6q10n.L.W.O/m=md/excm=mih,mab,meb/d=1/ed=1/rs=AA2YrTu_rV-pUnXX1h6sn7ycipxnAHN_vw"
      }
    },
    {
      "blockedResource": {
        "url": "https://www.gstatic.com/og/_/js/k=og.mob.en_US.kGUqZK9fvf4.O/rt=j/m=md/exm=mih,mab,meb/d=1/ed=1/rs=AA2YrTsG6_bfwtH4gwgVRnW1ojCYGNvxjw"
      }
    },
    {
      "blockedResource": {
        "url": "https://www.google.com/xjs/_/js/k=xjs.qs.en_US.N9w19N-T440.O/m=sx,c,sb_mob,bct,cdos,elog,hsm,jsa,mbsf,r,qsm,d,csi/am=gEBbMjAcANggsYR9ASFACQ/rt=j/d=1/t=zcms/rs=ACT90oGN_lqt6mBfiFCxmGq0nQeAixxgUw"
      }
    }
  ]
}