# buttercms-python
Python Library for ButterCMS API.
## Documentation
For a comprehensive list of examples, check out the [API documentation](https://buttercms.com/docs/api/).
## Jump to:
* [Pages](#pages)
* [Collections](#collections)
* [Posts](#posts)
* [Authors](#authors)
* [Categories](#categories)
* [Feeds](#feeds)
## Installation
Install from PyPi using [pip](http://www.pip-installer.org/en/latest/), 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.
```python
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.
```python
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.
```python
client.pages.all('news')
# Optional params
client.pages.all('news', {'foo': 'bar'})
```
```python
client.pages.get('news', 'hello-world')
# Optional params
client.pages.get('news', 'hello-world', {'foo': 'bar'})
```
```python
client.pages.search('enter search query', {'page': 1, 'page_size': 10})
```
[To Top](#buttercms-python)
### Collections
For a list of params see the [API documentation](https://buttercms.com/docs/api/?python#collections)
.get() method accepts an optional `params` dict to add additional data to the response.
```python
client.content_fields.get(['collection_key'], {'locale': 'en'})
```
[To Top](#buttercms-python)
### Blog Engine
#### Posts
```python
client.posts.all({'page_size': 3, 'page': 1, 'exclude_body': 'true'})
```
```python
client.posts.get('hello-world')
```
```python
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
```python
client.authors.all()
client.authors.all({'include':'recent_posts'})
```
```python
client.authors.get('jennifer-smith')
client.authors.get('jennifer-smith', {'include':'recent_posts'})
```
[To Top](#buttercms-python)
#### 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
```python
client.categories.all()
client.categories.all({'include':'recent_posts'})
```
```python
client.categories.get('product-updates')
client.categories.get('product-updates', {'include':'recent_posts'})
```
[To Top](#buttercms-python)
#### 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
```python
client.tags.all()
client.tags.all({'include':'recent_posts'})
```
```python
client.tags.get('product-updates')
client.tags.get('product-updates', {'include':'recent_posts'})
```
[To Top](#buttercms-python)
#### Feeds
```python
client.feeds.get('rss')
```
```python
client.feeds.get('atom')
```
```python
client.feeds.get('sitemap')
```
[To Top](#buttercms-python)
### Other
View Python [Blog engine](https://buttercms.com/python-blog-engine/) and [Full CMS](https://buttercms.com/python-cms/) for other examples of using ButterCMS with Python.
### Tests
To run tests:
```python
python -m unittest butter_cms/unit_tests.py
```
Raw data
{
"_id": null,
"home_page": "https://github.com/buttercms/buttercms-python",
"name": "buttercms-python",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "foo, bar, baz",
"author": "Adam Yala",
"author_email": "adam@adamyala.com",
"download_url": "https://files.pythonhosted.org/packages/f2/b6/e56865c45d103f7ac4efe7c72fa50dc579e50df5fdddd06140f707b2483c/buttercms-python-2.0.tar.gz",
"platform": null,
"description": "# buttercms-python\n\nPython Library for ButterCMS API. \n\n## Documentation\n\nFor a comprehensive list of examples, check out the [API documentation](https://buttercms.com/docs/api/).\n\n## Jump to:\n\n* [Pages](#pages)\n* [Collections](#collections)\n* [Posts](#posts)\n* [Authors](#authors)\n* [Categories](#categories)\n* [Feeds](#feeds)\n\n## Installation\n\nInstall from PyPi using [pip](http://www.pip-installer.org/en/latest/), a\npackage manager for Python.\n\n pip install buttercms-python\n\n\n## Usage\n\nGetting started with the ButterCMS API couldn't be easier. Use your authorization token to create a ButterCMS client.\n\n```python\nfrom butter_cms import ButterCMS\n\nauth_token = \"XXXXXXXXXXXXXXXXXXX\"\nclient = ButterCMS(auth_token)\n```\n\nAll methods return dictionaries. The data can be navigated using keys and indexes like the example below.\n\n```python\nresponse = client.posts.all()\n\nposts = response['data'] \n# posts now contains a list of post dictionaries\n\nmy_post = posts[0]\n# my_post contains the first returned post\n\nprint(my_post)\n# {\n# \"url\": \"http://www.example.com/blog/this-is-a-blog-post\",\n# \"created\": \"2015-06-12T13:59:32.441289Z\",\n# \"published\": \"2015-06-12T00:00:00Z\",\n# ...\n# }\n```\n\n### Pages\n\nThe Page's `.all()`, `.get()` and `.search()` methods accept an optional `params` to add additional data to the response.\n\n```python\nclient.pages.all('news')\n\n# Optional params\nclient.pages.all('news', {'foo': 'bar'})\n```\n\n\n```python\nclient.pages.get('news', 'hello-world')\n\n# Optional params\nclient.pages.get('news', 'hello-world', {'foo': 'bar'})\n```\n\n```python\nclient.pages.search('enter search query', {'page': 1, 'page_size': 10})\n```\n\n[To Top](#buttercms-python)\n\n\n### Collections\n\nFor a list of params see the [API documentation](https://buttercms.com/docs/api/?python#collections)\n\n.get() method accepts an optional `params` dict to add additional data to the response.\n\n```python\nclient.content_fields.get(['collection_key'], {'locale': 'en'})\n```\n\n[To Top](#buttercms-python)\n\n\n### Blog Engine\n\n#### Posts\n\n```python\nclient.posts.all({'page_size': 3, 'page': 1, 'exclude_body': 'true'})\n```\n\n\n```python\nclient.posts.get('hello-world')\n```\n\n\n```python\nclient.posts.search('query', {'page': 1, 'page_size': 10})\n```\n\n#### Authors\n\nThe Author's `.all()` and `.get()` methods accept an optional `params` to add additional data to the response.\n\n* `{'include':'recent_posts'}`: Adds each author's posts under the `recent_posts` key in that author's returned dictionary\n\n```python\nclient.authors.all()\nclient.authors.all({'include':'recent_posts'})\n```\n\n\n```python\nclient.authors.get('jennifer-smith')\nclient.authors.get('jennifer-smith', {'include':'recent_posts'})\n```\n\n\n[To Top](#buttercms-python)\n\n#### Categories\n\nThe Category's `.all()` and `.get()` methods accept an optional `params` to add additional data to the response.\n\n* `{'include':'recent_posts'}`: Adds posts tagged with that category under the `recent_posts` key in that category's returned dictionary\n\n```python\nclient.categories.all()\nclient.categories.all({'include':'recent_posts'})\n```\n\n\n```python\nclient.categories.get('product-updates')\nclient.categories.get('product-updates', {'include':'recent_posts'})\n```\n\n\n[To Top](#buttercms-python)\n\n\n#### Tags\n\nThe Tag's `.all()` and `.get()` methods accept an optional `params` to add additional data to the response.\n\n* `{'include':'recent_posts'}`: Adds posts tagged with that tag under the `recent_posts` key in that tag's returned dictionary\n\n```python\nclient.tags.all()\nclient.tags.all({'include':'recent_posts'})\n```\n\n\n```python\nclient.tags.get('product-updates')\nclient.tags.get('product-updates', {'include':'recent_posts'})\n```\n\n\n[To Top](#buttercms-python)\n\n#### Feeds\n\n```python\nclient.feeds.get('rss')\n```\n\n\n```python\nclient.feeds.get('atom')\n```\n\n\n```python\nclient.feeds.get('sitemap')\n```\n\n\n[To Top](#buttercms-python)\n\n\n\n### Other\n\nView Python [Blog engine](https://buttercms.com/python-blog-engine/) and [Full CMS](https://buttercms.com/python-cms/) for other examples of using ButterCMS with Python.\n\n### Tests\n\nTo run tests:\n\n```python\npython -m unittest butter_cms/unit_tests.py\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "API First Blogging and CMS platform built for developers",
"version": "2.0",
"project_urls": {
"Download": "https://github.com/buttercms/buttercms-python/tarball/0.1",
"Homepage": "https://github.com/buttercms/buttercms-python"
},
"split_keywords": [
"foo",
" bar",
" baz"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b62657576a9729db556e5ede81cd1856be8ef95a9e77f2abdfba990d1d30c9f6",
"md5": "c56c2a103826990b8228d9ebb335056a",
"sha256": "a180e9651f71eb8b3f528b7987ba86bb67f2ac66490644dd2cef81ad99fee9c3"
},
"downloads": -1,
"filename": "buttercms_python-2.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "c56c2a103826990b8228d9ebb335056a",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 8098,
"upload_time": "2024-04-24T17:15:27",
"upload_time_iso_8601": "2024-04-24T17:15:27.141424Z",
"url": "https://files.pythonhosted.org/packages/b6/26/57576a9729db556e5ede81cd1856be8ef95a9e77f2abdfba990d1d30c9f6/buttercms_python-2.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f2b6e56865c45d103f7ac4efe7c72fa50dc579e50df5fdddd06140f707b2483c",
"md5": "74e3db04c84dff3c960a2cfa184ad506",
"sha256": "0e759ac24a418cef4d15633c9de4a45594ba5f738aad19a5b75b255d450ace82"
},
"downloads": -1,
"filename": "buttercms-python-2.0.tar.gz",
"has_sig": false,
"md5_digest": "74e3db04c84dff3c960a2cfa184ad506",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7461,
"upload_time": "2024-04-24T17:15:29",
"upload_time_iso_8601": "2024-04-24T17:15:29.970104Z",
"url": "https://files.pythonhosted.org/packages/f2/b6/e56865c45d103f7ac4efe7c72fa50dc579e50df5fdddd06140f707b2483c/buttercms-python-2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-24 17:15:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "buttercms",
"github_project": "buttercms-python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "build",
"specs": [
[
"==",
"1.2.1"
]
]
},
{
"name": "certifi",
"specs": [
[
"==",
"2024.2.2"
]
]
},
{
"name": "charset-normalizer",
"specs": [
[
"==",
"3.3.2"
]
]
},
{
"name": "idna",
"specs": [
[
"==",
"3.7"
]
]
},
{
"name": "packaging",
"specs": [
[
"==",
"24.0"
]
]
},
{
"name": "pyproject_hooks",
"specs": [
[
"==",
"1.0.0"
]
]
},
{
"name": "requests",
"specs": [
[
"==",
"2.31.0"
]
]
},
{
"name": "urllib3",
"specs": [
[
"==",
"2.2.1"
]
]
}
],
"lcname": "buttercms-python"
}