Get public metrics for organizations
curl --request POST \
--url https://app.chainpatrol.io/api/v2/public/getOrganizationMetrics \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"organizationSlug": "<string>",
"brandSlug": "<string>",
"startDate": "<string>",
"endDate": "<string>"
}
'import requests
url = "https://app.chainpatrol.io/api/v2/public/getOrganizationMetrics"
payload = {
"organizationSlug": "<string>",
"brandSlug": "<string>",
"startDate": "<string>",
"endDate": "<string>"
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
organizationSlug: '<string>',
brandSlug: '<string>',
startDate: '<string>',
endDate: '<string>'
})
};
fetch('https://app.chainpatrol.io/api/v2/public/getOrganizationMetrics', 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://app.chainpatrol.io/api/v2/public/getOrganizationMetrics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'organizationSlug' => '<string>',
'brandSlug' => '<string>',
'startDate' => '<string>',
'endDate' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.chainpatrol.io/api/v2/public/getOrganizationMetrics"
payload := strings.NewReader("{\n \"organizationSlug\": \"<string>\",\n \"brandSlug\": \"<string>\",\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.chainpatrol.io/api/v2/public/getOrganizationMetrics")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"organizationSlug\": \"<string>\",\n \"brandSlug\": \"<string>\",\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.chainpatrol.io/api/v2/public/getOrganizationMetrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"organizationSlug\": \"<string>\",\n \"brandSlug\": \"<string>\",\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"metrics": {
"reports": 123,
"newThreats": 123,
"threatsWatchlisted": 123,
"takedownsFiled": 123,
"takedownsCompleted": 123,
"domainThreats": 123,
"twitterThreats": 123,
"telegramThreats": 123,
"otherThreats": 123
},
"blockedByType": [
{
"type": "<string>",
"count": 123
}
],
"blockedByDay": [
{
"date": "<string>",
"count": 123
}
]
}{
"code": "BAD_REQUEST",
"message": "Invalid input data",
"issues": []
}{
"code": "UNAUTHORIZED",
"message": "Authorization not provided",
"issues": []
}{
"code": "FORBIDDEN",
"message": "Insufficient access",
"issues": []
}{
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal server error",
"issues": []
}Organization Metrics
Get Organization Metrics (Deprecated)
Get public metrics for one or more organizations
POST
/
public
/
getOrganizationMetrics
Get public metrics for organizations
curl --request POST \
--url https://app.chainpatrol.io/api/v2/public/getOrganizationMetrics \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"organizationSlug": "<string>",
"brandSlug": "<string>",
"startDate": "<string>",
"endDate": "<string>"
}
'import requests
url = "https://app.chainpatrol.io/api/v2/public/getOrganizationMetrics"
payload = {
"organizationSlug": "<string>",
"brandSlug": "<string>",
"startDate": "<string>",
"endDate": "<string>"
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
organizationSlug: '<string>',
brandSlug: '<string>',
startDate: '<string>',
endDate: '<string>'
})
};
fetch('https://app.chainpatrol.io/api/v2/public/getOrganizationMetrics', 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://app.chainpatrol.io/api/v2/public/getOrganizationMetrics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'organizationSlug' => '<string>',
'brandSlug' => '<string>',
'startDate' => '<string>',
'endDate' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.chainpatrol.io/api/v2/public/getOrganizationMetrics"
payload := strings.NewReader("{\n \"organizationSlug\": \"<string>\",\n \"brandSlug\": \"<string>\",\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.chainpatrol.io/api/v2/public/getOrganizationMetrics")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"organizationSlug\": \"<string>\",\n \"brandSlug\": \"<string>\",\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.chainpatrol.io/api/v2/public/getOrganizationMetrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"organizationSlug\": \"<string>\",\n \"brandSlug\": \"<string>\",\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"metrics": {
"reports": 123,
"newThreats": 123,
"threatsWatchlisted": 123,
"takedownsFiled": 123,
"takedownsCompleted": 123,
"domainThreats": 123,
"twitterThreats": 123,
"telegramThreats": 123,
"otherThreats": 123
},
"blockedByType": [
{
"type": "<string>",
"count": 123
}
],
"blockedByDay": [
{
"date": "<string>",
"count": 123
}
]
}{
"code": "BAD_REQUEST",
"message": "Invalid input data",
"issues": []
}{
"code": "UNAUTHORIZED",
"message": "Authorization not provided",
"issues": []
}{
"code": "FORBIDDEN",
"message": "Insufficient access",
"issues": []
}{
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal server error",
"issues": []
}This endpoint is deprecated. Please use the new RESTful endpoint GET /organization/metrics instead. This endpoint will be removed in a future version.
Quick Start
Authentication
Include your API key in theAuthorization header:
Authorization: Bearer your_api_key
Example Request
curl -X POST 'https://api.chainpatrol.io/public/getOrganizationMetrics' \
-H 'Authorization: Bearer your_api_key' \
-H 'Content-Type: application/json' \
-d '{
"organizationSlug": "your-org",
"startDate": "2024-01-01T00:00:00Z",
"endDate": "2024-03-01T00:00:00Z"
}'
Access Control
The API enforces strict access control based on your API key type:-
Organization API Keys:
- Can only access metrics for their associated organization
- Must match the
organizationSlugexactly - Example: An API key for “acme-org” can only query metrics for “acme-org”
-
User API Keys:
- Can access metrics for any organization where the user is a member
- Requires the user to be an active member of the queried organization
- Example: A user who is a member of both “acme-org” and “beta-org” can query metrics for both organizations
Example Implementation
async function fetchOrganizationMetrics(organizationSlug, startDate, endDate) {
const response = await fetch(
"https://api.chainpatrol.io/public/getOrganizationMetrics",
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer YOUR_API_KEY_HERE",
},
body: JSON.stringify({
organizationSlug,
startDate,
endDate,
}),
}
);
return response.json();
}
// Example usage
fetchOrganizationMetrics(
"your-org",
"2024-01-01T00:00:00Z",
"2024-03-01T00:00:00Z"
)
.then((data) => console.log("Metrics:", data))
.catch((error) => console.error("Error fetching metrics:", error));
interface OrganizationMetrics {
metrics: {
reportsCount: number;
threatsBlockedCount: number;
threatsBlockedByAssetType: Array<{
assetType: string;
count: number;
}>;
domainsBlockedCount: number;
totalTakedownsFiledCount: number;
totalTakedownsCompletedCount: number;
totalDetections: number;
};
}
async function fetchOrganizationMetrics(
organizationSlug: string,
startDate?: string,
endDate?: string
): Promise<OrganizationMetrics> {
const response = await fetch(
"https://api.chainpatrol.io/public/getOrganizationMetrics",
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer YOUR_API_KEY_HERE",
},
body: JSON.stringify({
organizationSlug,
startDate,
endDate,
}),
}
);
return response.json();
}
// Example usage
fetchOrganizationMetrics(
"your-org",
"2024-01-01T00:00:00Z",
"2024-03-01T00:00:00Z"
)
.then((data) => console.log("Metrics:", data))
.catch((error) => console.error("Error fetching metrics:", error));
import requests
from typing import Dict, Optional
from datetime import datetime
def fetch_organization_metrics(
organization_slug: str,
start_date: Optional[str] = None,
end_date: Optional[str] = None
) -> Dict:
response = requests.post(
"https://api.chainpatrol.io/public/getOrganizationMetrics",
headers={
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY_HERE",
},
json={
"organizationSlug": organization_slug,
"startDate": start_date,
"endDate": end_date,
},
)
return response.json()
# Example usage
try:
metrics = fetch_organization_metrics(
"your-org",
"2024-01-01T00:00:00Z",
"2024-03-01T00:00:00Z"
)
print("Metrics:", metrics)
except Exception as error:
print("Error fetching metrics:", str(error))
API Details
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| organizationSlug | string | Yes | Organization slug to query |
| startDate | Date | No | Start date for metrics (default: all time) |
| endDate | Date | No | End date for metrics (default: current date) |
Response Format
{
metrics: {
reportsCount: number; // Total number of reports
threatsBlockedCount: number; // Total number of threats blocked
threatsBlockedByAssetType: Array<{
// Threats blocked grouped by asset type
assetType: string;
count: number;
}>;
domainsBlockedCount: number; // Number of domains blocked
totalTakedownsFiledCount: number; // Total number of takedowns filed
totalTakedownsCompletedCount: number; // Total number of completed takedowns
totalDetections: number; // Total number of threat detections
}
}
Error Handling
| Status Code | Description |
|---|---|
| 401 Unauthorized | Invalid or missing API key |
| 403 Forbidden | API key does not have permission to query the requested organization |
| 500 Internal Server Error | Server error occurred while processing the request |
Notes
- If no date range is provided, metrics will be returned for all time
- The API only returns metrics for a single organization per request
- Organization API keys can only access metrics for their associated organization
- User API keys can access metrics for any organization where the user is a member
- To query multiple organizations, you must use a user API key and ensure the user is a member of all organizations you wish to query
Authorizations
Your API key. This is required by most endpoints to access our API programatically. Reach out to us at support@chainpatrol.io to get an API key for your use.
Was this page helpful?
⌘I