### Node.js Request Example Source: https://docs.ahrefs.com/en/api/reference/site-explorer/get-pages-by-backlinks Provides an example of making a GET request to the Site Explorer API using `fetch` in Node.js. Remember to insert your API key where indicated. ```javascript const response = await fetch("https://api.ahrefs.com/v3/site-explorer/pages-by-backlinks", { method: "GET", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Get Organic Competitors (Node.js) Source: https://docs.ahrefs.com/en/api/reference/site-explorer/get-organic-competitors This Node.js example demonstrates how to use the fetch API to get organic competitor data. Remember to substitute your API key for $AHREFS_API_KEY. ```javascript const response = await fetch("https://api.ahrefs.com/v3/site-explorer/organic-competitors", { method: "GET", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Go Request Example Source: https://docs.ahrefs.com/en/api/reference/web-analytics/get-sources Example of how to make a GET request to the Web Analytics Sources API using Go's http package. Replace `$AHREFS_API_KEY` with your actual API key. ```go req, _ := http.NewRequest("GET", "https://api.ahrefs.com/v3/web-analytics/sources", nil) req.Header.Set("Authorization", "Bearer $AHREFS_API_KEY") req.Header.Set("Accept", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() data, _ := io.ReadAll(resp.Body) fmt.Println(string(data)) ``` -------------------------------- ### Get All Backlinks Request in Go Source: https://docs.ahrefs.com/en/api/reference/site-explorer/get-all-backlinks Provides a Go example for requesting all backlinks. This code sets up an HTTP GET request, includes the required authorization header, and reads the response body. ```go req, _ := http.NewRequest("GET", "https://api.ahrefs.com/v3/site-explorer/all-backlinks", nil) req.Header.Set("Authorization", "Bearer $AHREFS_API_KEY") req.Header.Set("Accept", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() data, _ := io.ReadAll(resp.Body) fmt.Println(string(data)) ``` -------------------------------- ### Get Project Competitors (cURL) Source: https://docs.ahrefs.com/en/api/reference/management/get-project-competitors Example of how to fetch project competitors using cURL. Ensure you replace `$AHREFS_API_KEY` with your actual API key. ```bash curl "https://api.ahrefs.com/v3/management/project-competitors" \ -H "Authorization: Bearer $AHREFS_API_KEY" \ -H "Accept: application/json" ``` -------------------------------- ### Get Entry Pages (Go) Source: https://docs.ahrefs.com/en/api/reference/web-analytics/get-entry-pages Example of how to fetch entry pages data using Go. Replace `$AHREFS_API_KEY` with your actual API key. ```go req, _ := http.NewRequest("GET", "https://api.ahrefs.com/v3/web-analytics/entry-pages", nil) req.Header.Set("Authorization", "Bearer $AHREFS_API_KEY") req.Header.Set("Accept", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() data, _ := io.ReadAll(resp.Body) fmt.Println(string(data)) ``` -------------------------------- ### Get Cited Domains (Go) Source: https://docs.ahrefs.com/en/api/reference/brand-radar/get-cited-domains Implement a GET request to the Cited Domains API using Go's http package. This example covers setting headers, making the request, and reading the response body. ```go req, _ := http.NewRequest("GET", "https://api.ahrefs.com/v3/brand-radar/cited-domains", nil) req.Header.Set("Authorization", "Bearer $AHREFS_API_KEY") req.Header.Set("Accept", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() data, _ := io.ReadAll(resp.Body) fmt.Println(string(data)) ``` -------------------------------- ### Get Competitors Domains (Go) Source: https://docs.ahrefs.com/en/api/reference/rank-tracker/get-competitors-domains Example of how to fetch competitor domains using Go. Ensure you replace $AHREFS_API_KEY with your actual API key. ```go req, _ := http.NewRequest("GET", "https://api.ahrefs.com/v3/rank-tracker/competitors-domains", nil) req.Header.Set("Authorization", "Bearer $AHREFS_API_KEY") req.Header.Set("Accept", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() data, _ := io.ReadAll(resp.Body) fmt.Println(string(data)) ``` -------------------------------- ### Go Request Example Source: https://docs.ahrefs.com/en/api/reference/site-explorer/get-pages-by-backlinks Illustrates how to perform a GET request to the Site Explorer API using Go's `net/http` package. Replace the placeholder with your valid API key. ```go req, _ := http.NewRequest("GET", "https://api.ahrefs.com/v3/site-explorer/pages-by-backlinks", nil) req.Header.Set("Authorization", "Bearer $AHREFS_API_KEY") req.Header.Set("Accept", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() data, _ := io.ReadAll(resp.Body) fmt.Println(string(data)) ``` -------------------------------- ### Get Cited Pages - Node.js Example Source: https://docs.ahrefs.com/en/api/reference/brand-radar/get-cited-pages This Node.js example uses the `fetch` API to make a GET request to the Cited Pages endpoint. It demonstrates how to set the `Authorization` and `Accept` headers. Remember to substitute `$AHREFS_API_KEY` with your API key. ```javascript const response = await fetch("https://api.ahrefs.com/v3/brand-radar/cited-pages", { method: "GET", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Get Operating Systems Data (Node.js) Source: https://docs.ahrefs.com/en/api/reference/web-analytics/get-operating-systems This Node.js example demonstrates how to fetch operating system data using the `fetch` API. The `Authorization` header must include your API key. ```javascript const response = await fetch("https://api.ahrefs.com/v3/web-analytics/operating-systems", { method: "GET", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Get Pages History (Node.js) Source: https://docs.ahrefs.com/en/api/reference/gsc/get-pages-history Node.js example using fetch to get pages history. Remember to substitute $AHREFS_API_KEY with your API key. ```javascript const response = await fetch("https://api.ahrefs.com/v3/gsc/pages-history", { method: "GET", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Get Performance by Device - cURL Source: https://docs.ahrefs.com/en/api/reference/gsc/get-performance-by-device Example of how to make a GET request to the performance-by-device endpoint using cURL. Ensure you replace $AHREFS_API_KEY with your actual API key. ```bash curl "https://api.ahrefs.com/v3/gsc/performance-by-device" \ -H "Authorization: Bearer $AHREFS_API_KEY" \ -H "Accept: application/json" ``` -------------------------------- ### Create Project using Node.js Source: https://docs.ahrefs.com/en/api/reference/management/post-projects This Node.js example shows how to create a project using the fetch API. It includes setting the Authorization header and sending the project details in the request body. ```javascript const response = await fetch("https://api.ahrefs.com/v3/management/projects", { method: "POST", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json", "Content-Type": "application/json" }, body: JSON.stringify({ "owned_by": "string", "access": "private", "protocol": "both", "url": "string", "mode": "exact", "project_name": "string" }) }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Get Impressions History (Go) Source: https://docs.ahrefs.com/en/api/reference/brand-radar/get-impressions-history Example of how to make a GET request to the impressions history endpoint using Go. Replace `$AHREFS_API_KEY` with your actual API key. ```go req, _ := http.NewRequest("GET", "https://api.ahrefs.com/v3/brand-radar/impressions-history", nil) req.Header.Set("Authorization", "Bearer $AHREFS_API_KEY") req.Header.Set("Accept", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() data, _ := io.ReadAll(resp.Body) fmt.Println(string(data)) ``` -------------------------------- ### Add Project Competitors using Go Source: https://docs.ahrefs.com/en/api/reference/management/post-project-competitors This Go program illustrates how to make a POST request to add competitors, including setting the required headers and request body. ```go package main import ( "bytes" "fmt" "io" "net/http" ) func main() { body := []byte(`{ "competitors": [ { "url": "string", "mode": "exact" } ] }`) req, _ := http.NewRequest("POST", "https://api.ahrefs.com/v3/management/project-competitors", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer $AHREFS_API_KEY") req.Header.Set("Accept", "application/json") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() data, _ := io.ReadAll(resp.Body) fmt.Println(string(data)) } ``` -------------------------------- ### Get Project Competitors (Go) Source: https://docs.ahrefs.com/en/api/reference/management/get-project-competitors Example of how to fetch project competitors using Go's http package. Replace `$AHREFS_API_KEY` with your actual API key. ```go req, _ := http.NewRequest("GET", "https://api.ahrefs.com/v3/management/project-competitors", nil) req.Header.Set("Authorization", "Bearer $AHREFS_API_KEY") req.Header.Set("Accept", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() data, _ := io.ReadAll(resp.Body) fmt.Println(string(data)) ``` -------------------------------- ### Get Impressions History (Node.js) Source: https://docs.ahrefs.com/en/api/reference/brand-radar/get-impressions-history Example of how to make a GET request to the impressions history endpoint using Node.js. Replace `$AHREFS_API_KEY` with your actual API key. ```javascript const response = await fetch("https://api.ahrefs.com/v3/brand-radar/impressions-history", { method: "GET", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Get Cities Chart Data (cURL) Source: https://docs.ahrefs.com/en/api/reference/web-analytics/get-cities-chart Example of how to make a GET request to the cities-chart endpoint using cURL. Ensure you replace $AHREFS_API_KEY with your actual API key. ```curl curl "https://api.ahrefs.com/v3/web-analytics/cities-chart" \ -H "Authorization: Bearer $AHREFS_API_KEY" \ -H "Accept: application/json" ``` -------------------------------- ### Get Projects (Node.js) Source: https://docs.ahrefs.com/en/api/reference/management/get-projects This Node.js example demonstrates how to fetch project data using the fetch API. Remember to replace the placeholder for your API key. ```javascript const response = await fetch("https://api.ahrefs.com/v3/management/projects", { method: "GET", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Create Brand Radar Prompts (Go) Source: https://docs.ahrefs.com/en/api/reference/management/post-brand-radar-prompts This Go program illustrates how to create Brand Radar prompts. It constructs the request body, sets headers, and sends the POST request using http.DefaultClient. ```go package main import ( "bytes" "fmt" "io" "net/http" ) func main() { body := []byte(`{ "countries": ["ad"], "prompts": ["string"] }`) req, _ := http.NewRequest("POST", "https://api.ahrefs.com/v3/management/brand-radar-prompts", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer $AHREFS_API_KEY") req.Header.Set("Accept", "application/json") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() data, _ := io.ReadAll(resp.Body) fmt.Println(string(data)) } ``` -------------------------------- ### Get Operating Systems Chart Data (Go) Source: https://docs.ahrefs.com/en/api/reference/web-analytics/get-operating-systems-chart Example of how to fetch operating systems chart data using Go's http package. Replace $AHREFS_API_KEY with your actual API key. ```go req, _ := http.NewRequest("GET", "https://api.ahrefs.com/v3/web-analytics/operating-systems-chart", nil) req.Header.Set("Authorization", "Bearer $AHREFS_API_KEY") req.Header.Set("Accept", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() data, _ := io.ReadAll(resp.Body) fmt.Println(string(data)) ``` -------------------------------- ### Get Matching Terms Request in Node.js Source: https://docs.ahrefs.com/en/api/reference/keywords-explorer/get-matching-terms This Node.js example shows how to use the fetch API to get matching terms. It sets the Authorization and Accept headers for the request. ```javascript const response = await fetch("https://api.ahrefs.com/v3/keywords-explorer/matching-terms", { method: "GET", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Get Pages API Response Structure Source: https://docs.ahrefs.com/en/api/reference/gsc/get-pages This is an example of the JSON response structure you can expect from the Get Pages API. It includes a list of pages with various performance metrics. ```json { "pages": [ { "page": "string", "keywords_count": 0, "top_keyword": "string", "clicks": 0, "impressions": 0, "ctr": 0.0, "position": 0.0, "traffic_value": 0.0 } ] } ``` -------------------------------- ### Get Impressions History (cURL) Source: https://docs.ahrefs.com/en/api/reference/brand-radar/get-impressions-history Example of how to make a GET request to the impressions history endpoint using cURL. Ensure you replace `$AHREFS_API_KEY` with your actual API key. ```curl curl "https://api.ahrefs.com/v3/brand-radar/impressions-history" \ -H "Authorization: Bearer $AHREFS_API_KEY" \ -H "Accept: application/json" ``` -------------------------------- ### Get Browsers (Go) Source: https://docs.ahrefs.com/en/api/reference/web-analytics/get-browsers Example of how to fetch browser data using Go's http package. Replace `$AHREFS_API_KEY` with your actual API key. ```go req, _ := http.NewRequest("GET", "https://api.ahrefs.com/v3/web-analytics/browsers", nil) req.Header.Set("Authorization", "Bearer $AHREFS_API_KEY") req.Header.Set("Accept", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() data, _ := io.ReadAll(resp.Body) fmt.Println(string(data)) ``` -------------------------------- ### cURL Request Example Source: https://docs.ahrefs.com/en/api/reference/web-analytics/get-sources Example of how to make a GET request to the Web Analytics Sources API using cURL. Ensure you replace `$AHREFS_API_KEY` with your actual API key. ```bash curl "https://api.ahrefs.com/v3/web-analytics/sources" \ -H "Authorization: Bearer $AHREFS_API_KEY" \ -H "Accept: application/json" ``` -------------------------------- ### Get SERP Overview with Go Source: https://docs.ahrefs.com/en/api/reference/serp-overview/get-serp-overview This Go code snippet illustrates how to make a GET request to the SERP Overview API. Ensure your API key is correctly set in the `Authorization` header. ```go req, _ := http.NewRequest("GET", "https://api.ahrefs.com/v3/serp-overview/serp-overview", nil) req.Header.Set("Authorization", "Bearer $AHREFS_API_KEY") req.Header.Set("Accept", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() data, _ := io.ReadAll(resp.Body) fmt.Println(string(data)) ``` -------------------------------- ### Add Project Competitors using Node.js Source: https://docs.ahrefs.com/en/api/reference/management/post-project-competitors This Node.js example shows how to use the fetch API to add competitors. It includes setting the Authorization, Accept, and Content-Type headers for the POST request. ```javascript const response = await fetch("https://api.ahrefs.com/v3/management/project-competitors", { method: "POST", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json", "Content-Type": "application/json" }, body: JSON.stringify({ "competitors": [ { "url": "string", "mode": "exact" } ] }) }); const data = await response.json(); console.log(data); ``` -------------------------------- ### cURL Request Example Source: https://docs.ahrefs.com/en/api/reference/web-analytics/get-chart Example of how to make a GET request to the web analytics chart endpoint using cURL. Ensure you replace $AHREFS_API_KEY with your actual API key. ```bash curl "https://api.ahrefs.com/v3/web-analytics/chart" \ -H "Authorization: Bearer $AHREFS_API_KEY" \ -H "Accept: application/json" ``` -------------------------------- ### Get Operating Systems Versions Chart (Node.js) Source: https://docs.ahrefs.com/en/api/reference/web-analytics/get-operating-systems-versions-chart This Node.js example demonstrates how to retrieve operating system versions chart data using the `fetch` API. It sets the required authorization and accept headers. ```javascript const response = await fetch("https://api.ahrefs.com/v3/web-analytics/operating-systems-versions-chart", { method: "GET", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Get Languages API Request (cURL) Source: https://docs.ahrefs.com/en/api/reference/web-analytics/get-languages Example of how to make a GET request to the Languages API endpoint using cURL. Ensure you replace $AHREFS_API_KEY with your actual API key. ```bash curl "https://api.ahrefs.com/v3/web-analytics/languages" \ -H "Authorization: Bearer $AHREFS_API_KEY" \ -H "Accept: application/json" ``` -------------------------------- ### Create Project using Go Source: https://docs.ahrefs.com/en/api/reference/management/post-projects This Go code snippet illustrates how to create a project using the http package. It constructs the request body and sets the required headers for the API call. ```go body := []byte(`{ "owned_by": "string", "access": "private", "protocol": "both", "url": "string", "mode": "exact", "project_name": "string" }`) req, _ := http.NewRequest("POST", "https://api.ahrefs.com/v3/management/projects", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer $AHREFS_API_KEY") req.Header.Set("Accept", "application/json") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() data, _ := io.ReadAll(resp.Body) fmt.Println(string(data)) ``` -------------------------------- ### Get Browser Versions Chart (Go) Source: https://docs.ahrefs.com/en/api/reference/web-analytics/get-browser-versions-chart Example of how to make a GET request to the Browser Versions Chart API using Go. Replace $AHREFS_API_KEY with your actual API key. ```go req, _ := http.NewRequest("GET", "https://api.ahrefs.com/v3/web-analytics/browser-versions-chart", nil) req.Header.Set("Authorization", "Bearer $AHREFS_API_KEY") req.Header.Set("Accept", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() data, _ := io.ReadAll(resp.Body) fmt.Println(string(data)) ``` -------------------------------- ### Get SERP Overview with Node.js Source: https://docs.ahrefs.com/en/api/reference/serp-overview/get-serp-overview This Node.js example shows how to retrieve SERP Overview data using the `fetch` API. The `Authorization` header must include your API key. ```javascript const response = await fetch("https://api.ahrefs.com/v3/serp-overview/serp-overview", { method: "GET", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Get Browser Versions Chart (Node.js) Source: https://docs.ahrefs.com/en/api/reference/web-analytics/get-browser-versions-chart Example of how to make a GET request to the Browser Versions Chart API using Node.js. Replace $AHREFS_API_KEY with your actual API key. ```javascript const response = await fetch("https://api.ahrefs.com/v3/web-analytics/browser-versions-chart", { method: "GET", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Get SERP Overview with Python Source: https://docs.ahrefs.com/en/api/reference/serp-overview/get-serp-overview This Python script demonstrates how to fetch SERP Overview data using the `requests` library. Remember to set your API key in the `Authorization` header. ```python import requests url = "https://api.ahrefs.com/v3/serp-overview/serp-overview" headers = { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### Get Cited Pages - Go Example Source: https://docs.ahrefs.com/en/api/reference/brand-radar/get-cited-pages This Go program illustrates how to fetch data from the Cited Pages API using the `net/http` package. It sets the required headers, including the API key for authorization. The response body is then printed as a string. ```go req, _ := http.NewRequest("GET", "https://api.ahrefs.com/v3/brand-radar/cited-pages", nil) req.Header.Set("Authorization", "Bearer $AHREFS_API_KEY") req.Header.Set("Accept", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() data, _ := io.ReadAll(resp.Body) fmt.Println(string(data)) ``` -------------------------------- ### Get Channel Metrics Request (cURL) Source: https://docs.ahrefs.com/en/api/reference/social-media/get-channel-metrics Example of how to make a GET request to the channel metrics endpoint using cURL. Ensure you replace '$AHREFS_API_KEY' with your actual API key. ```curl curl "https://api.ahrefs.com/v3/social-media/channel-metrics" \ -H "Authorization: Bearer $AHREFS_API_KEY" \ -H "Accept: application/json" ``` -------------------------------- ### Get Page Content with Node.js Source: https://docs.ahrefs.com/en/api/reference/site-audit/get-page-content This Node.js example uses the `fetch` API to get page content. Remember to substitute `$AHREFS_API_KEY` with your key and include the required query parameters. ```javascript const response = await fetch("https://api.ahrefs.com/v3/site-audit/page-content", { method: "GET", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Get Impressions Overview (Go) Source: https://docs.ahrefs.com/en/api/reference/brand-radar/get-impressions-overview Make a GET request to retrieve brand impressions data using Go's `net/http` package. Set the Authorization and Accept headers appropriately. ```go req, _ := http.NewRequest("GET", "https://api.ahrefs.com/v3/brand-radar/impressions-overview", nil) req.Header.Set("Authorization", "Bearer $AHREFS_API_KEY") req.Header.Set("Accept", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() data, _ := io.ReadAll(resp.Body) fmt.Println(string(data)) ``` -------------------------------- ### Get Pages API Request (Node.js) Source: https://docs.ahrefs.com/en/api/reference/gsc/get-pages This Node.js example shows how to call the Get Pages API using the fetch API. Remember to substitute $AHREFS_API_KEY with your API key. ```javascript const response = await fetch("https://api.ahrefs.com/v3/gsc/pages", { method: "GET", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Free SERP Overview Query Source: https://docs.ahrefs.com/en/api/docs/free-test-queries Use `wordcount` as the keyword for free SERP Overview requests. ```http https://api.ahrefs.com/v3/serp-overview/serp-overview?country=us&date=2023-05-16&keyword=wordcount&select=url,position,url_rating,backlinks,traffic&top_positions=3 ``` -------------------------------- ### Create Project using Python Source: https://docs.ahrefs.com/en/api/reference/management/post-projects This Python script demonstrates how to create a project using the requests library. It sends a POST request with the necessary headers and JSON payload. ```python import requests url = "https://api.ahrefs.com/v3/management/projects" headers = { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json", "Content-Type": "application/json" } response = requests.post(url, headers=headers, json={ "owned_by": "string", "access": "private", "protocol": "both", "url": "string", "mode": "exact", "project_name": "string" }) print(response.json()) ``` -------------------------------- ### Node.js Request Example Source: https://docs.ahrefs.com/en/api/reference/web-analytics/get-sources Example of how to make a GET request to the Web Analytics Sources API using Node.js fetch API. Replace `$AHREFS_API_KEY` with your actual API key. ```javascript const response = await fetch("https://api.ahrefs.com/v3/web-analytics/sources", { method: "GET", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Node.js Request Example Source: https://docs.ahrefs.com/en/api/reference/web-analytics/get-chart Example of how to make a GET request to the web analytics chart endpoint using Node.js fetch API. Replace $AHREFS_API_KEY with your actual API key. ```javascript const response = await fetch("https://api.ahrefs.com/v3/web-analytics/chart", { method: "GET", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Get Competitors Overview (Node.js) Source: https://docs.ahrefs.com/en/api/reference/rank-tracker/get-competitors-overview This Node.js example demonstrates how to call the Competitors Overview API using `fetch`. Remember to substitute your API key for `$AHREFS_API_KEY`. ```javascript const response = await fetch("https://api.ahrefs.com/v3/rank-tracker/competitors-overview", { method: "GET", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Get Languages API Request (Node.js) Source: https://docs.ahrefs.com/en/api/reference/web-analytics/get-languages Example of how to make a GET request to the Languages API endpoint using Node.js fetch API. Replace $AHREFS_API_KEY with your actual API key. ```javascript const response = await fetch("https://api.ahrefs.com/v3/web-analytics/languages", { method: "GET", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Successful SERP Overview Response Example Source: https://docs.ahrefs.com/en/api/reference/rank-tracker/get-serp-overview This is an example of a successful 200 OK response from the SERP Overview API, showing the structure of the returned data. ```json { "positions": [ { "ahrefs_rank": 0, "backlinks": 0, "domain_rating": 0.0, "keywords": 0, "nr_words": 0, "page_type": "string", "position": 0, "refdomains": 0, "title": "string", "top_keyword": "string", "top_keyword_volume": 0, "traffic": 0, "type": ["string"], "update_date": "string", "url": "string", "url_rating": 0.0, "value": 0 } ] } ``` -------------------------------- ### Get Exit Pages Chart (Node.js) Source: https://docs.ahrefs.com/en/api/reference/web-analytics/get-exit-pages-chart Node.js example using the fetch API to get exit pages chart data. Remember to substitute $AHREFS_API_KEY with your valid API key. ```javascript const response = await fetch("https://api.ahrefs.com/v3/web-analytics/exit-pages-chart", { method: "GET", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Get Keywords Explorer Overview (Node.js) Source: https://docs.ahrefs.com/en/api/reference/keywords-explorer/get-overview This Node.js example demonstrates how to fetch keyword overview data using the fetch API. It sets the Authorization and Accept headers for the request. ```javascript const response = await fetch("https://api.ahrefs.com/v3/keywords-explorer/overview", { method: "GET", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Successful SERP Overview Response Example Source: https://docs.ahrefs.com/en/api/reference/serp-overview/get-serp-overview This is an example of a successful 200 OK response from the SERP Overview API. It includes a `positions` array with details for each SERP result. ```json { "positions": [ { "ahrefs_rank": 0, "backlinks": 0, "domain_rating": 0.0, "keywords": 0, "page_type": "string", "position": 0, "refdomains": 0, "title": "string", "top_keyword": "string", "top_keyword_volume": 0, "traffic": 0, "type": ["paid_top"], "update_date": "string", "url": "string", "url_rating": 0.0, "value": 0 } ] } ``` -------------------------------- ### Get Browser Versions Chart (cURL) Source: https://docs.ahrefs.com/en/api/reference/web-analytics/get-browser-versions-chart Example of how to make a GET request to the Browser Versions Chart API using cURL. Ensure you replace $AHREFS_API_KEY with your actual API key. ```bash curl "https://api.ahrefs.com/v3/web-analytics/browser-versions-chart" \ -H "Authorization: Bearer $AHREFS_API_KEY" \ -H "Accept: application/json" ``` -------------------------------- ### Get Channel Metrics Request (Go) Source: https://docs.ahrefs.com/en/api/reference/social-media/get-channel-metrics Example of making a GET request for channel metrics using Go's http package. The API key is set in the Authorization header. ```go req, _ := http.NewRequest("GET", "https://api.ahrefs.com/v3/social-media/channel-metrics", nil) req.Header.Set("Authorization", "Bearer $AHREFS_API_KEY") req.Header.Set("Accept", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() data, _ := io.ReadAll(resp.Body) fmt.Println(string(data)) ``` -------------------------------- ### Get Keywords Explorer Overview (Go) Source: https://docs.ahrefs.com/en/api/reference/keywords-explorer/get-overview This Go code snippet shows how to make a GET request to the Keywords Explorer Overview API. It sets the Authorization and Accept headers and prints the response body. ```go req, _ := http.NewRequest("GET", "https://api.ahrefs.com/v3/keywords-explorer/overview", nil) req.Header.Set("Authorization", "Bearer $AHREFS_API_KEY") req.Header.Set("Accept", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() data, _ := io.ReadAll(resp.Body) fmt.Println(string(data)) ``` -------------------------------- ### Get Devices Data (Node.js) Source: https://docs.ahrefs.com/en/api/reference/web-analytics/get-devices This Node.js example demonstrates how to use the `fetch` API to call the Devices endpoint. It sets the required Authorization and Accept headers. ```javascript const response = await fetch("https://api.ahrefs.com/v3/web-analytics/devices", { method: "GET", headers: { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Get Impressions History (Python) Source: https://docs.ahrefs.com/en/api/reference/brand-radar/get-impressions-history Example of how to make a GET request to the impressions history endpoint using Python's requests library. Replace `$AHREFS_API_KEY` with your actual API key. ```python import requests url = "https://api.ahrefs.com/v3/brand-radar/impressions-history" headers = { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### Get Competitors Overview (Go) Source: https://docs.ahrefs.com/en/api/reference/rank-tracker/get-competitors-overview This Go code snippet shows how to make a GET request to the Competitors Overview API. It includes setting the necessary headers, including your API key. ```go req, _ := http.NewRequest("GET", "https://api.ahrefs.com/v3/rank-tracker/competitors-overview", nil) req.Header.Set("Authorization", "Bearer $AHREFS_API_KEY") req.Header.Set("Accept", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() data, _ := io.ReadAll(resp.Body) fmt.Println(string(data)) ``` -------------------------------- ### Python Request Example Source: https://docs.ahrefs.com/en/api/reference/web-analytics/get-sources Example of how to make a GET request to the Web Analytics Sources API using Python's requests library. Replace `$AHREFS_API_KEY` with your actual API key. ```python import requests url = "https://api.ahrefs.com/v3/web-analytics/sources" headers = { "Authorization": "Bearer $AHREFS_API_KEY", "Accept": "application/json" } response = requests.get(url, headers=headers) print(response.json()) ```