API – Getting Started Tutorial
WP Bug Detector API Tutorial
Welcome to the WP Bug Detector API tutorial! WP Bug Detector is a renowned WordPress plugin that offers visual regression. Now, with the introduction of our API, you can easily integrate WP Bug Detector into your workflow. Let’s get started!
1. Prerequisites:
- Ensure you have a WP Bug Detector account.
- Familiarity with API requests (GET, POST, etc.).
- Postman or any other API testing tool.
2. Accessing the API Documentation:
Before diving into the API, it’s essential to understand its capabilities and endpoints. The detailed API documentation can be found at:
WP Bug Detector API Docs
3. Obtaining a License Key:
To use the API, you’ll need a license key. Follow these steps to get one:
- Visit the License Key Page.
- Log in to your account.
- Navigate to the License Keys section and get your purchased license key.
4. Setting Up in Postman:
- Download the provided Postman Collection here.
- Import the collection into Postman.
- Set up your license key and domain in the Postman environment or directly in the request headers.
5. Activating Your Domain:
- Use the
/activate
endpoint to activate your domain under the license key.- If your domain is already activated, you can also use the /login request.
- Upon successful activation, you’ll receive an
accessToken
. Ensure to store this token securely as you’ll need it for subsequent requests.
6. Starting a Reference Request:
- Use the
/reference
endpoint to initiate a POST request. - Configure the request body according to your needs. For instance:
- Specify the URLs you want to test
- Define the viewports
- Set a delay if required (e.g., 10000 milliseconds for a 10-second delay)
7. Getting References and Comparisons (and checking their status):
- Use the
/sync
endpoint to get the status of all references and comparisons. - From the response, save the
referenceId
of the current reference request for future use.
8. Initiating a Comparison Request:
- Use the
/comparison
endpoint for a POST request. - Provide the previously saved
referenceId
in the request body to start the comparison.
9. Monitoring the Comparison:
- Again, use the
/sync
endpoint to monitor the status of all references and comparisons.
Conclusion:
Congratulations! You’ve successfully set up and used the WP Bug Detector API. By following this tutorial, you can seamlessly integrate visual regression testing into your projects and ensure your WordPress sites are always in top shape. Happy testing!