Skip to content

Instantly share code, notes, and snippets.

@mdevilliers
Forked from Popcore/python run pipes
Last active February 16, 2018 17:19
Show Gist options
  • Select an option

  • Save mdevilliers/ec54ecce985235ec4b34cea1b09cc34d to your computer and use it in GitHub Desktop.

Select an option

Save mdevilliers/ec54ecce985235ec4b34cea1b09cc34d to your computer and use it in GitHub Desktop.
Run a Thingful pipe programmatically with python
import requests
import os
import logging
try:
import http.client as http_client
except ImportError:
# Python 2
import httplib as http_client
http_client.HTTPConnection.debuglevel = 1
# You must initialize logging, otherwise you'll not see debug output.
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
url = "https://datapipes.thingful.net/api/run/3c52406d-513b-4b7f-95e8-64fa61666dfd"
token = os.getenv("PIPES_TOKEN")
if token is None:
raise TypeError("PIPES_TOKEN must be set in the environment")
headers = {'Thingful-Authorization': 'Bearer {}'.format(token)}
print headers
resp = requests.get(url, headers=headers)
print(resp.json())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment