# Basecamp API
This package allows interaction with the [Basecamp API](https://github.com/basecamp/bc3-api) using Python.
## Installation
The package can be installed from your terminal by typing:
pip install bcapi
You need to have python 3.11 or higher installed.
## Set up your environment
Typically
You need to create a .env file in the root of the project and add your Basecamp account ID, client ID, client secret, and redirect URI. Copy the .env.example file to get started. You'll find the client ID and secret in 1password under: **Basecamp Oauth App: ciobc**. You'll also find them on [our OAuth app page](https://launchpad.37signals.com/integrations/15032). You'll need to login with your Basecamp account of course.
### Get a refresh token
You also need a refresh token. To interact with Basecamp's API, you must provide an access token for every API request. Access tokens are set to expire after two weeks.
A refresh token allows you to automatically regenerate new access tokens. You only have to generate the refresh token once and after that you can use it to gain access to Basecamp each time you run your script.
The refresh token is not in 1password since it is tied to your account. You must generate it and add it to your `.env` file.
If you already have a Refresh token, skip this step.
To begin the authentication process, use the `auth` script:
```bash
bcapi
```
Since your `.env` file does not contain a refresh_token, an error will be raised which contains a link for the authorization of your app. Open that link in the browser and click on "Yes, I'll allow access".
After allowing access, you'll be redirected to your redirect URI where you'll find a verification code in the URL. Use this code to complete the authentication. Run the `auth` script again with the verification code as an argument:
```bash
ciobc 17beb4cd
```
This will generate your Refresh token and use that token right away to generate the Access token for your current session. You should now save the refresh token in your `.env` file.
## 3. Using the API
Once you have authentication set up, you can start interacting with Basecamp. Here are some examples:
#### Initialize MessageBoard
```python
from ciobc.client import Client
from ciobc.messageboard import MessageBoard
```
#### Use the client as a context manager
```python
with Client() as client:
message_board = MessageBoard(client=client)
```
#### List messages
```python
with Client() as client:
message_board = MessageBoard(client=client)
messages = message_board.list(
project_id=123456,
message_board_id=123456
)
```
#### Create a message
```python
with Client() as client:
message_board = MessageBoard(client=client)
message_board.create(
project_id=123456,
message_board_id=123456,
subject="Important Update",
content="Here's the latest project update...",
publish=True # Set to False for draft
)
```
#### Get a message
```python
with Client() as client:
message_board = MessageBoard(client=client)
message = message_board.get(
project_id=123456,
message_id=789012
)
```
#### Update a message
```python
with Client() as client:
message_board = MessageBoard(client=client)
message_board.update(
project_id=123456,
message_id=789012,
subject="Updated: Important Update",
content="Here's the revised project update..."
)
```
## Currently available endpoints
- MessageBoard
- People
- Projects
- Schedule Entries
- Schedules
- TodoList groups
- TodoLists
- Todos
- Todosets
Raw data
{
"_id": null,
"home_page": "https://github.com/hoolymama/bcapi",
"name": "bcapi",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.11",
"maintainer_email": null,
"keywords": "basecamp, api, client",
"author": "Julian Mann",
"author_email": "julian.mann@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/b9/1d/788b06f6a35fe8938a54e84afafba15979450ba4c2bc52671e0f90071f5f/bcapi-1.0.0.tar.gz",
"platform": null,
"description": "# Basecamp API\n\nThis package allows interaction with the [Basecamp API](https://github.com/basecamp/bc3-api) using Python.\n\n## Installation\nThe package can be installed from your terminal by typing:\n\n pip install bcapi\n\nYou need to have python 3.11 or higher installed.\n\n## Set up your environment\n\nTypically\n\nYou need to create a .env file in the root of the project and add your Basecamp account ID, client ID, client secret, and redirect URI. Copy the .env.example file to get started. You'll find the client ID and secret in 1password under: **Basecamp Oauth App: ciobc**. You'll also find them on [our OAuth app page](https://launchpad.37signals.com/integrations/15032). You'll need to login with your Basecamp account of course.\n\n### Get a refresh token\n\nYou also need a refresh token. To interact with Basecamp's API, you must provide an access token for every API request. Access tokens are set to expire after two weeks. \n\nA refresh token allows you to automatically regenerate new access tokens. You only have to generate the refresh token once and after that you can use it to gain access to Basecamp each time you run your script.\n\nThe refresh token is not in 1password since it is tied to your account. You must generate it and add it to your `.env` file.\n\nIf you already have a Refresh token, skip this step.\n\nTo begin the authentication process, use the `auth` script:\n\n```bash \nbcapi\n```\n\nSince your `.env` file does not contain a refresh_token, an error will be raised which contains a link for the authorization of your app. Open that link in the browser and click on \"Yes, I'll allow access\".\n\nAfter allowing access, you'll be redirected to your redirect URI where you'll find a verification code in the URL. Use this code to complete the authentication. Run the `auth` script again with the verification code as an argument:\n\n```bash\nciobc 17beb4cd\n```\n\nThis will generate your Refresh token and use that token right away to generate the Access token for your current session. You should now save the refresh token in your `.env` file.\n\n\n## 3. Using the API\n\nOnce you have authentication set up, you can start interacting with Basecamp. Here are some examples:\n\n#### Initialize MessageBoard\n```python\nfrom ciobc.client import Client\nfrom ciobc.messageboard import MessageBoard\n```\n\n\n#### Use the client as a context manager\n```python\nwith Client() as client:\n message_board = MessageBoard(client=client)\n```\n\n#### List messages\n```python\nwith Client() as client:\n message_board = MessageBoard(client=client)\n messages = message_board.list(\n project_id=123456,\n message_board_id=123456\n )\n```\n\n#### Create a message\n```python\nwith Client() as client:\n message_board = MessageBoard(client=client)\n\tmessage_board.create(\n\t\tproject_id=123456,\n\t\tmessage_board_id=123456,\n\t\tsubject=\"Important Update\",\n\t\tcontent=\"Here's the latest project update...\",\n\t\tpublish=True # Set to False for draft\n\t)\n```\n\n#### Get a message\n```python\nwith Client() as client:\n message_board = MessageBoard(client=client)\n\tmessage = message_board.get(\n\t\tproject_id=123456,\n\t\tmessage_id=789012\n\t)\n```\n\n#### Update a message\n```python\nwith Client() as client:\n message_board = MessageBoard(client=client)\n message_board.update(\t\n project_id=123456,\n message_id=789012,\n subject=\"Updated: Important Update\",\n content=\"Here's the revised project update...\"\n )\n```\n\n\n\n## Currently available endpoints\n\n- MessageBoard\n- People\n- Projects\n- Schedule Entries\n- Schedules\n- TodoList groups\n- TodoLists\n- Todos\n- Todosets\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python client wrapper for Basecamp API",
"version": "1.0.0",
"project_urls": {
"Documentation": "https://github.com/hoolymama/bcapi",
"Homepage": "https://github.com/hoolymama/bcapi",
"Repository": "https://github.com/hoolymama/bcapi"
},
"split_keywords": [
"basecamp",
" api",
" client"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4740358ee32f162bc09dddf3fa9a26c042704c5b9950b0ea2691b1d999419593",
"md5": "c01cf891af049f79c04276637f3278be",
"sha256": "862a3750285465aadb7cce50c67faed7de2a4733e745434a28dede3b17941af4"
},
"downloads": -1,
"filename": "bcapi-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c01cf891af049f79c04276637f3278be",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.11",
"size": 22031,
"upload_time": "2024-12-01T02:34:32",
"upload_time_iso_8601": "2024-12-01T02:34:32.548955Z",
"url": "https://files.pythonhosted.org/packages/47/40/358ee32f162bc09dddf3fa9a26c042704c5b9950b0ea2691b1d999419593/bcapi-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b91d788b06f6a35fe8938a54e84afafba15979450ba4c2bc52671e0f90071f5f",
"md5": "7b41c004b54e0847c8f3ed470eb47852",
"sha256": "99716178f9c8775b681d200100a79b10ab10513ca49df1dc1c32a79e0c93f96c"
},
"downloads": -1,
"filename": "bcapi-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "7b41c004b54e0847c8f3ed470eb47852",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.11",
"size": 15257,
"upload_time": "2024-12-01T02:34:35",
"upload_time_iso_8601": "2024-12-01T02:34:35.978763Z",
"url": "https://files.pythonhosted.org/packages/b9/1d/788b06f6a35fe8938a54e84afafba15979450ba4c2bc52671e0f90071f5f/bcapi-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-01 02:34:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hoolymama",
"github_project": "bcapi",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "bcapi"
}