Skip to main content

gaggle

An aiohttp-based Google API client.

The google-api-python-client requirement is because this library uses it to discover services and prepare requests, leveraging the prepare+execute pattern implemented in googleapiclient.HttpRequest.

Usage

JSON

import asyncio
import aiohttp
from gaggle import Client


async def main():
    async with aiohttp.ClientSession() as session:
        drive = Client(
            session=session,
            token=access_token,
            # the following are optional and only required if the access_token is expired and can be refreshed
            refresh_token=refresh_token,
            client_id=client_id,
            client_secret=client_secret
        ).drive('v3')
        resp = await drive.files.list(q="parents in 'root'")
        # resp is an instance of aiohttp.ClientResponse
        if resp.status == 200:
            data = await resp.json()
            files = data.get('files', [])
            for obj in files:
                print(obj)

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

Results in something like:

{'kind': 'drive#file', 'id': '...', 'name': 'test.csv', 'mimeType': 'text/csv'}
{'kind': 'drive#file', 'id': '...', 'name': 'Test Folder', 'mimeType': 'application/vnd.google-apps.folder'}
{'kind': 'drive#file', 'id': '...', 'name': 'spreadsheet.xlsx', 'mimeType': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'}
{'kind': 'drive#file', 'id': '...', 'name': 'spreadsheet', 'mimeType': 'application/vnd.google-apps.spreadsheet'}

Installation

$ pip install gaggle

Testing and developing

I've included a handy Makefile to make these things fairly easy.

$ make setup
$ make test

Metadata

Release files for gaggle 0.2.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 gaggle 0.2.1
File Size Uploaded
gaggle-0.2.1.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gaggle 0.2.1
File Interpreter ABI Platform
gaggle-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 11.6 kB

Release files / gaggle-0.2.1.tar.gz

Download URL gaggle-0.2.1.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8deec8639634fbc7e774b64a601f82bc93a66130cbdb829d5b2897a4ffaf7db0
BLAKE2b-256 checksum
How to use checksums
b8906c5dd3c3673e062744e55a4ce46704b2d8feb649aae401afb0106627c4da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.4 CPython/3.7.1 Darwin/18.2.0

Release files / gaggle-0.2.1-py3-none-any.whl

Download URL gaggle-0.2.1-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8133faecb97267f0cabcd24f8a648ec51bc5ba94386781b35df759af0b02d5aa
BLAKE2b-256 checksum
How to use checksums
f5e78ba2360c548814151f05a65554767d7a18c3d83b1668184c6a38277a3589
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.4 CPython/3.7.1 Darwin/18.2.0
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