OnPage API checks websites for on-page parameters, defines and displays all found flaws and opportunities for optimization, so that you can easily fix them.
GET https://vitalsx.com/api/v1/seo
Method: GET
Query Parameters:
url
(required): The URL to be analyzed for SEO.Success Response (200 OK):
Field | Description |
---|---|
success | Indicates if the analysis was successful or not |
message | A message describing the analysis status |
data | Contains the SEO analysis data |
score | The SEO score of the webpage |
metrics | Object containing pass, fail, and total metrics |
pass | Number of passed SEO metrics |
fail | Number of failed SEO metrics |
total | Total number of SEO metrics |
url | The URL that was analyzed |
errors | Object containing the identified errors |
successes | Object containing the identified successes |
Example response in JSON
json{
"success": true,
"message": "SEO analysis completed successfully",
"data": {
"score": 72,
"metrics": {
"pass": 10,
"fail": 4,
"total": 14
},
"url": "https://example.com"
},
"errors": {
"pageTitle": "Page title has an invalid length",
"pageDescription": "Page description not found",
"responsiveDesign": "Responsive meta tag not found or invalid"
},
"successes": {
"favicon": "Favicon found",
"headings": "H1 tag found",
"subHeadings": "H2 tag found"
}
}
When interacting with the API, there are instances where errors may occur. These errors typically manifest in scenarios such as when an invalid domain is provided or when the server encounters an unexpected issue. In such cases, the API responds with a JSON object that contains an error field as part of its response.
Here is a table that outlines the error field in the response:
Field | Description |
---|---|
error | The error message indicating the specific issue encountered |
To analyze the SEO of a webpage, you can use the fetch function in JavaScript to make a GET request to the /api/v1/seo
endpoint with the url
query parameter set to the URL of the webpage you want to analyze. Here's an example:
javascriptconst url = 'https://vitalsx.com/api/v1/seo?url=https://example.com';
fetch(url)
.then(response => response.json())
.then(data => {
// Handle the analysis results here
console.log(data);
})
.catch(error => {
// Handle any errors that occur during the request
console.error(error);
});
Note: Make sure to properly encode the URL before sending the request.
In the example above, the fetch function is used to make a GET request to the API endpoint. The response is then converted to JSON format, and you can handle the analysis results or errors in the respective callback functions.
Please note that the above example is a basic demonstration. You may need to modify the code and add additional error handling or processing based on your specific requirements.