Categories
Archives

IPTC’s Python library for creating manipulating and managing NewsML-G2 documents, python-newsmlg2, has reached version 1.0.
The earliest versions of the library were created back in 2021, but the code has seen significant changes over that period and we are happy to endorse the latest version as a production-ready 1.0 release.
Created as free, open source library that can be integrated into any Python code, the library supports all parts of the NewsML-G2 specification:
- multi-media news stories (NewsItem)
- packages of news content (PackageItem)
- planned news coverage and information about upcoming and past events (PlanningItem and EventsML-G2)
- news content classification concepts and sets of concepts (knowledge graphs) (ConceptItem, KnowledgeItem and CatalogItem)
- syndicated news content transactions (NewsMessage)

The 1.0 version has 98% unit test coverage, which can give users confidence that future changes will not introduce regression bugs.
The code can also handle non-NewsML-G2 content embedded within NewsML-G2 files using XML Schema’s “xs:any” construct. This is a feature of NewsML-G2 that allows any type of markup, such as but not limited to XHTML, NITF or RightsML, to be carried as the payload in a NewsML-G2 NewsItem. The 1.0 version adds “round-trip” support of all xs:any constructs allowing additional markup to be captured, retained and output verbatim, without any loss of fidelity.
The library’s documentation also gives examples of how the library can be used to create, process, manipulate and output NewsML-G2 documents.
The code offers some “helper functions” that make working with NewsML-G2 easier, such as:
- Automatic resolution between QCodes and URIs, two equivalent formats for controlled vocabulary terms, that can now be used interchangeably. The code uses NewsML-G2 Catalogs to look up QCode prefixes and resolve them to URI format.
- Automatic handling of repeatable items and traversal of the NewsML-G2 element structure to provide easy access to child elements such as “
digsrctype = newsitem.contentmeta.digitalsourcetype.uri“
The library can be installed by any Python user using PyPI: pip install newsmlg2.
The source code of the library is freely available, licensed under the open-source MIT licence, at https://github.com/iptc/python-newsmlg2.
Feedback on the library is very welcome. Please let us know what you think on the IPTC Contact Us page or the public NewsML-G2 discussion list.
Categories
Archives
- December 2025
- November 2025
- October 2025
- September 2025
- August 2025
- July 2025
- June 2025
- May 2025
- April 2025
- March 2025
- February 2025
- January 2025
- December 2024
- November 2024
- October 2024
- September 2024
- August 2024
- July 2024
- June 2024
- May 2024
- April 2024
- March 2024
- February 2024
- December 2023
- November 2023
- October 2023
- September 2023
- August 2023
- July 2023
- June 2023
- May 2023
- March 2023
- February 2023
- January 2023
- December 2022
- November 2022
- October 2022
- September 2022
- August 2022
- July 2022
- June 2022
- May 2022
- April 2022
- March 2022
- February 2022
- January 2022
- December 2021
- November 2021
- October 2021
- September 2021
- August 2021
- July 2021
- June 2021
- May 2021
- April 2021
- February 2021
- December 2020
- November 2020
- October 2020
- September 2020
- August 2020
- July 2020
- June 2020
- May 2020
- April 2020
- March 2020
- February 2020
- December 2019
- November 2019
- October 2019
- September 2019
- July 2019
- June 2019
- May 2019
- April 2019
- February 2019
- November 2018
- October 2018
- September 2018
- August 2018
- July 2018
- June 2018
- May 2018
- April 2018
- March 2018
- January 2018
- November 2017
- October 2017
- September 2017
- August 2017
- June 2017
- May 2017
- April 2017
- December 2016
- November 2016
- October 2016
- September 2016
- August 2016
- July 2016
- June 2016
- May 2016
- April 2016
- February 2016
- January 2016
- December 2015
- November 2015
- October 2015
- September 2015
- June 2015
- April 2015
- March 2015
- February 2015
- November 2014