🤢

おもろいAPIを使う

2020/09/21に公開

この先一生使うことのないであろうAPIをいくつか見つけたので紹介していく。

Tronald Dump


https://www.tronalddump.io/

トランプ大統領の迷言をTwitterから取ってきて投げてくれるAPIです。

使い方

ランダム迷言

curl https://api.tronalddump.io/random/quote
{
  "appeared_at": "2015-12-27T00:31:07.000Z",
  "created_at": "2019-12-13T17:01:47.876Z",
  "quote_id": "fwej8udkQ5uHpY2spg9pzQ",
  "tags": [],
  "updated_at": "2019-12-13T17:26:27.045Z",
  "value": "Hillary Clinton has announced that she is letting her husband out to campaign but HE'S DEMONSTRATED A PENCHANT FOR SEXISM, so inappropriate!",
  "_embedded": {
    "author": [
      {
        "author_id": "wVE8Y7BoRKCBkxs1JkqAvw",
        "bio": null,
        "created_at": "2019-12-13T16:43:24.728Z",
        "name": "Donald Trump",
        "slug": "donald-trump",
        "updated_at": "2019-12-13T16:43:24.728Z",
        "_links": {
          "self": {
            "href": "http://api.tronalddump.io/author/wVE8Y7BoRKCBkxs1JkqAvw"
          }
        }
      }
    ],
    "source": [
      {
        "created_at": "2019-12-13T16:56:20.749Z",
        "filename": null,
        "quote_source_id": "4V7H40ORRlerbEer_DENJw",
        "remarks": null,
        "updated_at": "2019-12-13T16:56:20.749Z",
        "url": "https://twitter.com/realDonaldTrump/status/680908733455708160",
        "_links": {
          "self": {
            "href": "http://api.tronalddump.io/quote-source/4V7H40ORRlerbEer_DENJw"
          }
        }
      }
    ]
  },
  "_links": {
    "self": {
      "href": "http://api.tronalddump.io/quote/fwej8udkQ5uHpY2spg9pzQ"
    }
  }
}

迷言カテゴリ

curl https://api.tronalddump.io/tag
{
  "count": 28,
  "total": 28,
  "_embedded": {
    "tag": [
      {
        "created_at": "2019-12-13T16:46:02.205Z",
        "updated_at": "2019-12-13T16:46:02.205Z",
        "value": "Barack Obama",
        "_links": {
          "self": {
            "href": "http://api.tronalddump.io/tag/Barack%20Obama"
          }
        }
      },
      {
        "created_at": "2019-12-13T16:46:02.810Z",
        "updated_at": "2019-12-13T16:46:02.810Z",
        "value": "Women",
        "_links": {
          "self": {
            "href": "http://api.tronalddump.io/tag/Women"
          }
        }
      },
      {
        "created_at": "2019-12-13T16:46:03.424Z",
        "updated_at": "2019-12-13T16:46:03.424Z",
        "value": "Marco Rubio",
        "_links": {
          "self": {
            "href": "http://api.tronalddump.io/tag/Marco%20Rubio"
          }
        }
      },
      // 続く.......

Official Joke API

https://github.com/15Dkatz/official_joke_api

アメリカンジョークをフリとオチに分けて投げてくれるAPIです。

使い方

ランダムジョーク

curl https://official-joke-api.appspot.com/jokes/random
{
  "id": 265,
  "type": "general",
  "setup": "What kind of bagel can fly?",
  "punchline": "A plain bagel."
}

プログラミングジョーク

curl https://official-joke-api.appspot.com/jokes/programming/random
{
    "id": 73,
    "type": "programming",
    "setup": "The punchline often arrives before the set-up.",
    "punchline": "Do you know the problem with UDP jokes?"
  }

Buzzword Generator API


https://github.com/sameerkumar18/corporate-bs-generator-api

中身ないけどそれっぽい言葉を投げてくれるAPIです

使い方

curl https://corporatebs-generator.sameerkumar.website/
{
  "phrase": "Energistically Matrix Web-enabled Services"
}

READMEの文章からすでに中身がないのでぜひ使ってみることをおすすめします

Corporate bullshit is the icing on the cake, proof that not even the business world takes the business world seriously. People get annoyed about it but don’t do anything about it, they give its use in meetings the dignity of a response rather than someone saying “what the fuck are you talking about?!” Even Googling “how to deal with corporate bullshit” renders no exact matches and very related matches.
So, I made this lovely little corporate bullshit generator to randomly pick out phrases, which can help your application get ahead in an industry where spin, buzzwords and vagueness reign supreme.

Open Trivia API

https://opentdb.com/api_config.php

様々なジャンルのトリビアを教えてくれるAPIです

使い方

curl https://opentdb.com/api.php?amount=1
{
  "response_code": 0,
  "results": [
    {
      "category": "Entertainment: Television",
      "type": "multiple",
      "difficulty": "medium",
      "question": "Who sang the theme song for the TV show 'Rawhide'?",
      "correct_answer": "Frankie Laine",
      "incorrect_answers": [
        "Guy Mitchell",
        " Tennessee Ernie Ford",
        "Slim Whitman"
      ]
    }
  ]
}

Numbers API

http://numbersapi.com/

数字に関するトリビアを教えてくれるAPIです。

使い方

ランダムトリビア

数学
curl http://numbersapi.com/random/math?json
{
 "text": "9267 is a value of n for which n and 2n together use each digit 1-9 exactly once.",
 "number": 9267,
 "found": true,
 "type": "math"
}
日付
curl http://numbersapi.com/random/date?json
100   207  100   207    0     0    539      0 --:--:-- --:--:-- --:--:--   539
{
  "text": "June 21st is the day in 1854 that the first Victoria Cross is awarded during the bombardment of Bomarsund in the Åland Islands.",
  "year": 1854,
  "number": 173,
  "found": true,
  "type": "date"
}
curl http://numbersapi.com/random/year?json
{
  "text": "777 is the year that Charlemagne defeats the Saxons; their leader Widukind flees to Denmark.",
  "number": 777,
  "found": true,
  "type": "year"
}
数学ですらないトリビア
curl http://numbersapi.com/random/trivia?json
{
  "text": "188 is the range measured in miles of a fully charged electric battery-powered Lightning GT sports car.",
  "number": 188,
  "found": true,
  "type": "trivia"
}

指定した日付のトリビア

ex.) 9/21

curl http://numbersapi.com/9/21/date?json
{
  "text": "September 21st is the day in 1981 that Belize is granted full independence from the United Kingdom.",
  "year": 1981,
  "number": 265,
  "found": true,
  "type": "date"
}

おわりに

今回紹介するAPIは全てこちらのサイトを作る際に見つけたものです。
サイト冒頭でAPI叩きたてホヤホヤのアメリカンジョークをぶち込んでますが英語なので正直僕も何が面白いのか分かりません。

参考になれば幸いです

Discussion