Skip to main content

jsonfeed

PyPI GitHub Workflow Status (branch) Full package documentation

jsonfeed is a Python package for parsing and constructing JSON Feeds. It explicitly supports JSON Feed Version 1.1.

Usage

This package's constructor arguments and class variables exactly match the field names defined in the JSON feed spec. I hope that the code is clear enough that the spec can be its granular documentation.

Installation

Install this package with pip:

$ pip install jsonfeed-util

In your Python code, include the line

import jsonfeed

Parsing a JSON feed

import jsonfeed as jf
import requests

# Requesting a valid JSON feed!
r = requests.get('https://arxiv-feeds.appspot.com/json/test')
# Parse from raw text...
feed_from_text = jf.Feed.parse_string(r.text)
# ...or parse JSON separately.
r_json = r.json()
feed_from_json = jf.Feed.parse(r_json)

Constructing a JSON feed

import jsonfeed as jf

me = jf.Author(
  name="Lukas Schwab",
  url="https://github.com/lukasschwab"
)
feed = jf.Feed("My Feed Title", authors=[me])
item = jf.Item("some_item_id")
feed.items.append(item)

print(feed.to_json())

jsonfeed exposes constructors for five classes of JSON feed objects:

  • Feed
  • Author
  • Hub
  • Item
  • Attachment

Note, jsonfeed is designed to be minimally restrictive. It does not require fields that are not required in the JSON Feed spec. This means it's possible to construct non-meaningful JSON feeds (e.g. with this valid Author object: {}).

Examples

Deprecations

See the spec for an overview of deprecated JSON Feed fields. This project (especially the converters and the parsing functions) will stay backwards-compatible when possible, but using deprecated fields when constructing feeds is discouraged.

JSON Feed 1.1

  • Feed.author is deprecated. Use Feed.authors.
  • Item.author is deprecated. Use Item.authors.

Notes

  • Dictionaries maintain insertion order as of Python 3.6. jsonfeed takes advantage of this to retain the order suggested in the JSON Feed spec (namely, that version appear at the top of the JSON object). This order may not be enforced in earlier versions of Python, but out-of-order JSON Feeds are not invalid.

  • I made a conscious decision to shoot for code that's readable––vis à vis the JSON Feed spec––rather than code that's minimal or performant. Additionally, I opted to avoid dependencies outside of the standard library. Hopefully this makes for easy maintenance.

Release files for jsonfeed-util 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jsonfeed-util 1.2.0
File Size Uploaded
jsonfeed_util-1.2.0.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jsonfeed-util 1.2.0
File Interpreter ABI Platform
jsonfeed_util-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.1 kB

Release files / jsonfeed_util-1.2.0.tar.gz

Download URL jsonfeed_util-1.2.0.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8917d46be216f2773124e0e45e6bc72a1a939666a1ee2b010371ac1e3e86770c
BLAKE2b-256 checksum
How to use checksums
66d06e3c2efef82e1794c2a27549ed8f72edeb080764570cff6d7b185647095d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / jsonfeed_util-1.2.0-py3-none-any.whl

Download URL jsonfeed_util-1.2.0-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ecdb6deacbc5a3979d871d07c17e85e0809f537a451cc2e35d2f8901e0311371
BLAKE2b-256 checksum
How to use checksums
2594f574bb0e053ffbc49b610de6e35a71ab43e7dff095bcd7504598b250bb55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.4

2 release files

1.1.3

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page