Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Collection of web service libraries for Tornado web framework
Python
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
tests Renamed facebook to _facebook, foursquare to _foursquare. Also, added…
.gitignore First commit
README.md Updated README.md
__init__.py
_facebook.py Updated license
_foursquare.py Renamed facebook to _facebook, foursquare to _foursquare. Also, added…
_stripe.py Updated license
_twitter.py

README.md

What is tornado_api

tornado_api is a collection of Mixins and asynchronous HTTP libraries for Tornado Web Framework.

FacebookGraphMixin

Re-implementation of Tornado's OAuth2 Mixin.

FoursquareMixin

OAuth2 Mixin for Foursquare. Once authorized via authorize_redirect(), you can call Foursquare API using foursquare_request()

tornado_api.Stripe

A complete implementation of Stripe v1 API using Tornado AsyncHTTPClient.

Initialization

    #
    # By default, blocking is set to False.
    # If blocking is set to True, then it uses Tornado blocking HTTP client.
    #
    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY, blocking=True)

Building URL

tornado_api.Stripe maps to Stripe Curl URL exactly one-to-one.

/v1/charges

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.charges

/v1/charges/{CHARGE_ID}

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.charges.id(CHARGE_ID)

/v1/customers

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.customers

/v1/customers/{CUSTOMER_ID}

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.customers.id(CUSTOMER_ID)

/v1/customers/{CUSTOMER_ID}/subscription

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.customers.id(CUSTOMER_ID).subscription

/v1/invoices

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.invoices

/v1/invoices/{INVOICE_ID}

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.invoices.id(INVOICE_ID)

/v1/invoiceitems

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.invoiceitems

/v1/invoiceitems/{INVOICEITEM_ID}

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.invoiceitems.id(INVOICEITEM_ID)

/v1/tokens

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.tokens

/v1/tokens/{TOKEN_ID}

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.tokens.id(TOKEN_ID)

/v1/events

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.events

/v1/events/{EVENT_ID}

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.events.id(EVENT_ID)

Performing HTTP request

GET

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.plans.get()
    stripe.plans.id(PLAN_ID).get()

POST

    DUMMY_PLAN = {
        'amount': 2000,
        'interval': 'month',
        'name': 'Amazing Gold Plan',
        'currency': 'usd',
        'id': 'stripe-test-gold'
    }
    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.plans.post(**DUMMY_PLAN)

DELETE

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.plans.id(DUMMY_PLAN['id']).delete()

tornado_api.Twitter

Requirement:

pip install twitter

Based on Twitter module. The only 2 differences:

  • The HTTP client have been replaced by Tornado AsyncHTTPClient.

  • __call__() accepts _callback as keyword argument.

Something went wrong with that request. Please try again.