Nature Remo APIを使ってChatGPTに接続家電一覧を取得してもらおう

WebAPIとか認証とか使った事殆ど無いから結構こけたわ

 

 

1

https://home.nature.globa

 

ここでトークンを発行する

 

 

2

ChatGPTの設定 アクション

認証をAPI Bearerとして「1」で取得したトークンをペースト

Nature Remo APIはOAuth 2.0認証だからこっちを使うのになかなか気づかなかった

 

 

3

YAMLで接続機器の一覧を表示するコードを書くというよりGPTに出してもらう

openapi: 3.0.3
info:
  title: Nature Remo API for Appliances
  version: 1
servers:
  - url: https://api.nature.global
paths:
  /1/appliances:
    get:
      summary: Fetch a list of registered appliances
      operationId: getAppliances
      responses:
        "200":
          description: Successfully retrieved the list of appliances
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Appliance"
        "401":
          description: Unauthorized - Invalid access token
components:
  securitySchemes:
    bearerAuth:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: https://api.nature.global/oauth2/token
          scopes: {}
  schemas:
    Appliance:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the appliance
        type:
          type: string
          description: Type of the appliance
        nickname:
          type: string
          description: User-defined name of the appliance
    Dummy:
      type: object
      properties:
        dummyField:
          type: string
          description: This is a dummy field to avoid schema object errors
security:
  - bearerAuth: []

 

 

3.5

なんかアクション設定で警告表示でオブジェクトがないとか言われるのでググった

OpenAIのフォーラムでダミーオブジェクトを設定すると動くよとあったのでそのための

 

    Dummy:
      type: object
      properties:
        dummyField:
          type: string
          description: This is a dummy field to avoid schema object errors

 

 

 

4

テストする

変なところがなければ出力されるはず

 

 

5

完成

 

 

特に何ができるわけでもないがNature Remo APIとChatGPT連携の足がかりとして

今後何をさせましょうかね