Shields endpoint JSON
curl --request GET \
--url https://nums.advay.ca/badge.jsonimport requests
url = "https://nums.advay.ca/badge.json"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://nums.advay.ca/badge.json', 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://nums.advay.ca/badge.json",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://nums.advay.ca/badge.json"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://nums.advay.ca/badge.json")
.asString();require 'uri'
require 'net/http'
url = URI("https://nums.advay.ca/badge.json")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"schemaVersion": 1,
"label": "views",
"message": "73",
"color": "blue",
"cacheSeconds": 30
}Endpoints
Badge (Shields endpoint)
GET
/
badge.json
Shields endpoint JSON
curl --request GET \
--url https://nums.advay.ca/badge.jsonimport requests
url = "https://nums.advay.ca/badge.json"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://nums.advay.ca/badge.json', 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://nums.advay.ca/badge.json",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://nums.advay.ca/badge.json"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://nums.advay.ca/badge.json")
.asString();require 'uri'
require 'net/http'
url = URI("https://nums.advay.ca/badge.json")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"schemaVersion": 1,
"label": "views",
"message": "73",
"color": "blue",
"cacheSeconds": 30
}Return Shields.io-compatible JSON for a dynamic badge.
Replace
An example of this in action with my own deployment is
You can add this into your own github profile to view the views on your site, (must be in allowed origins in the .env of your vercel deployment)
Example
The following example demonstrates how to use the Shields endpoint to create a badge for your project’s homepage hits:open "https://img.shields.io/endpoint?url=https%3A%2F%2F<deployment>%2Fbadge.json%3Fid%3Dhome%26label%3Dhits%26cacheSeconds%3D30"
<deployment> with your actual deployment URL. This command, when run in a terminal, will open a URL that returns a JSON response compatible with Shields.io, allowing you to display dynamic badge data.
An example of this in action with my own deployment is
https://img.shields.io/endpoint?url=https%3A%2F%2Fnums.advay.ca%2Fbadge.json%3Fid%3Dhome%26label%3Dhits