***

title: ApiNinjasTriviaSkill
slug: /reference/typescript/agents/skills/api-ninjas-trivia
description: Fetch trivia questions from the API Ninjas service with optional category filtering.
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[add-skill]: /docs/server-sdks/reference/typescript/agents/agent-base/add-skill

Fetch trivia questions from the API Ninjas service with optional category filtering.

**Class:** `ApiNinjasTriviaSkill`

**Tools:** `get_trivia`

**Env vars:** `API_NINJAS_KEY`

<ParamField path="api_key" type="string" required={true} toc={true}>
  API Ninjas API key. Falls back to the `API_NINJAS_KEY` environment variable.
</ParamField>

<ParamField path="default_category" type="string" toc={true}>
  Default trivia category if none is specified by the user. Available categories:
  `artliterature`, `language`, `sciencenature`, `general`, `fooddrink`,
  `peopleplaces`, `geography`, `historyholidays`, `entertainment`, `toysgames`,
  `music`, `mathematics`, `religionmythology`, `sportsleisure`.
</ParamField>

<ParamField path="reveal_answer" type="boolean" default="false" toc={true}>
  Whether to include the answer in the response. When `false`, the AI receives
  the answer privately so it can quiz the user.
</ParamField>

```typescript {6-9}
import { AgentBase, ApiNinjasTriviaSkill } from '@signalwire/sdk';

const agent = new AgentBase({ name: 'assistant', route: '/assistant' });
agent.setPromptText('You are a helpful assistant.');

await agent.addSkill(new ApiNinjasTriviaSkill({
  default_category: 'sciencenature',
  reveal_answer: false,
}));

agent.run();
```