Difference between revisions of "SpaceAPI"
From Fixme.ch
| (17 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| − | [[Category: | + | [[Category:Closed_Projects]][[Category:Android]] |
== Description == | == Description == | ||
| − | * Accessible here | + | * Accessible here |
| + | **https://fixme.ch/cgi-bin/spaceapi.py | ||
| + | **https://fixme.ch/status.json | ||
* Provide a simple API to know whether the hackerspace is open or closed | * Provide a simple API to know whether the hackerspace is open or closed | ||
| − | * | + | * Documentation to implements the SpaceAPI |
| + | ** New website: http://spaceapi.net/ | ||
| + | ** Old website: https://hackerspaces.nl/spaceapi/ | ||
| + | ** [http://openspace.slopjong.de/ API Validator] | ||
| + | * App which implements it | ||
| + | ** http://spacestatus.bastinat0r.de/#fixme | ||
| + | ** http://spaceapi.net/app | ||
== Components == | == Components == | ||
| − | * | + | * We were hosting a fork of the SpaceAPI, because it was often down and the process to add new space is opaque |
| − | * Perl script that put the | + | ** This endpoint was used in MyHackerspace Android application |
| + | ** It's available here: http://spaceapi.fixme.ch/directory.json | ||
| + | ** It has been taken by the SpaceApi org on github (swiss german ppl mainly) | ||
| + | * [https://github.com/fixme-lausanne/Twitter-Hackerspace-Status Sources on Github] | ||
| + | ** Python script on fixme.ch that serves the API on https://fixme.ch/status.json | ||
| + | ** Perl script that put the status in a Mysql DB (from the [[RFID_Doorlock]] or from a computer) | ||
| + | ** A Drupal module to show the status on the main website | ||
| + | * MyHackerspace: Android application using SpaceAPI directory | ||
| + | ** [https://play.google.com/store/apps/details?id=ch.fixme.status Android Download on Play store] | ||
| + | ** [http://f-droid.org/repository/browse/?fdfilter=hackerspace&fdid=ch.fixme.status Download on F-Droid.org] | ||
| + | ** [https://github.com/fixme-lausanne/MyHackerspace/ Source code] | ||
| + | |||
| + | == Dummy script to lookup the status == | ||
| + | |||
| + | <syntaxhighlight lang="python"> | ||
| + | #!/usr/bin/env python3 | ||
| + | import urllib.request | ||
| + | import json | ||
| + | |||
| + | URL = "https://fixme.ch/cgi-bin/spaceapi.py" | ||
| + | |||
| + | def get_json(): | ||
| + | try: | ||
| + | con = urllib.request.urlopen(URL) | ||
| + | content = con.read() | ||
| + | hs_json = json.loads(content.decode('utf8')) | ||
| + | return hs_json | ||
| + | except IOError: | ||
| + | print("A network error occured sorry") | ||
| + | exit(1) | ||
| + | except ValueError: | ||
| + | print("Malformatted json") | ||
| + | |||
| + | def print_info(hs_json): | ||
| + | if hs_json['open']: | ||
| + | print("OPENENENENEN") | ||
| + | print("status is : {status}".format(**hs_json)) | ||
| + | print("the changes happens at {lastchange}".format(**hs_json)) | ||
| + | print("The duration is {duration} hours".format(**hs_json)) | ||
| + | else: | ||
| + | print("The hackerspace is closed") | ||
| + | json = get_json() | ||
| + | try: | ||
| + | print_info(json) | ||
| + | except: | ||
| + | pass | ||
| + | |||
| + | </syntaxhighlight> | ||
== Participant == | == Participant == | ||
Latest revision as of 15:01, 14 November 2019
Description
- Accessible here
- Provide a simple API to know whether the hackerspace is open or closed
- Documentation to implements the SpaceAPI
- New website: http://spaceapi.net/
- Old website: https://hackerspaces.nl/spaceapi/
- API Validator
- App which implements it
Components
- We were hosting a fork of the SpaceAPI, because it was often down and the process to add new space is opaque
- This endpoint was used in MyHackerspace Android application
- It's available here: http://spaceapi.fixme.ch/directory.json
- It has been taken by the SpaceApi org on github (swiss german ppl mainly)
- Sources on Github
- Python script on fixme.ch that serves the API on https://fixme.ch/status.json
- Perl script that put the status in a Mysql DB (from the RFID_Doorlock or from a computer)
- A Drupal module to show the status on the main website
- MyHackerspace: Android application using SpaceAPI directory
Dummy script to lookup the status
#!/usr/bin/env python3 import urllib.request import json URL = "https://fixme.ch/cgi-bin/spaceapi.py" def get_json(): try: con = urllib.request.urlopen(URL) content = con.read() hs_json = json.loads(content.decode('utf8')) return hs_json except IOError: print("A network error occured sorry") exit(1) except ValueError: print("Malformatted json") def print_info(hs_json): if hs_json['open']: print("OPENENENENEN") print("status is : {status}".format(**hs_json)) print("the changes happens at {lastchange}".format(**hs_json)) print("The duration is {duration} hours".format(**hs_json)) else: print("The hackerspace is closed") json = get_json() try: print_info(json) except: pass