LoginSignup
4
2

More than 5 years have passed since last update.

NHK番組表apiのrubyクライアントでV2 APIを叩く

Last updated at Posted at 2017-02-25

ふと思い立って、岩合光昭の世界ネコ歩きの放送予定をカレンダーを作ってみた。

調べてみると、NHK 番組表 APIが公開されていて、さらにそれに対応したruby クライアントも公開されていた。
めっちゃ助かりますね。

で、早速APIキーを取得して本日から1週間先の番組表を取得・・・ってやると、3日先からBad Requestになってしまう。
原因はnhk_programがV1のAPIを利用していることでした。

V1とV2の番組表APIはendpointが違うだけで仕様自体は変わってないようなのでnhk_programが使うendpointを変更して対応。

無事に1週間先まで取れました。

nhkclient.rb
client = NHKProgram.new(
                api_key: hogehogehoge
                endpoint: 'http://api.nhk.or.jp/v2/pg')
4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2