Skip to content

Instantly share code, notes, and snippets.

@evandiewald
Last active November 5, 2022 13:22
Show Gist options
  • Save evandiewald/de4038680fe20c34eb805412e8c31ff2 to your computer and use it in GitHub Desktop.
Save evandiewald/de4038680fe20c34eb805412e8c31ff2 to your computer and use it in GitHub Desktop.
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