G2 Data API: Extract Structured JSON in 2026
Tutorials

G2 Data API: Extract Structured JSON in 2026

Learn how to extract structured JSON data from G2 reviews using AlterLab's Extract API with schema-based validation and no HTML parsing.

4 min read
79 views

AlterLab handles this automaticallyscrape any URL with one API call. No infrastructure required.

Try it free

This guide covers extracting publicly accessible data. Always review a site's robots.txt and Terms of Service before scraping.

TL;DR

Use AlterLab's Extract API with a JSON schema to pull structured G2 review data. POST the target URL and schema to the Extract API endpoint and receive typed JSON—no HTML parsing required.

Why use G2 data?

G2 hosts public product reviews that are useful for:

  • Training sentiment analysis models on real‑world feedback
  • Building competitive intelligence dashboards that track rating trends
  • Enriching CRM records with verified purchase signals from reviewers

What data can you extract?

From a typical G2 review page you can request:

  • product_name – the name of the SaaS or tool being reviewed
  • rating – the star rating shown (e.g., "4.5")
  • review_count – total number of reviews for that product
  • category – the G2 taxonomy category (e.g., "Customer Relationship Management")
  • verified_purchase – flag indicating whether the reviewer confirmed purchase

These fields are publicly visible; you define them in a JSON schema and AlterLab returns them as typed values.

The extraction approach

Raw HTTP requests return HTML that changes frequently. Parsing with regex or CSS selectors breaks when G2 updates its layout. A data API that accepts a schema and returns validated JSON removes that fragility. AlterLab handles request handling, anti‑bot measures, and AI‑driven field extraction so you receive consistent output.

Quick start with AlterLab Extract API

First, install the client and refer to the Getting started guide for setup.

Python
import alterlab

client = alterlab.Client("YOUR_API_KEY")

schema = {
  "type": "object",
  "properties": {
    "product_name": {
      "type": "string",
      "description": "The product name field"
    },
    "rating": {
      "type": "string",
      "description": "The rating field"
    },
    "review_count": {
      "type": "string",
      "description": "The review count field"
    },
    "category": {
      "type": "string",
      "description": "The category field"
    },
    "verified_purchase": {
      "type": "string",
      "description": "The verified purchase field"
    }
  }
}

result = client.extract(
    url="https://g2.com/example-page",
    schema=schema,
)
print(result.data)

The call returns a JSON object matching the schema, for example:

JSON
{
  "product_name": "Salesforce CRM",
  "rating": "4.4",
  "review_count": "12580",
  "category": "Customer Relationship Management",
  "verified_purchase": "true"
}

You can achieve the same with cURL; see the Extract API docs for full reference.

Bash
curl -X POST https://api.alterlab.io/v1/extract \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://g2.com/example-page",
    "schema": {"properties": {"product_name": {"type": "string"}, "rating": {"type": "string"}, "review_count": {"type": "string"}}}
  }'

Batch and async usage

For large‑scale jobs, fire off multiple extract requests in parallel and handle each response as it arrives.

Python
import alterlab
import asyncio

client = alterlab.Client("YOUR_API_KEY")

urls = [
    "https://g2.com/products/salesforce-crm/reviews",
    "https://g2.com/products/hubspot-crm/reviews",
    "https://g2.com/products/zoho-crm/reviews"
]

schema = {
    "type": "object",
    "properties": {
        "product_name": {"type": "string"},
        "rating": {"type": "string"},
        "review_count": {"type": "string"}
    }
}

async def fetch(url):
    return client.extract(url=url, schema=schema)

async def main():
    tasks = [fetch(u) for u in urls]
    results = await asyncio.gather(*tasks)
    for resp in results:
        print(resp.data)

asyncio.run(main())

Define your schema

The schema parameter drives the extraction. AlterLab validates each field against the declared type and returns only matching data. If a field cannot be found, the API returns null for that property, keeping the output shape predictable. You can nest objects or add arrays for lists of reviewers, but for simple review summaries a flat object works best.

Handle pagination and scale

G2 splits reviews across pages. Retrieve the next page URL from the HTML (or from a JSON endpoint if available) and loop until no further pages exist. To stay within rate limits, space requests or use AlterLab’s built‑in concurrency controls. For cost estimates, visit the AlterLab pricing page—charges are per successful extraction with no minimums and credits that never expire.

Try it yourself

Extract structured reviews data from G2

Key takeaways

  • Use a JSON schema to ask AlterLab for exactly the fields you need from G2 pages.
  • The Extract API returns typed JSON, eliminating fragile HTML parsing.
  • Parallelize requests for high volume while respecting rate limits and costs.
  • Always verify that your extraction target is public and complies with the site’s terms.

AlterLab // Web Data, Simplified.

Share

Was this article helpful?

Frequently Asked Questions

G2 offers limited partner APIs for internal use; there is no public API for review data. AlterLab provides a compliant way to extract publicly available reviews as structured JSON.
You can extract fields like product_name, rating, review_count, category, and verified_purchase by defining a JSON schema; AlterLab returns validated, typed data.
AlterLab charges per successful extraction; see the pricing page for pay‑as‑you-go rates with no minimums and credits that never expire.