Skip to main content

Free yourself from silo API chaff and expose the sweet social data foodstuff inside in standard formats and protocols!

Project description

https://raw.github.com/snarfed/granary/master/static/granary_logo_128.png https://circleci.com/gh/snarfed/granary.svg?style=svg https://coveralls.io/repos/github/snarfed/granary/badge.svg?branch=master

Granary is a library and REST API that fetches and converts social network data between a wide variety of formats:

Try out the interactive demo and check out the docs.

License: This project is placed in the public domain.

Using

The library and REST API are both based on the OpenSocial Activity Streams service.

Let’s start with an example. This code using the library:

from granary import twitter
...
tw = twitter.Twitter(ACCESS_TOKEN_KEY, ACCESS_TOKEN_SECRET)
tw.get_activities(group_id='@friends')

is equivalent to this HTTP GET request:

https://granary-demo.appspot.com/twitter/@me/@friends/@app/
  ?access_token_key=ACCESS_TOKEN_KEY&access_token_secret=ACCESS_TOKEN_SECRET

They return the authenticated user’s Twitter stream, ie tweets from the people they follow. Here’s the JSON output:

{
  "itemsPerPage": 10,
  "startIndex": 0,
  "totalResults": 12,
  "items": [{
      "verb": "post",
      "id": "tag:twitter.com,2013:374272979578150912",
      "url": "http://twitter.com/evanpro/status/374272979578150912",
      "content": "Getting stuff for barbecue tomorrow. No ribs left! Got some nice tenderloin though. (@ Metro Plus Famille Lemay) http://t.co/b2PLgiLJwP",
      "actor": {
      "username": "evanpro",
        "displayName": "Evan Prodromou",
        "description": "Prospector.",
        "url": "http://twitter.com/evanpro",
      },
      "object": {
        "tags": [{
            "url": "http://4sq.com/1cw5vf6",
            "startIndex": 113,
            "length": 22,
            "objectType": "article"
          }, "..."],
      },
    }, "..."]
  "..."
}

Check out the docs for more!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

granary-1.8.tar.gz (172.0 kB view details)

Uploaded Source

File details

Details for the file granary-1.8.tar.gz.

File metadata

  • Download URL: granary-1.8.tar.gz
  • Upload date:
  • Size: 172.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for granary-1.8.tar.gz
Algorithm Hash digest
SHA256 c9a85d25ddfba5115614fc2cc38065b0832945416fdcc5895e9576200abd77a9
MD5 db981c02a0d845eb2abb3e4c1ec395b7
BLAKE2b-256 c181fd0f85d5fbca4d6ecbf1bc06aa73f10fa4686444b718e0d3185d4d628c8e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page