Skip to content

Latest commit

 

History

History
116 lines (89 loc) · 2.66 KB

File metadata and controls

116 lines (89 loc) · 2.66 KB
description
This is complete documentation about how to get Facts using Random Stuff API (This Endpoint is accessible using Paid plan only)

ℹ /facts

{% hint style="danger" %} Since this API is only accessible using RapidAPI, you need to change the base URL to https://random-stuff-api.p.rapidapi.com**** {% endhint %}

{% swagger method="get" path="/facts" baseUrl="https://api.pgamerx.com" summary="This endpoint allows you to get facts" %} {% swagger-description %}

{% endswagger-description %}

{% swagger-parameter in="header" name="x-rapidapi-host" required="true" %} It should always be:

"random-stuff-api.p.rapidapi.com" {% endswagger-parameter %}

{% swagger-parameter in="header" name="Authorizaion" required="true" %} The API key you received from

our side

. {% endswagger-parameter %}

{% swagger-parameter in="header" name="x-rapidapi-key" required="true" %} The API key you received from

RapidApi

{% endswagger-parameter %}

{% swagger-parameter in="path" name="tye" required="true" %} What type of fact do you want to know? {% endswagger-parameter %}

{% swagger-response status="200: OK" description="You successfully got the details" %}

{
"fact":"Dogs can sniff at the same time as breathing"
}

{% endswagger-response %}

{% swagger-response status="401: Unauthorized" description="You did not Authorise correctly" %}

"Invalid API key"
// or 
"Forbidden, Not Subscribed to this plan"

{% endswagger-response %} {% endswagger %}

Facts Available

  • all
  • emoji
  • dog
  • cat
  • food
  • space
  • covid
  • computer

{% tabs %} {% tab title="NodeJS" %}

var axios = require("axios").default;

var options = {
  method: 'GET',
  url: 'https://random-stuff-api.p.rapidapi.com/facts/dog',
  headers: {
    authorization: 'Random Stuff API',
    'x-rapidapi-host': 'random-stuff-api.p.rapidapi.com',
    'x-rapidapi-key': 'RapidAPI key'
  }
};

axios.request(options).then(function (response) {
	console.log(response.data);
}).catch(function (error) {
	console.error(error);
});

{% endtab %}

{% tab title="Python" %}

import requests

url = "https://random-stuff-api.p.rapidapi.com/facts/dog"

headers = {
    'authorization': "Random Stuff API key",
    'x-rapidapi-host': "random-stuff-api.p.rapidapi.com",
    'x-rapidapi-key': "RapidAPI key"
    }

response = requests.request("GET", url, headers=headers)

print(response.text)

{% endtab %} {% endtabs %}

{% hint style="success" %} For examples in all languages, checkout RapidAPI Page {% endhint %}