← Back to Site Speed Metrix

For developers

Site Speed Metrix API

Run our speed test from your own software. The API runs exactly the same test as the website tool: a real Chrome browser loads your page from Istanbul, and you get the grade, metrics, and fixes back as JSON. Use it to check speed before a release, build client reports, or feed your own dashboards.

Your API key

You get a key with a free account. Each account has one key; when you create a new one, the old key stops working right away.

Your first test in three steps

  1. 1. Start a test

    Send the URL and the device. The response gives you the test ID and the URL to poll for its status.

    curl -X POST https://www.turksem.com/api/v1/speed/tests \
      -H "Authorization: Bearer tsm_YOUR_KEY" \
      -H "Content-Type: application/json" \
      -d '{"url": "https://example.com", "device": "mobile"}'
    {
      "id": "3f6c1e2a-8b4d-4c7e-9a10-5d2b7e4f9c31",
      "status": "queued",
      "device": "mobile",
      "poll_url": "https://www.turksem.com/api/v1/speed/tests/3f6c1e2a-8b4d-4c7e-9a10-5d2b7e4f9c31"
    }
  2. 2. Poll for status

    A test takes 30 to 90 seconds. Check back every few seconds: while it's queued you'll see your place in line, and while it runs you'll see which step it's on.

    curl https://www.turksem.com/api/v1/speed/tests/3f6c1e2a-8b4d-4c7e-9a10-5d2b7e4f9c31 \
      -H "Authorization: Bearer tsm_YOUR_KEY"
    {
      "id": "3f6c1e2a-8b4d-4c7e-9a10-5d2b7e4f9c31",
      "status": "completed",
      "report_id": "h7qz2lmxa4",
      "report": {
        "id": "h7qz2lmxa4",
        "url": "https://example.com/",
        "device": "mobile",
        "report_url": "https://www.turksem.com/en/tools/site-speed-metrix/report/h7qz2lmxa4",
        "grade": "B",
        "score": 84,
        "metrics": { "lcp_ms": 2140, "tbt_ms": 180, "cls": 0.02, "...": "..." },
        "audits": [
          { "id": "modernImages", "impact": "med", "savings_bytes": 412000, "...": "..." }
        ]
      }
    }
  3. 3. Read the report

    When the test finishes, the full report comes back in the same response. Every report also has a permanent URL in report_url that you can send to a client or your team.

Endpoints

MethodPathWhat it does
POST/api/v1/speed/testsStarts a new test. Body: url (required), device (mobile or desktop), language (en, tr, or de). For protected pages, you can also send http_auth (username, password), cookies ("name=value; name2=value2"), and headers (name-value pairs).
GET/api/v1/speed/tests/{id}Returns the test status, plus the full report once it's done. Test records are kept for 30 minutes.
GET/api/v1/speed/reports/{id}Returns a stored report. Use it for tests older than 30 minutes.

What's in a report

We only ever add fields to this contract. If we ever need to remove a field or change what it means, we'll do it in a new version (v2), and v1 will keep working.

grade, score
A letter grade from A to F and a score out of 100, calculated exactly as on the website.
metrics
LCP, FCP, TBT, CLS, server response (TTFB), fully loaded time, Speed Index, page size, and request count. Times are in milliseconds.
audits
Issues we found, each with an ID, an impact level (high, med, or low), estimated byte and time savings, and the files involved.
conditions
How the test ran: location, viewport, network latency, bandwidth, CPU slowdown, and number of runs.
without_third_parties
Results of the without-third-parties experiment, if it was run on the website. Otherwise null.
report_url
The report's permanent public URL.

Limits

  • 20 tests a day, shared with the website tool and counted over a rolling 24 hours.
  • Tests run one at a time. At busy moments you may get a 503; try again in a few minutes.
  • Local network addresses can't be tested. To test a password-protected or logged-in page, send http_auth, cookies, or headers. We send them only to the site you're testing and never store them. Only the key's owner can read the report for that test.

Error codes

400
Bad request: the body isn't JSON, url is missing, or device is invalid.
401
Missing or invalid key. Check your Authorization: Bearer header.
404
No test or report with that ID.
422
We couldn't load the URL. Make sure the page is public and reachable.
429
You've used all of today's tests.
503
The test queue is full.