Skip to content

Instantly share code, notes, and snippets.

@mjg123 mjg123/func.py
Last active Apr 10, 2018

Embed
What would you like to do?
Example fn code to query the OsloBysykkel API
import json
import urllib2
import sys
try:
input = json.loads(''.join(sys.stdin.readlines()))['body']
except:
input=""
if input == "":
input = "167"
input = input.strip()
opener = urllib2.build_opener()
opener.addheaders = [('Client-Identifier', 'f416cc3951533fc385acd670a0d0172d')]
content = opener.open('https://oslobysykkel.no/api/v1/stations').read()
bikestations = json.loads(content)
output = {}
for b in bikestations['stations']:
if str(b['id']) == input:
output = b
print(json.dumps({'body': json.dumps(output)}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.