-
-
Save ajokela/043bcf5d0184d4ad6a826cda752fd8ca to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import requests | |
import datetime | |
import h3 | |
import networkx as nx | |
import urllib | |
import numpy as np | |
import pandas as pd | |
import time | |
import random | |
def list_hotspots_in_city(city_id: str): | |
"""retrieves all the hotspots in a city""" | |
url = 'https://api.helium.io/v1/cities/' + city_id + '/hotspots' | |
r = requests.get(url) | |
hotspots = r.json()['data'] | |
return hotspots | |
def list_witnesses_for_hotspot(hotspot_address: str): | |
"""lists a hotspot's witnesses over the last 5 days""" | |
url = 'https://api.helium.io/v1/hotspots/' + hotspot_address + '/witnesses' | |
r = requests.get(url) | |
witnesses = r.json()['data'] | |
return witnesses | |
def get_hotspot_rewards(hotspot_address: str, n_days: int): | |
"""Get a hotspot's cumulative rewards for the past n days""" | |
start_time = datetime.datetime.isoformat(datetime.datetime.now() - datetime.timedelta(days=n_days)) | |
url = f"https://api.helium.io/v1/hotspots/{hotspot_address}/rewards/sum?min_time={start_time}" | |
r = requests.get(url) | |
rewards = r.json()['data']['total'] | |
return rewards | |
def get_hotspot_details(address: str): | |
url = 'https://api.helium.io/v1/hotspots/' + address | |
r = requests.get(url) | |
details = r.json()['data'] | |
return details |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment