Skip to main content

Shoogle

Use the Google API from the shell. An example, get the long URL using the urlshortener service:

$ echo '{"shortUrl": "http://goo.gl/Du5PSN"}' | shoogle execute urlshortener:v1.url.get -
{
  "status": "OK",
  "id": "http://goo.gl/Du5PSN",
  "longUrl": "http://1.bp.blogspot.com/-R0HSXDqlJI8/Tr67i-kr7hI/AAAAAAABMko/gaId6iYuhjA/s1600/12_%252520Cross%252520that%252520bridge%252520when%252520we%252520come%252520to%252520it.jpg",
  "kind": "urlshortener#url"
}

Install

Dependencies

  • Python >= 3.0

From PyPi

$ sudo pip install shoogle

From sources

$ wget https://github.com/tokland/shoogle/archive/master.zip
$ unzip master.zip
$ cd shoogle-master
$ sudo pip install pypandoc
$ sudo python setup.py install

Features

  • Exposes agnostically all the services in the API.

  • Provides infrastructure for the Oauth2 authentication (console or QT/GTK browser).

  • Shows information from the Google Discovery API to help build the JSON requests.

  • Save credentials for each set of scopes.

Setup: configure the API and secret keys

  • You must enable the services you want to use and create the required keys or secret file in the API Manager. Each service has its own policies, check the Google documentation for more details.

Commands

show

Incrementally show details of services/resources/methods:

$ shoogle show
adexchangebuyer2:v2beta1 - Ad Exchange Buyer API II
adexchangebuyer:v1.2 - Ad Exchange Buyer API
...
youtubeAnalytics:v1beta1 - YouTube Analytics API
youtubereporting:v1 - YouTube Reporting API
$ shoogle show short
urlshortener:v1 - URL Shortener API
$ shoogle show urlshortener:v1
urlshortener:v1.url
$ shoogle show urlshortener:v1.url
urlshortener:v1.url.get - Expands a short URL or gets creation time and analytics.
urlshortener:v1.url.insert - Creates a new short URL.
urlshortener:v1.url.list - Retrieves a list of URLs shortened by a user.
$ shoogle show urlshortener:v1.url.get
[INFO] Response (level=0, --debug-response-level=N to change):
{
  "$ref": "Url"
}
[INFO] Request (level=1, --debug-request-level=N to change):
{
  "shortUrl": "(string) The short URL, including the protocol - required"
}

execute

  • Expand a short URL:

$ cat get-longurl.json
{
  "key": "YOUR_SECRET_KEY", // You can use JS comments!
  "shortUrl": "http://goo.gl/Du5PSN"
}

$ shoogle execute urlshortener:v1.url.get get-longurl.json
{
  "status": "OK",
  "id": "http://goo.gl/Du5PSN",
  "longUrl": "http://1.bp.blogspot.com/-R0HSXDqlJI8/Tr67i-kr7hI/AAAAAAABMko/gaId6iYuhjA/s1600/12_%252520Cross%252520that%252520bridge%252520when%252520we%252520come%252520to%252520it.jpg",
  "kind": "urlshortener#url"
}
  • jq is a command-line JSON builder/parser. This example shows how to upload a video from a JSON template and extract the ID from the response:

$ cat upload-video.template.json
{
  "part": "snippet",
  "body": {
    "snippet": {
      "title": $title,
      "description": $description
    }
  }
}
$ jq -n -f upload-video.template.json --arg title "Chess" --arg description "Norway Chess" |
    shoogle execute -c your_client_id.json youtube:v3.videos.insert - -f chess.mp4 |
    jq -r '.id'
wUArz2nPGqA

More

Feedback

  • Issues: Please open issues only to report bugs of the package. If you have problems regarding how to use the API itself (what auth is required, how to create those auth files, how to build the request parameters, quotas management, etc), use the Google Forums or StackOverflow.

  • Want to donate?

ChangeLog

[0.1.0]

  • Provides infrastructure for Oauth2 authentication (console and browser).

  • Exposes all services supported by the Python Gooogle API.

Metadata

Release files for shoogle 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shoogle 0.1.4
File Size Uploaded
shoogle-0.1.4.tar.gz 33.6 kB Details

Release files / shoogle-0.1.4.tar.gz

Download URL shoogle-0.1.4.tar.gz
Size 33.6 kB
Tags Source
SHA-256 checksum
How to use checksums
37e0fe894ce716db32e27ada0f6182c5def561d688e58bf8b47c3b0f3de9634e
BLAKE2b-256 checksum
How to use checksums
73aa2d9f80f37fd99eebe036896b84a560fd904b9c822c1480d410f4e389921f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.4 This release

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

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