# Random Joke API

> Random Joke fetches two-part jokes with separated setups and punchlines for applications and bots. Paid plans add a joke rating score to evaluate humor.

**Endpoint:** `GET https://api.apiverve.com/v1/randomjoke`  
**Category:** Entertainment  
**Cost:** 1 credit per call  
**Canonical page:** https://apiverve.com/marketplace/randomjoke

## Overview

Every GET request pulls a joke split into an opening setup and a concluding punchline. By default the joke comes from a reviewed pool that leaves out sexual, offensive, violent and political jokes, so it suits workplace and family apps; set safe to false to draw from the full collection. Paid subscriptions append a numeric quality score to each returned joke.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl "https://api.apiverve.com/v1/randomjoke?safe=true" \
  -H "x-api-key: YOUR_API_KEY"
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `safe` | boolean | No | Only return jokes reviewed as safe for a general audience (no sexual, offensive, violent or political jokes). Set to false to include the full collection, which has adult humor. default true |

## Response fields

- `score` — number · Joke rating or score value · (premium)
- `setup` — string · Opening or setup line of the joke
- `punchline` — string · Punchline or conclusion of the joke

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "score": 9,
    "setup": "Why did the stonemason break up with the female con artist?",
    "punchline": "She took him for granite."
  }
}
```

## Use cases

- **CLI MOTD Banners** — To lighten command-line workflows, terminal scripts fetch and print a setup and punchline whenever an engineer opens a shell session.
- **Interactive Kiosk Idling** — When visitors leave a public touchscreen idle, display software cycles through jokes to draw pedestrians back to the screen.
- **Livestream Overlay Alerts** — During broadcast breaks, streaming software displays a joke setup followed by punchline text on screen to entertain waiting viewers.
- **Push Notification Punchlines** — Mobile apps boost daily retention by delivering the joke setup as a notification teaser and revealing the punchline on tap.

## SDKs

- **npm** — `npm install @apiverve/randomjoke` (https://www.npmjs.com/package/@apiverve/randomjoke)
- **PyPI** — `pip install apiverve-randomjoke` (https://pypi.org/project/apiverve-randomjoke/)
- **NuGet** — `dotnet add package APIVerve.API.RandomJoke` (https://www.nuget.org/packages/APIVerve.API.RandomJoke)
- **Source** — https://github.com/apiverve/randomjoke-api

## More

- Full reference: https://docs.apiverve.com/ref/randomjoke
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
