SDKs & Libraries

SDKs & Libraries

Official and community SDKs to integrate QuizAPI into your application. Use a type-safe client library or call the REST API directly from any language.

Official SDKs

Our official SDKs are maintained by the QuizAPI team and provide full type safety, automatic retries, and built-in error handling.

JavaScript / TypeScript SDK

Official

The JavaScript SDK works in Node.js, Deno, Bun, and modern browsers. It includes full TypeScript type definitions.

Installation

bash
npm install @quizapi/sdk

Quick Start

javascript
import { QuizAPI } from "@quizapi/sdk";

// Initialize the client
const quizapi = new QuizAPI({
  apiKey: "qza_live_abc123def456",
});

// List quizzes
const quizzes = await quizapi.quizzes.list({
  category: "programming",
  limit: 10,
});
console.log(quizzes.data);

// Get a single quiz
const quiz = await quizapi.quizzes.get("quiz_abc123");
console.log(quiz.data.title);

// Create a new quiz
const newQuiz = await quizapi.quizzes.create({
  title: "React Hooks Quiz",
  description: "Test your knowledge of React hooks",
  category: "programming",
  difficulty: "MEDIUM",
  tags: ["react", "hooks"],
});
console.log("Created:", newQuiz.data.id);

// List questions for a quiz
const questions = await quizapi.questions.list({
  quizId: "quiz_abc123",
  includeAnswers: true,
});
console.log(questions.data);

TypeScript Support

All methods return fully typed responses. Import the type definitions directly from the package.

typescript
import { QuizAPI, Quiz, Question, PaginatedResponse } from "@quizapi/sdk";

const quizapi = new QuizAPI({ apiKey: process.env.QUIZAPI_KEY! });

// Full TypeScript support with inferred types
const response: PaginatedResponse<Quiz> = await quizapi.quizzes.list({
  category: "programming",
});

// Type-safe access to quiz properties
response.data.forEach((quiz: Quiz) => {
  console.log(quiz.id);          // string
  console.log(quiz.title);       // string
  console.log(quiz.questionCount); // number
});

// Questions are also fully typed
const questions: PaginatedResponse<Question> = await quizapi.questions.list({
  quizId: "quiz_abc123",
});

Error Handling

javascript
import { QuizAPI, QuizAPIError, RateLimitError } from "@quizapi/sdk";

const quizapi = new QuizAPI({ apiKey: "qza_live_abc123def456" });

try {
  const quiz = await quizapi.quizzes.get("quiz_nonexistent");
} catch (error) {
  if (error instanceof RateLimitError) {
    console.log(`Rate limited. Retry after ${error.retryAfter} seconds`);
  } else if (error instanceof QuizAPIError) {
    console.log(`API error: ${error.code} - ${error.message}`);
    console.log(`Status: ${error.status}`);
  } else {
    throw error;
  }
}

Community SDKs

Community-maintained SDKs built by developers in the QuizAPI ecosystem. These libraries are not officially supported but follow the same API conventions.

LanguagePackageStatus
Gogo-quizapiCommunity Maintained
Rubyquizapi-rubyCommunity Maintained
PHPquizapi-phpComing Soon

REST API

Don't see your language? Use the REST API directly. QuizAPI is a standard RESTful API that works with any HTTP client in any programming language.

bash
# List quizzes
curl -X GET "https://quizapi.io/api/v1/quizzes?category=programming&limit=10" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Get a single quiz
curl -X GET "https://quizapi.io/api/v1/quizzes/quiz_abc123" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Create a quiz
curl -X POST "https://quizapi.io/api/v1/quizzes" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "React Hooks Quiz",
    "category": "programming",
    "difficulty": "MEDIUM"
  }'

See the full Quizzes API and Questions API reference for all available endpoints, parameters, and response formats.

Contributing

Want to build an SDK for your language? We provide an OpenAPI specification that you can use to auto-generate client code or as a reference when building a client manually.

To get started:

  1. Download the OpenAPI spec from the link above
  2. Use a code generator like openapi-generator or build your client by hand
  3. Follow the authentication patterns described in the Authentication docs
  4. Submit your SDK to our community directory by opening an issue on GitHub