On Page SEO API Documentation

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

Request

Method: GET

Query Parameters:

  • url (required): The URL to be analyzed for SEO.

Response

Success Response (200 OK):

FieldDescription
successIndicates if the analysis was successful or not
messageA message describing the analysis status
dataContains the SEO analysis data
scoreThe SEO score of the webpage
metricsObject containing pass, fail, and total metrics
passNumber of passed SEO metrics
failNumber of failed SEO metrics
totalTotal number of SEO metrics
urlThe URL that was analyzed
errorsObject containing the identified errors
successesObject 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"
  }
}

Error Handling

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:


FieldDescription
errorThe error message indicating the specific issue encountered

Usage

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.