Trigger a scan manually using the Visual scanner API.
Using the Visual scanner API, you can execute Visual scanner builds on-demand, allowing immediate checks and faster response times to visual discrepancies. This API provides the following benefits:
Automated Workflows: Businesses can ensure visual inspections are part of their regular development cycles by integrating the Visual scanner API into automated workflows, such as CI/CD pipelines. The API automatically triggers a scan whenever there is an update or change to the codebase. This ensures continuous integration and delivery without manual intervention.
Flexibility and Control: This API allows developers to trigger scans based on specific events or conditions rather than predefined schedules. For example, a visual scan can be triggered immediately after deployment or during off-peak hours to minimize performance impact.
Scalability: When managing multiple websites or larger projects, triggering scans via API can help manage scans across multiple environments and URLs efficiently. The scalability of the solution ensures that performance and visual consistency remain consistent even when the project grows.
Integration with Other Tools: You can integrate build triggers and APIs with other tools and systems, such as issue tracking systems, internal notification systems, etc. This makes it possible to automatically report any detected issues to the relevant team members and resolve them as soon as possible.
Make sure your $PERCY_TOKEN is a Write-only or Full-access token.
Request
To trigger a visual scan using the Visual scanner API, use the following command where YOUR_PERCY_TOKEN is your PERCY_TOKEN present in the Project settings.
importrequests# Replace 'your_token_here' with your actual Percy token
PERCY_TOKEN='your_token_here'url='https://percy.io/api/v1/visual-scanner-builds'headers={'Authorization':f'Token token={PERCY_TOKEN}'}response=requests.post(url,headers=headers)# Printing the response
print(response.text)
importjava.net.URI;importjava.net.http.HttpClient;importjava.net.http.HttpRequest;importjava.net.http.HttpResponse;importjava.net.http.HttpHeaders;importjava.util.HashMap;importjava.util.Map;publicclassMain{publicstaticvoidmain(String[]args){StringpercyToken="your_token_here";// Replace with your actual Percy tokenHttpClientclient=HttpClient.newHttpClient();HttpRequestrequest=HttpRequest.newBuilder().uri(URI.create("https://percy.io/api/v1/visual-scanner-builds")).header("Authorization","Token token="+percyToken).POST(HttpRequest.BodyPublishers.noBody()).build();try{HttpResponse<String>response=client.send(request,HttpResponse.BodyHandlers.ofString());System.out.println(response.statusCode());System.out.println(response.body());}catch(Exceptione){e.printStackTrace();}}}
There can only be one concurrent scan per project.
Response
Here is a sample response after the scan is triggered and the build succeeds:
Visual scanner API returns a success or failure response only after build finalization.
Did this page help you?
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
ON THIS PAGE
Is this page helping you?
Yes
No
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!
By clicking 'Accept All', you agree to the use of all types of cookies to enhance site navigation. For more information, please visit our Cookie Policy.