Created
March 17, 2015 19:56
-
-
Save chriddyp/a49c22a8547130ef02ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:c6ad7e07e12f6a7c78274f549a96fc7547f0a9c5955a29ced7cb55b5d16bd991" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"import requests\n", | |
"import json\n", | |
"from requests.auth import HTTPBasicAuth\n", | |
"\n", | |
"auth = HTTPBasicAuth('', '')\n", | |
"headers = {'Plotly-Client-Platform': 'api', 'Content-Type': 'application/json'}" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 10 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"r = requests.get('https://api.plot.ly/v2/files/chris:-1', headers=headers, auth=auth)" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 14 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"files = json.loads(r.content)['results']" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 18 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"h = ''\n", | |
"for f in files:\n", | |
" if f['filetype'] == 'plot':\n", | |
" url = 'https://plot.ly/~'+'/'.join(f['fid'].split(':'))\n", | |
" h += (''+\n", | |
" '<div>'+\n", | |
" '<a href=\"'+url + '\">' + \n", | |
" '<h3>'+f['filename']+'</h3>'+\n", | |
" '<img src=\"'+url+'.png'+'\">'\n", | |
" '</a>'+\n", | |
" '</div>')\n", | |
" \n", | |
"HTML(h)" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": [ | |
"<div><a href=\"https://plot.ly/~chris/6859\"><h3>US Prisoners</h3><img src=\"https://plot.ly/~chris/6859.png\"></a></div><div><a href=\"https://plot.ly/~chris/6852\"><h3>untitled (111)</h3><img src=\"https://plot.ly/~chris/6852.png\"></a></div><div><a href=\"https://plot.ly/~chris/6834\"><h3>bubble (1)</h3><img src=\"https://plot.ly/~chris/6834.png\"></a></div><div><a href=\"https://plot.ly/~chris/6832\"><h3>recreated in python</h3><img src=\"https://plot.ly/~chris/6832.png\"></a></div><div><a href=\"https://plot.ly/~chris/6819\"><h3>excel demo</h3><img src=\"https://plot.ly/~chris/6819.png\"></a></div><div><a href=\"https://plot.ly/~chris/6828\"><h3>plot from API (522)</h3><img src=\"https://plot.ly/~chris/6828.png\"></a></div><div><a href=\"https://plot.ly/~chris/3197\"><h3>NYPD complaints</h3><img src=\"https://plot.ly/~chris/3197.png\"></a></div>" | |
], | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 45, | |
"text": [ | |
"<IPython.core.display.HTML at 0x104d612d0>" | |
] | |
} | |
], | |
"prompt_number": 45 | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment