LoginSignup
11
6

More than 1 year has passed since last update.

はじめに

最近読んだ「技術書」の読書術 達人が教える選び方・読み方・情報発信&共有のコツとテクニック という本から、本から学ぶ方法を改めようと感じたので、Notionを活用することにしました。

Notionで読書データベース

image.png

ただ本を読んだ後、メモのために入力する情報が多い・・・、
そこで!!
「Power Apps」+「Google Books API」を使ったバーコードリーダーアプリを作ってみました!
記録の利便性を上げます。

Power Apps

Power Appsでは、バーコードの読み取り機能を持たせることが出来ます。

この機能で 「ISBNコード」 を本のバーコードから読み取ることができました。

ISBNは、13桁からなるコード番号によってあらわされ、書籍出版物の書誌を特定することができます。

書籍出版流通とISBNの利便性

このコードを利用して情報を拾うAppsの作成をしてみます。

バーコードリーダーで使えるAPIの例

Power Appsでは「バーコードーリーダー」機能で、バーコードの情報を拾うことができますが、
拾う情報は数字・文字列の羅列に留まります。

このコードをキーにして情報を取得するのは、別のデータソースが必要です。
何らかのAPIを利用し、情報を取得する必要があります。

今回は「本の情報」がテーマですので、何が使えるかざっくり調べたところ、下記のAPIが出揃いました

  • Yahoo!ショッピング商品検索(v3)

  • Product Advertising API (Amazon Web Services)

  • 楽天商品検索API (Rakuten Developers)

  • 国立国会図書館サーチAPI

  • Google Books API

参考

2.WebAPIで検索する方法(種類)

MotoJapan's Tech-Memo


検証

今回の目的は「書籍情報」の取得です。

書籍における

  • タイトル
  • 著者
  • 出版社

こういった情報を取得できることが目的になります。

Yahoo!ショッピング商品検索(v3)の場合

入りやすさ: ★★★★☆
ギークフジワラさんのBlogもとい動画が参考になるので載せます。

  • メリット
    Web APIを利用するための準備がとてもラク! Yahoo! JAPAN ID + 簡単な登録作業で利用可能!

  • デメリット
    Yahoo!ショッピングの情報をもとにしていて、正確なタイトルや情報が取りづらい。
    【期間限定 ~ 】といった商品見出しの情報が対象になるので統一感がない。

国立国会図書館サーチAPI

入りやすさ: ★★★★★
GETメソッドであれば、すぐに試すことができます。
せっかくなので紹介させていただいた本を検索するイメージを載せます。

  • Power Automate
    image.png

  • Python

JapanLibraryAPI
import requests

params = {
        'operation':'searchRetrieve',
        'query':'isbn=9784798171548',
        'recordPacking':'xml'
        } 

url = 'https://iss.ndl.go.jp/api/sru'

res = requests.post(url, params=params)
print(res.text)

戻り値がXMLなことが最初は残念でしたがjson(**値**)ですぐに変換できるので、PowerAutomate恐るべし・・・。
検証はCUIが好きよ!という方はPythonでもGoogle Apps Scriptでも上記のような簡素なコードで検証できるので、試してみてください。

筆者としては「戻り値のFormatがなぁ~・・・」というところだけです。

  <dc:title>「技術書」の読書術 : 達人が教える選び方・読み方・情報発信&amp;共有のコツとテクニック</dc:title>
  <dc:creator>IPUSIRON, 増井敏克 著</dc:creator>

・・・チョッッ・・・

書籍のデータ量ならNo.1とのことですが、、、ううむ。

Google Books API

Google Cloud PlatformでAPIキーの取得が必要だろうな・・・、
と思いきや!!!

「GET」であればAPIキー不要!!

ちなみにAPIキー必要なGoogle Booksのカスタムコネクタ発表されていました

APIを呼び出す方法はとても簡単
GETでURLを設定するだけ!

入りやすさ: ★★★★★

GoogleBooksSample
import requests

url = 'https://www.googleapis.com/books/v1/volumes?q=isbn:9784798171548'

res = requests.get(url)
print(res.text)
## 戻り値はJSON ## 下記の通り ##
{
  "kind": "books#volumes",
  "totalItems": 1,
  "items": [
    {
      "kind": "books#volume",
      "id": "7wRezwEACAAJ",
      "etag": "6Ikp943oLKM",
      "selfLink": "https://www.googleapis.com/books/v1/volumes/7wRezwEACAAJ",
      "volumeInfo": {
        "title": "「技術書」の読書術達人が教える選び方・読み方・情報発信&共有のコツとテクニック",
        "authors": [
          "IPUSIRON",
          "増井敏克"
        ],
        "publishedDate": "2022-11-04",
        "description": "おそらく本邦初、「技術書(コンピュータ書)」の読書術を指南する本がついに登場。表も裏も知り尽くした人気作家2名が教えます。",
        "industryIdentifiers": [
          {
            "type": "ISBN_10",
            "identifier": "4798171549"
          },
          {
            "type": "ISBN_13",
            "identifier": "9784798171548"
          }
        ],
        "readingModes": {
          "text": false,
          "image": false
        },
        "pageCount": 0,
        "printType": "BOOK",
        "maturityRating": "NOT_MATURE",
        "allowAnonLogging": false,
        "contentVersion": "preview-1.0.0",
        "panelizationSummary": {
          "containsEpubBubbles": false,
          "containsImageBubbles": false
        },
        "imageLinks": {
          "smallThumbnail": "http://books.google.com/books/content?id=7wRezwEACAAJ&printsec=frontcover&img=1&zoom=5&source=gbs_api",
          "thumbnail": "http://books.google.com/books/content?id=7wRezwEACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api"
        },
        "language": "ja",
        "previewLink": "http://books.google.co.jp/books?id=7wRezwEACAAJ&dq=isbn:9784798171548&hl=&cd=1&source=gbs_api",
        "infoLink": "http://books.google.co.jp/books?id=7wRezwEACAAJ&dq=isbn:9784798171548&hl=&source=gbs_api",
        "canonicalVolumeLink": "https://books.google.com/books/about/%E6%8A%80%E8%A1%93%E6%9B%B8_%E3%81%AE%E8%AA%AD%E6%9B%B8%E8%A1%93%E9%81%94%E4%BA%BA%E3%81%8C%E6%95%99%E3%81%88%E3%82%8B.html?hl=&id=7wRezwEACAAJ"   
      },
      "saleInfo": {
        "country": "JP",
        "saleability": "NOT_FOR_SALE",
        "isEbook": false
      },
      "accessInfo": {
        "country": "JP",
        "viewability": "NO_PAGES",
        "embeddable": false,
        "publicDomain": false,
        "textToSpeechPermission": "ALLOWED",
        "epub": {
          "isAvailable": false
        },
        "pdf": {
          "isAvailable": false
        },
        "webReaderLink": "http://play.google.com/books/reader?id=7wRezwEACAAJ&hl=&source=gbs_api",
        "accessViewStatus": "NONE",
        "quoteSharingAllowed": false
      },
      "searchInfo": {
        "textSnippet": "技術書の表も裏も知り尽くした人気作家が教えます。"
      }
    }
  ]
}
  • 使いやすさ
  • 情報量
  • 美しさ

サムネイルまで拾えるとは、凄すぎる!!!
それで一番簡単だなんて使うしかない!!

Google Books API 君に決めた!


Power Automateで実践してみる

1. HTTPで単純に実行するパターン

image.png

HTTP以降は必要な情報をJSONから選択しているだけの単純なプロセスです。
Jsonの構造を見て、値を抽出するプロセスになります。

それらしく言ってますが最近までお作法を理解していなかったので、こちらのブログをオススメします。

さて、もう少し視座を上げて、これをカスタムコネクタにしてみましょう!

2. カスタムコネクタを構築してみるパターン

詳細はlearnを見ましょう!

parameter Value
host googleapis.com
  • swaggerコード
Google Books Search
swagger: '2.0'
info:
  title: Google Books Search
  description: >-
    This will be a custom connector for using Google Books API without
    authentication.

    The query is freely configurable, but the assumption is that it will be an
    ISBN code.
  version: '1.0'
host: www.googleapis.com
basePath: /
schemes:
  - https
consumes: []
produces: []
paths:
  /books/v1/volumes:
    get:
      responses:
        default:
          description: default
          schema:
            type: object
            properties:
              totalItems:
                type: integer
                format: int32
                description: Total hits in search
                title: TotalItems
              items:
                type: array
                items:
                  type: object
                  properties:
                    kind:
                      type: string
                      description: kind or contents
                      title: Kind
                    id:
                      type: string
                      description: id
                      title: Id
                    etag:
                      type: string
                      description: etag
                      title: Etag
                    selfLink:
                      type: string
                      description: API Links
                      title: API Links
                    volumeInfo:
                      type: object
                      properties:
                        title:
                          type: string
                          description: Title of Item
                          title: Title
                        authors:
                          type: array
                          items:
                            type: string
                          description: authors
                          title: Authors
                        publisher:
                          type: string
                          description: publisher
                          title: Publisher
                        publishedDate:
                          type: string
                          description: Date of Publication
                          title: PublishedDate
                        description:
                          type: string
                          description: Description of contents
                          title: Description
                        industryIdentifiers:
                          type: array
                          items:
                            type: object
                            properties:
                              type:
                                type: string
                                description: type
                              identifier:
                                type: string
                                description: 13-digit ISBN number
                          description: ISBN Codes
                        readingModes:
                          type: object
                          properties:
                            text:
                              type: boolean
                              description: text Data format for reading
                              title: ''
                              x-ms-visibility: advanced
                              enum:
                                - ''
                                - 'true'
                                - 'false'
                            image:
                              type: boolean
                              description: image Data format for reading
                              title: ''
                              x-ms-visibility: advanced
                              enum:
                                - ''
                                - 'true'
                                - 'false'
                          description: Data format for reading
                        pageCount:
                          type: integer
                          format: int32
                          description: pageCount
                          title: PageCount
                        printType:
                          type: string
                          description: printType
                          title: PrintType
                        maturityRating:
                          type: string
                          description: Rating
                          title: Rating
                        contentVersion:
                          type: string
                          description: contentVersion
                          title: ContentVersion
                        imageLinks:
                          type: object
                          properties:
                            smallThumbnail:
                              type: string
                              description: smallThumbnail
                              title: Link of SmallThumbnail
                            thumbnail:
                              type: string
                              description: thumbnail
                              title: Link of Thumbnail
                          description: imageLinks
                        language:
                          type: string
                          description: language
                          title: Language
                        previewLink:
                          type: string
                          description: previewLink
                          title: Preview Link
                        infoLink:
                          type: string
                          description: infoLink
                          title: Information Link
                        canonicalVolumeLink:
                          type: string
                          description: canonicalVolumeLink
                          title: CanonicalVolumeLink
                          x-ms-visibility: advanced
                      description: volumeInfo
                    saleInfo:
                      type: object
                      properties:
                        country:
                          type: string
                          description: Country of publication
                          title: Country
                      description: saleInfo
                    accessInfo:
                      type: object
                      properties:
                        country:
                          type: string
                          description: country of accessInfo
                          title: country of accessInfo
                          x-ms-visibility: internal
                        viewability:
                          type: string
                          description: Range of readability
                          title: ViewAbility
                        pdf:
                          type: object
                          properties:
                            isAvailable:
                              type: boolean
                              description: Available in PDF version
                              title: isAvailable PDF
                              enum:
                                - ''
                                - 'true'
                                - 'false'
                            acsTokenLink:
                              type: string
                              description: acsTokenLink
                              title: ''
                              x-ms-visibility: internal
                          description: PDF Information
                      description: accessInfo
                description: items
      summary: Get Volume
      description: >-
        The connector uses the Google Books API with no authentication required.
        It is a specification that returns information on books by ISBN code.
      operationId: GetBookInformation
      parameters:
        - name: q
          in: query
          required: true
          type: string
          default: 'isbn:'
          description: ISBN codes 13
          x-ms-summary: ISBN codes 13
definitions: {}
parameters: {}
responses: {}
securityDefinitions: {}
security: []
tags: []

実際にカスタムコネクタ構築画面を見ながら作ってみたほうが身になると思います。

コネクタを作成することで、自分が取得したい情報を選びやすくできるメリットがあります。
JSONのキーを覚えるということは結構な負担なので、一旦コネクタを作り、視認性を高めることで、継続的にこのAPIを活かすことが出来ます。

フロー

image.png

Power AppsのScan情報を受け取り、値を返すフローです。
これを実装することで

  1. Scan
    image.png

  2. Google Books APIから情報取得
    image.png

  3. Power Appsに表現
    image.png

いい感じにできました!
達成感がとても凄いです!Happy!

今ではタダのバーコード検索アプリなので、書評や情報を追加するDBへのPOST機能も必要です。
Notion APIにチャレンジ中・・・

自分の生活を楽にしつつ、学びを深める。いいですね!
今後もチャレンジしていきたいと思います!

Power !

11
6
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
11
6