Retrieve Current Visibility - Lightsage

Retrieve Current Visibility

cURL

curl --request GET \
  --url https://api.lightsage.com/v2/visibility/current \
  --header 'X-Lightsage-Api-Key: <api-key>'

Python

import requests

url = "https://api.lightsage.com/v2/visibility/current"

headers = {"X-Lightsage-Api-Key": "<api-key>"}

response = requests.get(url, headers=headers)

print(response.text)

JavaScript (Fetch)

const options = {method: 'GET', headers: {'X-Lightsage-Api-Key': '<api-key>'}};

fetch('https://api.lightsage.com/v2/visibility/current', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

PHP

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.lightsage.com/v2/visibility/current",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "X-Lightsage-Api-Key: <api-key>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Go

package main

import (
    "fmt"
    "net/http"
    "io"
)

func main() {
    url := "https://api.lightsage.com/v2/visibility/current"

req, _ := http.NewRequest("GET", url, nil)
    req.Header.Add("X-Lightsage-Api-Key", "<api-key>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}

Response Format

Expected Success Response (200)

{
  "company": {
    "name": "<string>",
    "domain": "<string>",
    "logo_url": "<string>",
    "relationship": "<string>"
  },
  "start_date": "<string>",
  "end_date": "<string>",
  "has_data": true,
  "recommendation_score": 123,
  "recommendation_score_rank": 123,
  "visibility_score": 123,
  "visibility_score_rank": 123,
  "share_of_voice": 123,
  "share_of_voice_rank": 123,
  "average_position": 123,
  "average_position_rank": 123,
  "date": "<string>",
  "active_prompts_only": true
}

Expected Validation Error Response (422)

{
  "detail": [
    {
      "loc": ["<string>"],
      "msg": "<string>",
      "type": "<string>",
      "input": "<unknown>",
      "ctx": {}
    }
  ]
}