Quotable は、無料のオープンソースの見積もり API です。これはもともと FreeCodeCamp プロジェクトの一部として構築されました。貢献に興味がある場合は、貢献者ガイドをご覧ください。
IP アドレスごとに1 分あたり 180 リクエストのレート制限があります。レート制限を超えると、API は429
エラーで応答します。
https://api.quotable.io
API はパブリック Postman ワークスペースで試すことができます。
GET /random
データベースから単一のランダムな引用符を返します。
⛔️ このメソッドは非推奨となり、ランダムな引用を取得するようになりました。
クエリパラメータ
パラメータ | タイプ | 説明 |
---|---|---|
最大長さ | Int | 文字数の最大長 ( minLength と組み合わせることができます) |
最小の長さ | Int | 文字数の最小長 ( maxLength と組み合わせることができます) |
タグ | String | 特定のタグを含むランダムな見積もりを取得します。これは、カンマ ( AND を意味する) またはパイプ ( OR を意味する) で区切られた 1 つ以上のタグ名のリストを受け取ります。カンマ区切りのリストは、指定されたすべてのタグを持つ引用符と一致します。一方、パイプ ( | ) で区切られたリストは、指定されたタグのいずれかを持つ引用符と一致します。タグ名では大文字と小文字が区別されません。複数の単語のタグはケバブケース (「タグ名」) またはスペース区切り (「タグ名」) にすることができます。 |
著者 | String | 1 人以上の著者によるランダムな引用を取得します。値には作成者name またはslug を指定できます。複数の著者による引用を含めるには、著者名/スラッグのパイプ区切りリストを提供します。 |
著者ID | String | deprecated author パラメータと同じですが、 slug の代わりに author _id 使用します。 |
応答
{
_id: string
// The quotation text
content: string
// The full name of the author
author: string
// The `slug` of the quote author
authorSlug: string
// The length of quote (number of characters)
length: number
// An array of tag names for this quote
tags: string [ ]
}
GET /quotes/random
データベースから 1 つ以上のランダムな引用符を取得します。このメソッドは、特定のプロパティ (タグ、引用の長さなど) を持つランダムな引用を取得するために使用できるいくつかのフィルターをサポートしています。
デフォルトでは、このメソッドは単一のランダムな引用符を返します。 limit
パラメーターを使用して、返すランダムな引用符の数を指定できます。
️ このメソッドは、/random
エンドポイントと同等です。唯一の違いは応答形式です。このメソッドは、単一のQuote
オブジェクトを返す代わりに、Quote
オブジェクトのArray
を返します。
パラメータ | タイプ | 説明 |
---|---|---|
限界 | Int | default: 1 min: 1 max: 50 取得するランダムな引用符の数。 |
最大長さ | Int | 文字数の最大長 ( minLength と組み合わせることができます) |
最小の長さ | Int | 文字数の最小長 ( maxLength と組み合わせることができます) |
タグ | String | 特定のタグを含むランダムな見積もりを取得します。これは、カンマ ( AND を意味する) またはパイプ ( OR を意味する) で区切られた 1 つ以上のタグ名のリストを受け取ります。カンマ区切りのリストは、指定されたすべてのタグを持つ引用符と一致します。一方、パイプ ( | ) で区切られたリストは、指定されたタグのいずれかを持つ引用符と一致します。タグ名では大文字と小文字が区別されません。複数の単語のタグはケバブケース (「タグ名」) またはスペース区切り (「タグ名」) にすることができます。 |
著者 | String | 1 人以上の著者によるランダムな引用を取得します。値には作成者name またはslug を指定できます。複数の著者による引用を含めるには、著者名/スラッグのパイプ区切りリストを提供します。 |
著者ID | String | deprecated author パラメータと同じですが、 slug の代わりに author _id 使用します。 |
応答
// An array containing one or more Quotes
Array < {
_id : string
// The quotation text
content : string
// The full name of the author
author : string
// The `slug` of the quote author
authorSlug : string
// The length of quote (number of characters)
length : number
// An array of tag names for this quote
tags : string [ ]
} >
例
ランダムな見積もりを取得してブラウザで試してみる
GET /quotes/random
5 つのランダムな見積もりを取得してブラウザで試してください
GET /quotes/random?limit=3
タグ「テクノロジー」 AND
「有名な引用」を含むランダムな引用をブラウザで試してください
GET /quotes/random?tags=technology,famous-quotes
「歴史」 OR
「公民権」タグを含むランダムな引用をブラウザで試してください
GET /quotes/random?tags=history|civil-rights
最大 50 文字のランダムな引用をブラウザで試してください
GET /quotes/random?maxLength=50
100 ~ 140 文字の長さのランダムな引用をブラウザで試してください
GET /quotes/random?minLength=100&maxLength=140
GET /quotes
指定されたクエリに一致するすべての見積もりを取得します。デフォルトでは、これはすべての引用符のページ分割されたリストを_id
でソートして返します。引用は作成者、タグ、長さでフィルタリングすることもできます。
クエリパラメータ
パラメータ | タイプ | 説明 |
---|---|---|
最大長さ | Int | 文字数の最大長 ( minLength と組み合わせることができます) |
最小の長さ | Int | 文字数の最小長 ( maxLength と組み合わせることができます) |
タグ | String | タグで引用をフィルターします。カンマ ( AND を意味する) またはパイプ ( OR 意味する) で区切られた 1 つ以上のタグ名のリストを受け取ります。カンマ区切りのリストは、指定されたすべてのタグを持つ引用符と一致します。一方、パイプ ( | ) で区切られたリストは、提供されたタグのいずれかを持つ引用符と一致します。タグ名では大文字と小文字が区別されません。複数の単語のタグはケバブケース (「タグ名」) またはスペース区切り (「タグ名」) にすることができます。 |
著者 | String | 特定の著者による引用を取得します。値には作成者name またはslug を指定できます。複数の著者による引用を取得するには、著者名/スラッグのパイプ区切りリストを提供します。 |
著者ID | String | deprecated author パラメータと同じですが、 slug の代わりに author _id 使用します。 |
並べ替え | enum | Default: "dateAdded" values: "dateAdded", "dateModified", "author", "content" 引用符の並べ替えに使用されるフィールド |
注文 | enum | values: "asc", "desc" default: depends on sortBy 結果がソートされる順序。デフォルトの順序は、sortBy フィールドによって決まります。アルファベット順に並べ替えられた文字列フィールドの場合、デフォルトの順序は昇順です。数値フィールドと日付フィールドの場合、デフォルトの順序は降順です。 |
限界 | Int | Min: 1 Max: 150 Default: 20 ページごとの結果の数を設定します。 |
ページ | Int | Min: 1 Default: 1 返される結果のページ。値が合計ページ数より大きい場合、リクエストは結果を返しません。 |
応答
{
// The number of quotes returned in this response
count: number
// The total number of quotes matching this query
totalCount: number
// The current page number
page: number
// The total number of pages matching this request
totalPages: number
// The 1-based index of the last result included in the current response.
lastItemIndex: number
// The array of quotes
results : Array < {
_id : string
// The quotation text
content : string
// The full name of the author
author : string
// The `slug` of the quote author
authorSlug : string
// The length of quote (number of characters)
length : number
// An array of tag names for this quote
tags : string [ ]
} >
}
例
見積もりの最初のページを取得し、1 ページあたり 20 件の結果をブラウザで試してください
GET /quotes?page=1
見積書の 2 ページ目を取得します。ブラウザで 1 ページあたり 20 件の結果が表示されます。
GET /quotes?page=2
love
OR
happiness
タグが付いたすべての引用をブラウザで取得してみてください
GET /quotes?tags=love|happiness
タグtechnology
AND
famous-quotes
を使用してすべての引用をブラウザで取得します
GET /quotes?tags=technology,famous-quotes
著者のslug
を使用して、著者ごとのすべての引用を取得します。ブラウザで試してみる
GET /quotes?author=albert-einstein
GET /quotes/:id
ID で見積もりを取得する
応答
{
_id: string
// The quotation text
content: string
// The full name of the author
author: string
// The length of quote (number of characters)
length: number
// An array of tag names for this quote
tags: string [ ]
}
GET /authors
指定されたクエリに一致するすべての著者を取得します。このエンドポイントは、並べ替えとフィルターのためのいくつかのオプションを使用して、著者をリストするために使用できます。また、著者スラッグまたは ID を使用して、1 人以上の特定の著者の詳細を取得するために使用することもできます。
クエリパラメータ
パラメータ | タイプ | 説明 |
---|---|---|
ナメクジ | string | 著者をスラッグでフィルタリングします。値には 1 つ以上の作成者スラッグを指定できます。スラッグによって複数の作成者を取得するには、値はパイプで区切られたスラッグのリストである必要があります。 |
並べ替え | enum | Default: "name" values: "dateAdded", "dateModified", "name", "quoteCount" 著者を並べ替えるために使用されるフィールド。 |
注文 | enum | values: "asc", "desc" 結果がソートされる順序。デフォルトの順序は、sortBy フィールドによって決まります。アルファベット順にソートされた文字列フィールド (つまり、 name ) の場合、デフォルトの順序は昇順です。数値フィールドと日付フィールド (つまりquoteCount ) の場合、デフォルトの順序は降順です。 |
限界 | Int | Min: 1 Max: 150 Default: 20 ページごとの結果の数を設定します。 |
ページ | Int | Min: 1 Default: 1 返される結果のページ。値が合計ページ数より大きい場合、リクエストは結果を返しません。 |
応答
{
// The number of results included in this response.
count: number
// The total number of results matching this request.
totalCount: number
// The current page number
page: number
// The total number of pages matching this request
totalPages: number
// The 1-based index of the last result included in this response. This shows the
// current pagination offset.
lastItemIndex: number | null
// The array of authors
results : Array < {
// A unique id for this author
_id : string
// A brief, one paragraph bio of the author. Source: wiki API
bio : string
// A one-line description of the author. Typically it is the person's primary
// occupation or what they are know for.
description : string
// The link to the author's wikipedia page or official website
link : string
// The authors full name
name : string
// A slug is a URL-friendly ID derived from the authors name. It can be used as
slug : string
// The number of quotes by this author
quoteCount : string
} >
}
例
すべての著者を名前のアルファベット順に取得してブラウザで試してください
GET /authors?sortBy=name
すべての著者を取得し、引用数で降順に並べ替えます。ブラウザで試してください。
GET /authors?sortBy=quoteCount&order=desc
スラッグで単一の著者を取得します。ブラウザで試してみる
GET /authors?slug=albert-einstein
スラッグで複数の著者を取得します。この場合、ブラウザで試行するスラッグのパイプ区切りリストを提供します。
GET /authors?slug=albert-einstein|abraham-lincoln
GET /search/quotes
このエンドポイントを使用すると、キーワード、内容、著者名で引用を検索できます。 List Quotes エンドポイントとは異なり、このメソッドは Atlas Search を利用しており、検索バー UI を強化するように設計されています。
クエリパラメータ
パラム | タイプ | 説明 |
---|---|---|
クエリ | String | 検索文字列。クエリを引用符で囲むと、完全に一致する語句を検索できます。 |
フィールド | String | Default: "content,author,tags" 検索するフィールドを指定します。これは、フィールド名のカンマ区切りリストを受け取ります。サポートされている検索フィールドは、「コンテンツ」、「作成者」、「タグ」です。デフォルトでは、すべてのフィールドで同時に検索します。 |
fuzzyMaxEdits | Int | Min: 0 Max: 2 Default: 0 指定した検索語に一致するために必要な 1 文字の編集の最大数。これをゼロに設定すると、あいまい一致が無効になります。 |
fuzzyMaxExpansions | Int | Max: 150 Min: 0 Default: 50 あいまい検索が有効な場合、これは生成および検索するバリエーションの最大数です。この制限はトークンごとに適用されます。 |
限界 | Int | Min: 0 Max: 150 Default: 20 ページあたりの結果の最大数 |
ページ | Int | Min: 1 Default: 1 ページネーションのページ番号を設定します |
応答
{
// The number of results included in this response.
count: number
// The total number of results matching this request.
totalCount: number
// The current page number
page: number
// The total number of pages matching this request
totalPages: number
// The 1-based index of the last result included in this response. This shows the
// current pagination offset.
lastItemIndex: number | null
// The array of authors
results : Array < {
// A unique id for this author
_id : string
// A brief, one paragraph bio of the author. Source: wiki API
bio : string
// A one-line description of the author. Typically it is the person's primary
// occupation or what they are know for.
description : string
// The link to the author's wikipedia page or official website
link : string
// The authors full name
name : string
// A slug is a URL-friendly ID derived from the authors name. It can be used as
slug : string
// The number of quotes by this author
quoteCount : string
} >
}
例
「すべての優れたテクノロジーは基本的に魔法」を検索します (ブラウザーで試してください)
GET /search/quotes?query=every good technology is basically magic
結果:
- 「十分に進歩したテクノロジーは魔法と同等です。」
「一戸建て」というフレーズを検索する
GET /search/quotes?query=divided house
結果
- 「対立して分裂した家は存続できない。」
「人生」または「幸福」というキーワードで名言を検索します(ブラウザでお試しください)
GET /search/quotes?query=life happiness
「kennedy」という名前の著者による引用を検索します (ブラウザで試してください)
GET /search/quotes?query=Kennedy&fields=author
GET /search/authors
このエンドポイントを使用すると、著者を名前で検索できます。これは、ユーザーが入力するとオートコンプリートの提案を表示する著者の検索バーを強化するように設計されています。
Example
query="John F. Kennedy"
terms=["john", "kennedy"]
term term
| |
John F. Kennedy Jr.
| |
initial suffix
Example
query="Saint Augustine of Hippo"
terms=["Augustine", "Hippo"]
term term
| |
Saint Augustine of Hippo
| |
prefix stopword
クエリパラメータ
パラム | タイプ | 説明 |
---|---|---|
クエリ | String | 検索クエリ |
オートコンプリート | Boolean | default: true オートコンプリートマッチングを有効にします |
一致しきい値 | Int | Min: 1 Max: 3 Default: 2 著者が結果に含まれるために一致する必要がある検索語 (単語) の最小数を設定します。基本的に、これを 1 に設定すると、名前の少なくとも 1 つの部分に一致するすべての作成者が結果に含まれます。したがって、query="John F. Kennedy" とすると、結果には、「john」 OR 「kennedy」のいずれかに一致するすべての著者が含まれます。これを 2 に設定すると、検索クエリに 2 つ以上の「用語」が含まれる場合、それらの用語のうち少なくとも 2 つが一致する必要があります。したがって、query="John F. Kennedy" は、「John」 AND 「Kennedy」に一致する著者のみを返します。 |
限界 | Int | Min: Max: 150 Default: 20 ページごとの結果の最大数 |
ページ | Int | Min: 1 Default: 1 ページネーションのページ番号を設定します |
応答
{
// The number of results included in this response.
count: number
// The total number of results matching this request.
totalCount: number
// The current page number
page: number
// The total number of pages matching this request
totalPages: number
// The 1-based index of the last result included in this response. This shows the
// current pagination offset.
lastItemIndex: number | null
// The array of authors
results : Array < {
// A unique id for this author
_id : string
// A brief, one paragraph bio of the author. Source: wiki API
bio : string
// A one-line description of the author. Typically it is the person's primary
// occupation or what they are know for.
description : string
// The link to the author's wikipedia page or official website
link : string
// The authors full name
name : string
// A slug is a URL-friendly ID derived from the authors name. It can be used as
slug : string
// The number of quotes by this author
quoteCount : string
} >
}
例
「Einstein」という名前の著者を検索します(ブラウザで試してください)
GET /search/authors?query=Einstein
結果:
- アルバート・アインシュタイン
「Einstein」のオートコンプリート検索 (ブラウザで試してください)
GET /search/authors?query=Einst
結果:
- アルバート・アインシュタイン
「John Adams」を検索します (ブラウザで試してください)
GET /search/authors?query=john adams
結果
- ジョン・アダムス
- ジョン・クインシー・アダムス
「John Quincy Adams」を検索します (ブラウザで試してください)
GET /search/authors?query=john quincy adams
結果:
- ジョン・クインシー・アダムス)
- ジョン・アダムス
slug
によって単一のAuthor
を取得します。このメソッドは、経歴、Web サイトのリンク、プロフィール画像などの著者の詳細を取得するために使用できます。
特定の著者によるすべての引用を取得したい場合は、/quotes エンドポイントを使用し、著者名/スラッグでフィルターします。
1 つのリクエストで slug によって複数の著者を取得したい場合は、 /authors エンドポイントを使用し、 slug
でフィルターします。
GET /authors/:id
応答
{
// A unique id for this author
_id: string
// A brief, one paragraph bio of the author. Source wiki API.
bio: string
// A one-line description of the author.
description: string
// The link to the author's wikipedia page or official website
link: string
// The authors full name
name: string
// A slug is a URL-friendly ID derived from the authors name. It can be used as
slug: string
// The number of quotes by this author
quoteCount: string
}
GET /tags
すべてのタグのリストを取得する
クエリパラメータ
パラメータ | タイプ | 説明 |
---|---|---|
並べ替え | enum | Default: "name" values: "dateAdded", "dateModified", "name", "quoteCount" タグの並べ替えに使用されるフィールド。 |
注文 | enum | values: "asc", "desc" 結果を並べ替える順序。デフォルトの順序は、sortBy フィールドによって異なります。アルファベット順に並べ替えられた文字列フィールドの場合、デフォルトの順序は昇順です。数値フィールドと日付フィールドの場合、デフォルトの順序は降順です。 |
応答
{
// The number of all tags by this request
count: number
// The array of tags
results : Array < {
_id : string
name : string
} >
}