Septzzz's picture
Upload folder using huggingface_hub (part 12)
96aab11 verified
Raw
History Blame Contribute Delete
1.45 kB
import requests
import json
from datetime import date, datetime, timedelta
import os
from typing import Optional, Dict, Union, List
def getusers(age: int=None, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"return a list of all users"
age: return a list of all user with the specified age
"""
url = f"https://nbzor-homework-v1.p.rapidapi.com/api/users"
querystring = {}
if age:
querystring['age'] = age
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "nbzor-homework-v1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def getuser(is_id: int, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"return user by id"
id: id of the user
"""
url = f"https://nbzor-homework-v1.p.rapidapi.com/api/users/{is_id}"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "nbzor-homework-v1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation