Closed3

ZennのCLI, APIなどについて調査する🌟

まさぴょんまさぴょん

Zennの記事一覧を取得する方法

  1. RSSを活用する方法

    • https://zenn.dev/ユーザー名/feed?all=1
    • 上記のような形で、そのユーザーの記事情報をすべて取得することができる (RSS形式)
  2. 非公式のZenn APIを使用する方法

    • https://zenn.dev/api/articles?username=ユーザー名&order=latest
    • 上記のような形で、RSS形式で、そのユーザーの記事情報を取得することができる (JSON形式)

JSON形式で、自分のZennの記事を取得する

  • https://zenn.dev/api/articles?username=manase&order=latest

https://zenn.dev/api/articles?username=manase&order=latest

  • json で取得できたのは、48 件

  • 2/4 時点で 記事は、57 件を公開中 なので、おそらくページネーションされている API だと思われる

  • 1 ページの上限は、48?

  • JSONの最後に、"next_page": 2 とあるので、ページネーションだと思われる。

  • 試しに、QueryParameter に page を追加してみたら、ページネーション設定ごとに、記事一覧を取得できた。

    • https://zenn.dev/api/articles?username=manase&order=latest&page=1
      • "next_page":2 になっている

https://zenn.dev/api/articles?username=manase&order=latest&page=1

  • https://zenn.dev/api/articles?username=manase&order=latest&page=2
    • "next_page":null になっている

https://zenn.dev/api/articles?username=manase&order=latest&page=2

RSSとして、自分のZennの記事をすべて取得する

  • https://zenn.dev/ユーザー名/feed?all=1

https://zenn.dev/manase/feed?all=1

参考・引用

https://zenn.dev/catnose99/articles/cb72a73368a547756862#comment-de8c8e9f253aa4

https://zenn.dev/niiharamegumu/articles/8f00cfdf9753d1

https://zenn.dev/h_ymt/articles/5e44b4967f6764

https://zenn.dev/ayousanz/scraps/6ad79260ccd86c

このスクラップは3ヶ月前にクローズされました