A utility package for using the public API of tapeapp.com with Python.
Project description
turbotape
A modern utility library for easily using the Tape (https://tapeapp.com/) API with Python.
How to install
pip install turbotape
the 'tpod' command
Get your client ID und client secret from https://podio.com/settings/api
Then run the following command:
tpod init --client-id=<Tape-client-id> --client-secret=<Tape-client-secret>
This will create a hidden file called .turbotape_credentials.json in the
current working directory. The access token is valid for some hours.
Accessing single Tape items
You can find die item_id of any Tape item by opening a Tape item detail view
in the Webbrowser and then clicking on 'Actions' and 'Developer info':
This will display among other things the item_id and the app_id:
Using the item_id you can now write a simple python programm that will read the details
of one single item. Create file named get_record_data.py that contains the following Python code:
from turbotape.session import create_tape_session
ITEM_ID=123456789 # <- Replace with your own record_id.
def get_tape_record(record_id):
# reads the access token from .turbotape_credentials.json
Tape = create_Tape_session()
# see https://developers.podio.com/doc/items/get-item-22360
record_url = f'https://api.tapeapp.com/v1/record/{record_id}'
# podio.get() works almost the same way that requests.get() works
resp = podio.get(record_url)
resp.raise_for_status()
item_data = resp.json()
return item_data
if __name__ == '__main__':
item_data = get_tape_record(ITEM_ID)
# print something from the item_data, then exit
print(f"Record ID: {item_data['item_id']}")
print(f"Record title: {item_data['title']}")
Now run the program. The output should look like this:
$ python ./get_record_data.py
Record ID: 123456789
Record title: Bow of boat
$ _
Working with higher number of Tape items
Tape has very strict API limits. Because of this, turbotape includes an option to
create a 'robust' session. If you create Tape session with the robust parameter,
turbotape will wait when the API limit is reached and it will also retry the request
when Tape returns a '504 Gateway timeout' error.
from turbotape.session import create_podio_session
podio = create_podio_session(robust=True)
Another hurdle is pagination. To download the data of a whole Tape app, we need to get the Tape items in smaller chunks:
from turbotape.session import create_podio_session
from turbotape.helpers import iterate_resource
app_id = 987654321 # <- Enter your own app_id here.
podio = create_podio_session(robust=True)
url = f'https://api.podio.com/item/app/{app_id}/filter/'
for item in iterate_resource(client, url, 'POST', limit=250):
print(item['item_id'])
(The limit parameter can be anything from 1 to 500. On larger Tape apps it is wise to stay below
300 and reduce the limit if you see that the Tape API returns a lot of HTTP 504 Errors.
See https://developers.podio.com/doc/items/filter-items-4496747 for more info on the filter API endpoint.
Turning a whole Tape app into a Pandas dataframe
For this example to work Pandas needs to be installed already. Often you want to get all the data from one Tape app.
import turbotape.dataframe
from turbotape.session import create_podio_session
podio = create_podio_session(robust=True)
app_id = 987654321 # <- Replace with your own app_id here.
# You need to list the fields that should be included in the dataframe
df = turbotape.dataframe.load_from_app(podio, app_id, labels=['Title', 'Description'])
# But you can also use the external_ids of the fields
df = turbotape.dataframe.load_from_app(podio, app_id, external_ids=['title‘, 'description'])
Useful links
- https://github.com/finklabs/whaaaaat
- http://click.pocoo.org/5/
- https://github.com/asweigart/pyperclip
- http://urwid.org/
- http://npyscreen.readthedocs.io/introduction.html
- https://help.podio.com/hc/en-us/community/posts/206886967-Updating-a-Calculation-Field-Script-via-the-API
- https://requests-oauthlib.readthedocs.io/en/latest/
- https://sedimental.org/glom_restructured_data.html
- https://flit.readthedocs.io/en/latest/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file turbotape-0.0.10.tar.gz.
File metadata
- Download URL: turbotape-0.0.10.tar.gz
- Upload date:
- Size: 1.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba89327dcc1690ca25fa60cc7ddf0c493b2eaee84fe9b2dd3cefc180245f8a70
|
|
| MD5 |
a7f3730ff04fb97721045c3499bada33
|
|
| BLAKE2b-256 |
7d954a0f61538968e234dc68e65bf5d42f0716d11d054bc0aa32d4e15e29d3a4
|
File details
Details for the file turbotape-0.0.10-py3-none-any.whl.
File metadata
- Download URL: turbotape-0.0.10-py3-none-any.whl
- Upload date:
- Size: 20.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1686b7f361f6a6e925b25483066a99b5944d9694e329f46f5f73b75db30a1258
|
|
| MD5 |
90d9894aae049a03956adbb837748a47
|
|
| BLAKE2b-256 |
03c25948f53771e8766cd7da77271398349f2568b94a977851c8f5357e5bab64
|