Zenodo access [“metadata”][“description”] [duplicate]

this piece of code returns records from zenodo with no problem

import requests
import json

records_api_url = 'https://zenodo.org/api/records'
search_query = 'grants.acronym:DIGITAF AND resource_type.type:publication'
res = requests.get(records_api_url, params={'q': search_query, 'size': 10000})
for i in res.json()["hits"]["hits"]:
    print(i["metadata"], "n" )

returning about 20 hits (dictionaries), one of them, as example here:

{
    "title": "Agroforestry & the Framework for Certification of Carbon Removals",
    "doi": "10.5281/zenodo.7828353",
    "publication_date": "2022-12-31",
    "description": "<p>Policy Briefing #20 welcomes the draft CRCF, and its initial proposals for robust certification of carbon removals including a) quality criteria, b) verification and certification, c) functioning of certification schemes.  However we feel that rigorous certification is only needed for a subset of specialised
 carbon farming schemes.  There is much more to be done, in the near term, to meet the aspirational target of the December 2021 “Sustainable Carbon Cycles Communication” that “by 2028 every land manager should have access to verified emission and removal data”.  EURAF believes that high quality emissions estimates by Member States (IPCC Tier 3) should be combined with detailed wall-to-wall representation of land use (IPCC Approach 3), and results should be available open source to farmers and foresters.  High-resolution databases of net emissions across the forestry and agricultural sectors will facilitate a target of net zero emissions in the integrated land sector by 2035. These improvements by MS should proceed in parallel with amendment and ratification of the CRCF.</p>",
    "access_right": "open",
    "creators": [
        {
            "name": "LAWSON, Gerry",
            "affiliation": "EURAF",
            "orcid": "0000-0002-1395-3092"
        }
    ],
    "keywords": [
        "carbon farming",
        "agroforestry",
        "DigitAF"
    ],
    "version": "1",
    "resource_type": {
        "title": "Working paper",
        "type": "publication",
        "subtype": "workingpaper"
    },
    "license": {
        "id": "cc-by-4.0"
    },
    "grants": [
        {
            "code": "101059794",
            "internal_id": "10.13039/501100000780: : 101059794",
            "funder": {
                "name": "European Commission",
                "doi": "10.13039/501100000780",
                "acronym": "EC"
            },
            "title": "DIGItal Tools to help AgroForestry meet climate, biodiversity and farming sustainability goals: linking field and cloud",
            "acronym": "DIGITAF",
            "program": "HE",
            "url": "https: //cordis.europa.eu/projects/101059794"
        }
    ],
    "communities": [
        {
            "id": "euraf"
        },
        {
            "id": "eu"
        }
    ],
    "relations": {
        "version": [
            {
                "index": 0,
                "is_last": True,
                "parent": {
                    "pid_type": "recid",
                    "pid_value": "7828352"
                }
            }
        ]
    },
    "notes": "EURAF Policy Briefing #20"
}

I have no problem accessing the title from this dict with

print(i["metadata"]["title"], "n" )

However, when trying accessing the description with

print(i["metadata"]["description"], "n" )

returns a “KeyError: ‘description'” which is puzzling me. What am I missing?

print(i["metadata"]["title"] # works fine
print(i["metadata"]["doi"] # works fine
print(i["metadata"]["publication_date"] # works fine

print(i["metadata"]["description"] # DOES NOT WORK -> triggers a KeyError: 'description'

4

Thanks to @mkrieger and @larsks the problem can be turned around by getting the key value, when there is actually the key (So this is actually a duplicate from a “normal key error” question). Anyway here’s the piece with getting the key value when the key exists:

import requests
import json

records_api_url = 'https://zenodo.org/api/records'
search_query = 'grants.acronym:DIGITAF AND resource_type.type:publication'
res = requests.get(records_api_url, params={'q': search_query, 'size': 10000})
for i in res.json()["hits"]["hits"]:
    print(i["metadata"].get("description", "no description available"))

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật