如何从格子 api 中获取 "Item" 的徽标?

How can I get the logo for an "Item" from the Plaid api?

我查看了 API 文档,但没有看到任何有关如何获取徽标的信息,但格子呢在 link 应用程序中显然有它们。有什么方法可以让我作为 API 的一部分或通过使用 "Item" id 的其他机制访问这些徽标?

虽然在撰写本文时尚未记录,但显然可以通过向机构请求添加值为 {"include_display_data": true} 的选项参数来完成。对于使用 getInstitutionById 方法的节点 API 和 Vangaurd,它看起来像这样。

client.getInstitutionById('ins_108768', {include_display_data: true} (err, result) => {
 // Handle err
 const logo = result.institution.logo;
});

logo 的值为 null 或包含 logo 二进制数据的 base64 编码字符串。

格子的当前版本 ruby gem(6.1.0) 不检索徽标,但您可以扩展格子库并使用 include_display_data 参数来获取徽标徽标。

module Plaid
  class Institutions < BaseProduct

    def get_by_id_with_logo(institution_id)
      post_with_public_key 'institutions/get_by_id',
                           SingleInstitutionResponse,
                           institution_id: institution_id,
                           options: { include_display_data: true }
    end
  end
end

用法:

ins = client.institutions.get_by_id_with_logo(YOUR_INSTITUTION_ID)
puts ins.institution[:logo]

要从 Plaid API 获取所有机构的列表,需要使用 POST 请求点击 /institutions/get。要获取徽标和其他机构属性,例如主页 URL 和品牌颜色,需要在请求正文中添加 options 属性,其中键=>值对 "include_optional_metadata" =>真的。 count 参数表示您希望返回的机构数(每页),而 offset 是要跳过的机构数。

curl -X POST \
https://sandbox.plaid.com/sandbox/institutions/get \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
        "client_id": "clientIdFromPlaidDashboard",
        "secret": "secretFromPlaidDashboard",
        "count": 500,
        "offset": 0,
        "options" => [
            "include_optional_metadata" => true
         ]
    }'

格子文档的预期响应:

http code 200
{
  "institutions": [
    {
      "country_codes": ["US"],
      "credentials": [{
        "label": "User ID",
        "name": "username",
        "type": "text"
       }, {
        "label": "Password",
        "name": "password",
        "type": "password"
      }],
      "has_mfa": true,
      "institution_id": "ins_109508",
      "mfa": [
        "code",
        "list",
        "questions",
        "selections"
      ],
      "name": "First Platypus Bank",
      // the following are included when
      // options.include_optional_metadata is true
      "primary_color": "#1f1f1f",
      "url": "https://plaid.com",
      "logo": null,
      ]
    }
  ],
  "request_id": "m8MDnv9okwxFNBV",
  "total": 1
}