Classes
Get class source code
Retrieve the verified source code for a specific class on the Starknet network.
GET
/
classes
/
{classHash}
/
source
Get class source code
curl --request GET \
--url https://public-api.voyager.online/beta/classes/{classHash}/source \
--header 'x-api-key: <api-key>'import requests
url = "https://public-api.voyager.online/beta/classes/{classHash}/source"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://public-api.voyager.online/beta/classes/{classHash}/source', 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://public-api.voyager.online/beta/classes/{classHash}/source",
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-api-key: <api-key>"
],
]);
$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://public-api.voyager.online/beta/classes/{classHash}/source"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://public-api.voyager.online/beta/classes/{classHash}/source")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://public-api.voyager.online/beta/classes/{classHash}/source")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"classHash": "0x04a80a072713b645d16c0238060d5ebd318f6a5cec2b7acdc272b1dcc2f5e2d7",
"sourceCode": {
"cairo_ds/Scarb.toml": "[package]\nname = \"cairo_ds\"...",
"cairo_ds/src/contracts/ERC20.cairo": "use starknet::ContractAddress;..."
},
"compilerVersion": "2.6.3",
"verifiedTimestamp": 1728474285,
"verifiedName": "V_Test_2.6.3"
}{
"error": "<string>"
}{
"message": "Forbidden"
}{
"error": "<string>"
}{
"message": "Limit Exceeded"
}Authorizations
API key for authentication. Get your key at https://voyager.online/plans
Path Parameters
Starknet class hash (0x-prefixed hex).
Pattern:
^(0x[0-9a-fA-F]{1,66})$⌘I
Get class source code
curl --request GET \
--url https://public-api.voyager.online/beta/classes/{classHash}/source \
--header 'x-api-key: <api-key>'import requests
url = "https://public-api.voyager.online/beta/classes/{classHash}/source"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://public-api.voyager.online/beta/classes/{classHash}/source', 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://public-api.voyager.online/beta/classes/{classHash}/source",
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-api-key: <api-key>"
],
]);
$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://public-api.voyager.online/beta/classes/{classHash}/source"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://public-api.voyager.online/beta/classes/{classHash}/source")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://public-api.voyager.online/beta/classes/{classHash}/source")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"classHash": "0x04a80a072713b645d16c0238060d5ebd318f6a5cec2b7acdc272b1dcc2f5e2d7",
"sourceCode": {
"cairo_ds/Scarb.toml": "[package]\nname = \"cairo_ds\"...",
"cairo_ds/src/contracts/ERC20.cairo": "use starknet::ContractAddress;..."
},
"compilerVersion": "2.6.3",
"verifiedTimestamp": 1728474285,
"verifiedName": "V_Test_2.6.3"
}{
"error": "<string>"
}{
"message": "Forbidden"
}{
"error": "<string>"
}{
"message": "Limit Exceeded"
}