Numbers API

Numbers API

Open Data

Number of the day, random number generation, number facts and anything else you want to do with numbers. Some of our API calls are public. To maintain our service level we ratelimit the number of API calls. For public API calls this is 60 API calls a day with distribution of 5 calls an hour. For paid plans this limit is increased according to the service level described in the plan.

Visit API

📚 Documentation & Examples

Everything you need to integrate with Numbers API

🚀 Quick Start Examples

Numbers API Javascript Examplejavascript
// Numbers API API Example
const response = await fetch('https://math.tools/api/numbers/', {
    method: 'GET',
    headers: {
        'Content-Type': 'application/json'
    }
});

const data = await response.json();
console.log(data);

Exploring Math.tools API with JavaScript

Math.tools provides a free and open API for developers to use in their projects. In this blog post, we'll explore some of the available endpoints and provide example code in JavaScript.

Getting Started

Before we begin, you'll need an API key. You can sign up for one for free on the Math.tools API documentation page.

To use the API in your JavaScript code, you will need to make HTTP requests to the API's endpoints using a library like Axios or Fetch.

Example Code

Here is an example of how to make a request to the sqrt endpoint using Axios:

const axios = require('axios');

const BASE_URL = 'https://math.tools/api/numbers';
const API_KEY = '<insert your API key here>';

const number = 16;

axios.get(`${BASE_URL}/sqrt/${number}?apikey=${API_KEY}`)
  .then(response => {
    console.log(response.data.result);
  })
  .catch(error => {
    console.log(error.response.data.error);
  });

Here is the same request using Fetch:

const BASE_URL = 'https://math.tools/api/numbers';
const API_KEY = '<insert your API key here>';

const number = 16;

fetch(`${BASE_URL}/sqrt/${number}?apikey=${API_KEY}`)
  .then(response => response.json())
  .then(json => {
    console.log(json.result);
  })
  .catch(error => {
    console.log(error.message);
  });

Note that in both examples, we need to include our API key in the request URL as a query parameter.

Available Endpoints

sqrt

This endpoint returns the square root of a number.

Example Request:

GET /sqrt/16?apikey=<your api key>

Example Response:

{
  "success": true,
  "result": 4
}

log

This endpoint returns the natural logarithm of a number.

Example Request:

GET /log/10?apikey=<your api key>

Example Response:

{
  "success": true,
  "result": 2.302585092994046
}

exp

This endpoint returns the exponential of a number.

Example Request:

GET /exp/2?apikey=<your api key>

Example Response:

{
  "success": true,
  "result": 7.3890560989306495
}

sin

This endpoint returns the sine of an angle in radians.

Example Request:

GET /sin/0.5?apikey=<your api key>

Example Response:

{
  "success": true,
  "result": 0.479425538604203
}

cos

This endpoint returns the cosine of an angle in radians.

Example Request:

GET /cos/0.5?apikey=<your api key>

Example Response:

{
  "success": true,
  "result": 0.8775825618903728
}

tan

This endpoint returns the tangent of an angle in radians.

Example Request:

GET /tan/0.5?apikey=<your api key>

Example Response:

{
  "success": true,
  "result": 0.5463024898437905
}

Conclusion

In this blog post, we've explored some of the available endpoints of the Math.tools API and provided example code in JavaScript using Axios and Fetch. With these tools, you can quickly and easily integrate mathematical calculations into your web applications.

📊 30-Day Uptime History

Daily uptime tracking showing online vs offline minutes

Jun 16Jun 18Jun 20Jun 22Jun 24Jun 26Jun 28Jun 30Jul 2Jul 4Jul 6Jul 8Jul 10Jul 12Jul 1504008001440Minutes
Online
Offline

Related APIs in Open Data