https://github.com/alpinweis/pycircleci
Python client for CircleCI API
https://github.com/alpinweis/pycircleci
api api-client circleci python
Last synced: 11 months ago
JSON representation
Python client for CircleCI API
- Host: GitHub
- URL: https://github.com/alpinweis/pycircleci
- Owner: alpinweis
- License: mit
- Created: 2020-02-18T07:51:56.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-08-20T05:59:10.000Z (over 2 years ago)
- Last Synced: 2024-10-01T20:51:43.587Z (over 1 year ago)
- Topics: api, api-client, circleci, python
- Language: Python
- Size: 85 KB
- Stars: 39
- Watchers: 5
- Forks: 13
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-starts - alpinweis/pycircleci - Python client for CircleCI API (python)
README
# pycircleci
[](https://python.org/pypi/pycircleci)
[](https://github.com/alpinweis/pycircleci/actions/workflows/test.yml?query=branch%3Amaster)
Python client for [CircleCI API](https://circleci.com/docs/2.0/api-intro/).
Based on the discontinued [circleci.py](https://github.com/levlaz/circleci.py) project.
## Features
- Supports [API v1.1](https://circleci.com/docs/api/#api-overview) and [API v2](https://circleci.com/docs/api/v2/)
- Supports both `circleci.com` and self-hosted [Enterprise CircleCI](https://circleci.com/enterprise/)
## Installation
$ pip install pycircleci
## Usage
Create a personal [API token](https://circleci.com/docs/2.0/managing-api-tokens/#creating-a-personal-api-token).
Set up the expected env vars:
CIRCLE_TOKEN # CircleCI API access token
CIRCLE_API_URL # CircleCI API base url. Defaults to https://circleci.com/api
```python
from pycircleci.api import Api, CIRCLE_TOKEN, CIRCLE_API_URL
circle_client = Api(token=CIRCLE_TOKEN, url=CIRCLE_API_URL)
# get current user info
circle_client.get_user_info()
# get list of projects
results = circle_client.get_projects()
# pretty print results as json
circle_client.ppj(results)
# pretty print the details of the last request/response
circle_client.ppr()
```
### Interactive development console
make console
This starts a pre-configured python interactive console which gives you access to a
`client` object - an instance of the `Api` class to play around. From the console
type `man()` to see the help screen.
### Contributing
1. Fork it
1. Install dev dependencies (`pip install -r requirements-dev.txt`)
1. Create your feature branch (`git checkout -b my-new-feature`)
1. Make sure `flake8` and the `pytest` test suite successfully run locally
1. Commit your changes (`git commit -am 'Add some feature'`)
1. Push to the branch (`git push origin my-new-feature`)
1. Create new Pull Request