Skip to main content

buttercms-python - 2.1.1

Python Library for ButterCMS API.

Documentation

For a comprehensive list of examples, check out the API documentation.

Jump to:

Installation

Install from PyPi using pip, a package manager for Python.

pip install buttercms-python

Usage

Getting started with the ButterCMS API couldn't be easier. Use your authorization token to create a ButterCMS client.

from butter_cms import ButterCMS

auth_token = "XXXXXXXXXXXXXXXXXXX"
client = ButterCMS(auth_token)

All methods return dictionaries. The data can be navigated using keys and indexes like the example below.

response = client.posts.all()

posts = response['data'] 
# posts now contains a list of post dictionaries

my_post = posts[0]
# my_post contains the first returned post

print(my_post)
# {
#   "url": "http://www.example.com/blog/this-is-a-blog-post",
#   "created": "2015-06-12T13:59:32.441289Z",
#   "published": "2015-06-12T00:00:00Z",
#   ...
# }

Pages

The Page's .all(), .get() and .search() methods accept an optional params to add additional data to the response.

client.pages.all('news')

# Optional params
client.pages.all('news', {'foo': 'bar'})
client.pages.get('news', 'hello-world')

# Optional params
client.pages.get('news', 'hello-world', {'foo': 'bar'})
client.pages.search('enter search query', {'page': 1, 'page_size': 10})

To Top

Collections

For a list of params see the API documentation

.get() method accepts an optional params dict to add additional data to the response.

client.content_fields.get(['collection_key'], {'locale': 'en'})

To Top

Blog Engine

Posts

client.posts.all({'page_size': 3, 'page': 1, 'exclude_body': 'true'})
client.posts.get('hello-world')
client.posts.search('query', {'page': 1, 'page_size': 10})

Authors

The Author's .all() and .get() methods accept an optional params to add additional data to the response.

  • {'include':'recent_posts'}: Adds each author's posts under the recent_posts key in that author's returned dictionary
client.authors.all()
client.authors.all({'include':'recent_posts'})
client.authors.get('jennifer-smith')
client.authors.get('jennifer-smith', {'include':'recent_posts'})

To Top

Categories

The Category's .all() and .get() methods accept an optional params to add additional data to the response.

  • {'include':'recent_posts'}: Adds posts tagged with that category under the recent_posts key in that category's returned dictionary
client.categories.all()
client.categories.all({'include':'recent_posts'})
client.categories.get('product-updates')
client.categories.get('product-updates', {'include':'recent_posts'})

To Top

Tags

The Tag's .all() and .get() methods accept an optional params to add additional data to the response.

  • {'include':'recent_posts'}: Adds posts tagged with that tag under the recent_posts key in that tag's returned dictionary
client.tags.all()
client.tags.all({'include':'recent_posts'})
client.tags.get('product-updates')
client.tags.get('product-updates', {'include':'recent_posts'})

To Top

Feeds

client.feeds.get('rss')
client.feeds.get('atom')
client.feeds.get('sitemap')

To Top

Other

View Python Blog engine and Full CMS for other examples of using ButterCMS with Python.

Tests

To run tests:

python -m unittest butter_cms/unit_tests.py

Metadata

Release files for buttercms-python 2.1.1

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

Source distribution (sdist)

Source distribution for buttercms-python 2.1.1
File Size Uploaded Provenance
buttercms_python-2.1.1.tar.gz 7.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for buttercms-python 2.1.1
File Interpreter ABI Platform
buttercms_python-2.1.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 15.6 kB

Release files / buttercms_python-2.1.1.tar.gz

Download URL buttercms_python-2.1.1.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
284aec079918a41df09eb3896e1136d38c9ffae268821b999c9e8101dc912c04
BLAKE2b-256 checksum
How to use checksums
8524965b4d355952b6f7111b983afa656dde81978527b6c3f58b456a36fd7b31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / buttercms_python-2.1.1-py2.py3-none-any.whl

Download URL buttercms_python-2.1.1-py2.py3-none-any.whl
Size 8.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
236e89da58554ea7ad2e92b4d3204e33901089bc2450e4ed2f22eee67301f5bf
BLAKE2b-256 checksum
How to use checksums
0aca11655b2d2ad329bd54dbaff47f0376e077a83909ff1364aa0f54e5b2782e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Security for buttercms-python 2.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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