Testcases
List Testcases in Testset
Retrieve a paginated list of Testcases belonging to a Testset.
GET
/
testsets
/
{testsetId}
/
testcases
JavaScript
import Scorecard from 'scorecard-ai';
const client = new Scorecard({
apiKey: process.env['SCORECARD_API_KEY'], // This is the default and can be omitted
});
// Automatically fetches more pages as needed.
for await (const testcase of client.testcases.list('246')) {
console.log(testcase.id);
}import os
from scorecard_ai import Scorecard
client = Scorecard(
api_key=os.environ.get("SCORECARD_API_KEY"), # This is the default and can be omitted
)
page = client.testcases.list(
testset_id="246",
)
page = page.data[0]
print(page.id)package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api2.scorecard.io/api/v2/testsets/{testsetId}/testcases"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}curl https://api2.scorecard.io/api/v2/testsets/$TESTSET_ID/testcases \
-H "Authorization: Bearer $SCORECARD_API_KEY"{
"data": [
{
"id": "123",
"testsetId": "246",
"jsonData": {
"question": "What is the capital of France?",
"idealAnswer": "Paris",
"provenance": "hand_curated"
},
"inputs": {
"question": "What is the capital of France?"
},
"expected": {
"idealAnswer": "Paris"
}
},
{
"id": "124",
"testsetId": "246",
"jsonData": {
"question": "What is the largest planet in our solar system?",
"idealAnswer": "Jupiter",
"provenance": "synthetic"
},
"inputs": {
"question": "What is the largest planet in our solar system?"
},
"expected": {
"idealAnswer": "Jupiter"
}
},
{
"id": "125",
"testsetId": "246",
"jsonData": {
"question": "What is the deepest ocean on Earth?",
"provenance": "user_feedback"
},
"inputs": {
"question": "What is the deepest ocean on Earth?"
},
"expected": {},
"validationErrors": [
{
"path": "/data",
"message": "Required field 'idealAnswer' is missing"
}
]
}
],
"nextCursor": "126",
"hasMore": true
}{
"code": "UNAUTHORIZED",
"message": "Invalid or missing authentication token",
"details": {}
}{
"code": "INTERNAL_ERROR",
"message": "An unexpected error occurred while processing your request.",
"details": {}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The ID of the Testset to list Testcases from.
Example:
"246"
Query Parameters
Maximum number of items to return (1-100). Use with cursor for pagination through large sets.
Example:
20
Cursor for pagination. Pass the nextCursor from the previous response to get the next page of results.
Example:
"123"
Was this page helpful?
⌘I
JavaScript
import Scorecard from 'scorecard-ai';
const client = new Scorecard({
apiKey: process.env['SCORECARD_API_KEY'], // This is the default and can be omitted
});
// Automatically fetches more pages as needed.
for await (const testcase of client.testcases.list('246')) {
console.log(testcase.id);
}import os
from scorecard_ai import Scorecard
client = Scorecard(
api_key=os.environ.get("SCORECARD_API_KEY"), # This is the default and can be omitted
)
page = client.testcases.list(
testset_id="246",
)
page = page.data[0]
print(page.id)package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api2.scorecard.io/api/v2/testsets/{testsetId}/testcases"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}curl https://api2.scorecard.io/api/v2/testsets/$TESTSET_ID/testcases \
-H "Authorization: Bearer $SCORECARD_API_KEY"{
"data": [
{
"id": "123",
"testsetId": "246",
"jsonData": {
"question": "What is the capital of France?",
"idealAnswer": "Paris",
"provenance": "hand_curated"
},
"inputs": {
"question": "What is the capital of France?"
},
"expected": {
"idealAnswer": "Paris"
}
},
{
"id": "124",
"testsetId": "246",
"jsonData": {
"question": "What is the largest planet in our solar system?",
"idealAnswer": "Jupiter",
"provenance": "synthetic"
},
"inputs": {
"question": "What is the largest planet in our solar system?"
},
"expected": {
"idealAnswer": "Jupiter"
}
},
{
"id": "125",
"testsetId": "246",
"jsonData": {
"question": "What is the deepest ocean on Earth?",
"provenance": "user_feedback"
},
"inputs": {
"question": "What is the deepest ocean on Earth?"
},
"expected": {},
"validationErrors": [
{
"path": "/data",
"message": "Required field 'idealAnswer' is missing"
}
]
}
],
"nextCursor": "126",
"hasMore": true
}{
"code": "UNAUTHORIZED",
"message": "Invalid or missing authentication token",
"details": {}
}{
"code": "INTERNAL_ERROR",
"message": "An unexpected error occurred while processing your request.",
"details": {}
}