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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsonfeed_util-1.1.4.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jsonfeed_util-1.1.4-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file jsonfeed_util-1.1.4.tar.gz.

File metadata

  • Download URL: jsonfeed_util-1.1.4.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.4

File hashes

Hashes for jsonfeed_util-1.1.4.tar.gz
Algorithm Hash digest
SHA256 ae4ad1bb8a3dad2172939d6b18c4121cce7c1021e3693e669d2c95ddfa04c36f
MD5 c11435e83c143616e5c545bf7993bc76
BLAKE2b-256 68e2fb797764efcaa3977a965c55cc234b568ec6f2f7a8ddd1423668eb83e18e

See more details on using hashes here.

File details

Details for the file jsonfeed_util-1.1.4-py3-none-any.whl.

File metadata

  • Download URL: jsonfeed_util-1.1.4-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.4

File hashes

Hashes for jsonfeed_util-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4762fb0e29c9fae15cd42f6153af524bb608dd8af0eecfdd803eedc8f35d7763
MD5 3c35bd45478ca671e442aeaf6b14a9f5
BLAKE2b-256 1da6877d5bcbb93ef1daf705debf259ad905cce407fa313c1510766c3fa1ebc7

See more details on using hashes here.

Release history Release notifications | RSS feed

1.2.0

2 files

This release

1.1.4 This release

2 files

1.1.3

1 file

1.1.2

1 file

1.1.1

1 file

1.1.0

1 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