Skip to content

Latest commit

 

History

History
148 lines (114 loc) · 3.88 KB

check-single-domain.md

File metadata and controls

148 lines (114 loc) · 3.88 KB
tags libraryName title description hasTabs eleventyNavigation
apiMain
Greencheck API
v3 - Check a domain
Use this API to check if a domain is hosted on a green web host recognised by The Green Web Foundation.
true
key title order
v3-check-single-domain
Check a domain
1

Query for a single domain

The Greencheck API provides endpoints that allow developers to query The Green Web Foundation's dataset of green domains.

The endpoint allows you to check if a single website domain is served from a green web host.

Request method

Use the GET method for this request.

Endpoint

The request should be sent to https://api.thegreenwebfoundation.org/api/v3/greencheck/{hostname}.

The {hostname} parameter should be replaced with the website domain you want to query for.

Parameters

{hostname}

A valid hostname should be passed to the endpoint. This parameter must not include any protocol, port, or path information.

  • climateaction.tech Accepted
  • https://climateaction.tech Incorrect
  • climateaction.tech/events Incorrect

Sample request

  1. JavaScript
  2. cURL
{% set code %} fetch("https://api.thegreenwebfoundation.org/api/v3/greencheck/climateaction.tech", { method: "GET", }).then((response) => response.json()); {% endset %}

{% codeSnippet code, 'js' %}

{% set code %} curl -X 'GET' \ 'https://api.thegreenwebfoundation.org/api/v3/greencheck/climateaction.tech' \ -H 'accept: application/json' {% endset %}

{% codeSnippet code, 'curl' %}

Response

{
  "url": "climateaction.tech",
  "hosted_by": "Cloudflare",
  "hosted_by_website": "www.cloudflare.com",
  "partner": null,
  "green": true,
  "hosted_by_id": 779,
  "modified": "2022-10-20T02:41:43",
  "supporting_documents": [
    {
      "id": 18,
      "title": "Blog post - The Climate and Cloudflare",
      "link": "https://blog.cloudflare.com/the-climate-and-cloudflare/"
    },
    {
      "id": 21,
      "title": "Cloudflare 2020 Emissions Inventory",
      "link": "https://s3.nl-ams.scw.cloud/tgwf-web-app-live/uploads/Cloudflare_Emissions_Inventory_-_2020.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=SCWK7542V4RH19SJV0RG%2F20221020%2Fnl-ams%2Fs3%2Faws4_request&X-Amz-Date=20221020T025244Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=9bf0a61ed3c50f2438d58f72d841457189d24cfcec5a122449272348d5bf3014"
    }
  ]
}

Response object

The response is returned as a JSON object. The content of the returned object depends on if the URL that was queried for is green.

  1. Green URL
  2. Not green URL
{
  "url": string,
  "hosted_by": string,
  "hosted_by_website": string,
  "partner": string || null,
  "green": true,
  "hosted_by_id": number,
  "modified": ISO 8601 formatted date string,
  "supporting_documents": array[
   object{
      "id": number,
      "title": string
      "link": string
   },
  ]
}
{
    "green": false,
    "url": string,
    "data": false
}

Troubleshooting

{% include 'snippets/why-not-green.md' %}