Skip to content

Instantly share code, notes, and snippets.

@mryhryki
Last active April 5, 2022 22:42
Show Gist options
  • Save mryhryki/3524a7a444b0af484cb7a49244bb160d to your computer and use it in GitHub Desktop.
Save mryhryki/3524a7a444b0af484cb7a49244bb160d to your computer and use it in GitHub Desktop.
DocBase のメモの検索APIで、10,001 件目以降を取ろうとするとエラーになることを確認するスクリプトとその結果

DocBase のメモの検索APIで、10,001 件目以降を取ろうとするとエラーになることを確認するスクリプトとその結果

(問い合わせたところ、検索エンジンの仕様で10,000件までしか取れない仕様とのこと)

# https://help.docbase.io/posts/45703#%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E3%83%88%E3%83%BC%E3%82%AF%E3%83%B3
export DOCBASE_TOKEN='XXXXXXXXXXXXXXXXXXXX'
function request() {
local per_page="$1"
local page="$2"
# https://help.docbase.io/posts/92984
local url="https://api.docbase.io/teams/connehito/posts?per_page=${per_page}&page=${page}"
echo "Request: ${url}" >&2
curl --silent \
-H "X-DocBaseToken: ${DOCBASE_TOKEN}" \
-H 'X-Api-Version: 2' \
"${url}"
}
printf "\n"
request 20 500 | cut -c 1-16
printf "\n"
request 20 501
printf "\n\n"
request 50 200 | cut -c 1-16
printf "\n"
request 50 201
printf "\n\n"
request 100 100 | cut -c 1-16
printf "\n"
request 100 101
printf "\n\n"
$ bash docbase_api.sh
Request: https://api.docbase.io/teams/connehito/posts?per_page=20&page=500
{"posts":[{"id":
Request: https://api.docbase.io/teams/connehito/posts?per_page=20&page=501
500 Internal Server Error
If you are the administrator of this website, then please read this web application's log file and/or the web server's log file to find out what went wrong.
Request: https://api.docbase.io/teams/connehito/posts?per_page=50&page=200
{"posts":[{"id":
Request: https://api.docbase.io/teams/connehito/posts?per_page=50&page=201
500 Internal Server Error
If you are the administrator of this website, then please read this web application's log file and/or the web server's log file to find out what went wrong.
Request: https://api.docbase.io/teams/connehito/posts?per_page=100&page=100
{"posts":[{"id":
Request: https://api.docbase.io/teams/connehito/posts?per_page=100&page=101
500 Internal Server Error
If you are the administrator of this website, then please read this web application's log file and/or the web server's log file to find out what went wrong.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment