Skip to main content
AI agents are now live in Website Scanner! Enter your URL and fix website issues 3x faster with AI. Explore now!
No Result Found
Get your setup working faster. Join our Discord for optimisation tips from elite testers. Join our DiscordJoin our Discord

Network logs

Use the REST API to retrieve the network requests Percy made while capturing and rendering a comparison. This is the same data that the Debug panel shows above each snapshot on the Percy dashboard. Use it to find assets that failed to load, such as requests that returned 4xx or 5xx errors, were blocked, or timed out.

Get network logs

GET https://percy.io/api/v1/network-logs

Retrieves the network logs for the given comparison_id. Get comparison IDs from the comparisons included in the List snapshots API response. The comparison must be finished. The API returns 403 if the comparison is still processing.

Note: Authentication
This endpoint accepts only your BrowserStack username and access key, passed through HTTP Basic auth. Project tokens aren’t supported. Find your username and access key on the BrowserStack profile page.

Request parameters

cURL request

curl --location 'https://percy.io/api/v1/network-logs?comparison_id=<comparison_id>' \
--header "Authorization: Basic $(echo -n '<username>:<accesskey>' | base64)"

cURL request to list only the failed requests in a comparison

curl --location 'https://percy.io/api/v1/network-logs?comparison_id=<comparison_id>' \
--header "Authorization: Basic $(echo -n '<username>:<accesskey>' | base64)" \
| jq '."network-logs" | to_entries | map(select(.value."status-error"))'
  • comparison_id* String

    ID of a finished comparison. Get comparison IDs from the comparisons included in the List snapshots response.

Response attributes 200 OK JSON

The response is plain JSON and doesn’t follow the JSON:API format. The API returns 200 even when the logs are no longer available. Check the meta object to confirm that the logs are complete. In the response, head refers to the current build and base refers to the baseline build. Fields with no data contain the string NA, not null.

Response

{
  "network-logs": {
    "https://example.com:443/assets/app.css": {
      "base-status": 200,
      "head-status": 404,
      "status-summary": "Current: Percy infra error\nBaseline: call via cache",
      "status-error": true,
      "domain": "example.com:443",
      "file": "app.css",
      "mimetype": "text/css",
      "details": {
        "cli-network-call": {
          "head": 404,
          "base": "ok"
        },
        "asset-captured": {
          "head": "error",
          "base": "ok",
          "head-hostname": "public",
          "base-hostname": "allowed"
        },
        "possible-fixes": "NA"
      }
    }
  },
  "meta": {
    "is-head-expired": false,
    "is-base-expired": false,
    "is-base-present": true
  }
}
  • network-logs Object

    Network requests for the comparison, keyed by request URL. Each value describes one request. URLs can include an explicit port, such as :443. Percy-internal URLs aren’t included.

    â–¶ SHOW VALUES
    • head-status Integer | String

      The HTTP status that Percy’s renderer received for the request in the current build. NA if the request wasn’t made in that render.

    • base-status Integer | String

      The HTTP status that Percy’s renderer received for the request in the baseline build. NA if the request wasn’t made in that render.

    • status-error Boolean

      true if the request failed in the current or the baseline render. Filter on this field to find failed requests.

    • status-summary String

      Result of the request, with one line for the current build and one for the baseline, such as Current: call via cache. Possible values are call by network request, call via cache, Percy infra error, Request skipped in cli, Error in cli network request, and asset not present.

    • domain String

      The host of the request URL, including the port when the URL has one.

    • file String

      The last path segment of the request URL. Returns / for the page itself.

    • mimetype String

      Content type of the response, without parameters. NA if not available.

    • details Object

      Details of how the Percy CLI discovered the asset and how Percy served it at render time.

      â–¶ SHOW VALUES
      • cli-network-call.head Integer | String

        The result of the request when the Percy CLI discovered assets for the current build. An HTTP status, ok, skipped, error, or NA.

      • cli-network-call.base Integer | String

        The result of the request when the Percy CLI discovered assets for the baseline build. An HTTP status, ok, skipped, error, or NA.

      • asset-captured.head String

        ok if Percy served the asset from the captured resources in the current build, error if the request returned a non-2xx status at render time, and NA if the asset wasn’t captured.

      • asset-captured.base String

        ok if Percy served the asset from the captured resources in the baseline build, error if the request returned a non-2xx status at render time, and NA if the asset wasn’t captured.

      • asset-captured.head-hostname String

        Describes how Percy reached the asset host in the current build. allowed if Percy served it from captured resources, public if Percy fetched it from the internet at render time, and disallowed if discovery.disallowedHostnames blocks the host.

      • asset-captured.base-hostname String

        Describes how Percy reached the asset host in the baseline build. allowed if Percy served it from captured resources, public if Percy fetched it from the internet at render time, and disallowed if discovery.disallowedHostnames blocks the host.

      • possible-fixes String

        Reserved for future use. The value is currently always NA.

  • meta Object

    Availability of the logs for the current build and the baseline.

    â–¶ SHOW VALUES
    • is-head-expired Boolean

      true if the logs for the current build aren’t available. This happens when the 30-day retention period expires, for builds created with the legacy percy-agent, or when Percy can’t read the logs. network-logs is then empty or partial.

    • is-base-expired Boolean

      true if the logs for the baseline build aren’t available, for the same reasons as is-head-expired.

    • is-base-present Boolean

      false if the comparison has no baseline, such as for a new snapshot.

Limitations

  • Percy keeps network logs for 30 days. After that, meta.is-head-expired is true, and network-logs is empty.
  • Builds created with the legacy percy-agent don’t have network logs.
  • Each call reads the logs from storage, so a response typically takes between 0.5 and 4 seconds. To scan a whole build, call this API once per comparison with no more than 5 requests in parallel.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Download Copy Check Circle