# Numbers API (`shahidirfan/number-api`) Actor

Fetch fascinating math facts, historic anecdotes, date insights, and trivia for any number with the Numbers API Actor. Designed for speed and reliability, it supports batch queries, customizable outputs, and robust error handling—perfect for educators, developers, and creators.

- **URL**: https://apify.com/shahidirfan/number-api.md
- **Developed by:** [Shahid Irfan](https://apify.com/shahidirfan) (community)
- **Categories:** Developer tools, Other, Automation
- **Stats:** 20 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Numbers API - Trivia, Math, Date & Year Facts

Extract fascinating and educational facts about any number with this high-performance, local-first actor. Whether you need mathematical properties, historical date information, trivia, or year-related events, this tool provides comprehensive numeric insights instantly.

This actor is built for speed and reliability, operating entirely without external API dependencies. This means no latency, no rate limits, and 100% uptime for your data enrichment workflows.

### Features

- **Trivia Facts** — Get fun and surprising trivia facts about any integer
- **Mathematical Properties** — Detailed analysis of primality, divisors, squares, cubes, binary, and hexadecimal representations
- **Date Information** — Interpret numbers as dates and get relevant historical context
- **Yearly Events** — Explore facts related to specific years, including era (AD/BC) and century placement
- **Batch Processing** — Process multiple numbers in a single run by providing a comma-separated list
- **Random Discovery** — Use the `random` keyword to discover facts about unexpected numbers
- **Zero External Dependencies** — Local execution ensures maximum privacy, speed, and reliability

### Use Cases

#### Educational Content Generation
Build educational quizzes, daily fact bots, or interactive learning tools for students. Provide deep mathematical insights into numbers used in curriculum.

#### Data Enrichment
Enhance your datasets with additional numeric context. Perfect for adding unique value to statistical reports or research papers.

#### App & Web Development
Integrate dynamic number facts into your applications, websites, or user interfaces to increase engagement and provide interactive value.

#### Quizzes & Gamification
Generate unique questions and answers for trivia games and quiz platforms based on mathematical or historical numeric facts.

---

### Input Parameters

The actor accepts the following input parameters:

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `numbers` | String | Yes | — | Comma-separated list of numbers or `random` (e.g., `7,random,42`). |
| `factType` | String | No | `"trivia"` | Type of fact to fetch: `trivia`, `math`, `date`, or `year`. |
| `results_wanted` | Integer | No | `20` | Maximum number of facts to generate in one run. |

---

### Output Data

Each record in the resulting dataset contains:

| Field | Type | Description |
|-------|------|-------------|
| `number` | Integer | The specific number the fact relates to. |
| `fact` | String | The plain text description or fact about the number. |
| `fact_html` | String | The fact formatted in HTML for easy web integration. |

---

### Usage Examples

#### Basic Trivia Extraction

Extract fun facts for a set of specific numbers:

```json
{
    "numbers": "7, 42, 100",
    "factType": "trivia"
}
````

#### Mathematical Analysis

Perform deep mathematical property extraction:

```json
{
    "numbers": "13, 256, 1024",
    "factType": "math"
}
```

#### Dynamic Random Discovery

Generate facts for random numbers for interactive applications:

```json
{
    "numbers": "random, random, random",
    "factType": "year",
    "results_wanted": 10
}
```

***

### Sample Output

```json
{
  "number": 42,
  "fact": "42 is a positive, even integer. 42 is a composite number with 8 positive divisors. The sum of its digits is 6. In binary, it is 101010. In hexadecimal, it is 0x2A. Here's a numeric trivia fact: 42 is a positive, even integer...",
  "fact_html": "<p>42 is a positive, even integer. 42 is a composite number with 8 positive divisors. The sum of its digits is 6. In binary, it is 101010. In hexadecimal, it is 0x2A. Here's a numeric trivia fact: 42 is a positive, even integer...</p>"
}
```

***

### Tips for Best Results

#### Mixing Specifics and Randoms

You can mix specific numbers with the `random` keyword (e.g., `1,random,100,random`) to get a balanced dataset of known and surprising facts.

#### Choosing the Right Fact Type

- Use **Trivia** for general engagement.
- Use **Math** for technical or educational depth.
- Use **Date** when numbers represent calendar days.
- Use **Year** for historical or timeline data.

#### Scaling Your Extraction

While the actor is very fast, using a reasonable `results_wanted` limit ensures your workflows remain efficient and manageable.

***

### Integrations

Connect your numeric facts with your favorite tools:

- **Google Sheets** — Direct export for analysis and reporting
- **Zapier & Make** — Automate your fact delivery workflows
- **Slack & Discord** — Power your community bots with interesting facts
- **Webhooks** — Send facts directly to your custom API endpoints

#### Export Formats

- **JSON** — Structured data for developers
- **CSV** — For easy spreadsheet manipulation
- **XML & Excel** — Compatible with business systems

***

### Frequently Asked Questions

#### Is there a limit to how many numbers I can process?

You can process as many numbers as you need, though the `results_wanted` parameter helps you stay within your desired output limit for each run.

#### Does this use an external API?

No, all logic is executed locally within the actor. This ensures maximum speed, privacy, and avoids external API failures or rate limits.

#### Can I use this for BC years?

Yes, the actor handles negative numbers as BC years and provides appropriate era context.

***

### Support

For issues or feature requests, contact support through the Apify Console.

#### Resources

- [Apify Documentation](https://docs.apify.com/)
- [API Reference](https://docs.apify.com/api/v2)

***

### Legal Notice

This actor is designed for educational and data enrichment purposes. Use the generated data responsibly and in accordance with your project's requirements.

# Actor input Schema

## `numbers` (type: `string`):

Comma-separated list of numbers or 'random' (e.g., 7,random,42). You can mix specific numbers with 'random' for dynamic results.

## `factType` (type: `string`):

Type of fact to fetch: 'trivia' for fun facts, 'math' for mathematical properties, 'date' for historical dates, 'year' for year-related information.

## `results_wanted` (type: `integer`):

Maximum number of facts to generate.

## Actor input object example

```json
{
  "numbers": "7,random,42",
  "factType": "trivia",
  "results_wanted": 20
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "numbers": "7,random,42",
    "factType": "trivia",
    "results_wanted": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("shahidirfan/number-api").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "numbers": "7,random,42",
    "factType": "trivia",
    "results_wanted": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("shahidirfan/number-api").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "numbers": "7,random,42",
  "factType": "trivia",
  "results_wanted": 20
}' |
apify call shahidirfan/number-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=shahidirfan/number-api",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Numbers API",
        "description": "Fetch fascinating math facts, historic anecdotes, date insights, and trivia for any number with the Numbers API Actor. Designed for speed and reliability, it supports batch queries, customizable outputs, and robust error handling—perfect for educators, developers, and creators.",
        "version": "0.0",
        "x-build-id": "xsF97HhM0S2Km34su"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/shahidirfan~number-api/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-shahidirfan-number-api",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/shahidirfan~number-api/runs": {
            "post": {
                "operationId": "runs-sync-shahidirfan-number-api",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/shahidirfan~number-api/run-sync": {
            "post": {
                "operationId": "run-sync-shahidirfan-number-api",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "numbers"
                ],
                "properties": {
                    "numbers": {
                        "title": "Numbers",
                        "type": "string",
                        "description": "Comma-separated list of numbers or 'random' (e.g., 7,random,42). You can mix specific numbers with 'random' for dynamic results."
                    },
                    "factType": {
                        "title": "Fact Type",
                        "enum": [
                            "trivia",
                            "math",
                            "date",
                            "year"
                        ],
                        "type": "string",
                        "description": "Type of fact to fetch: 'trivia' for fun facts, 'math' for mathematical properties, 'date' for historical dates, 'year' for year-related information.",
                        "default": "trivia"
                    },
                    "results_wanted": {
                        "title": "Results Wanted",
                        "minimum": 1,
                        "type": "integer",
                        "description": "Maximum number of facts to generate.",
                        "default": 20
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
