Septzzz's picture
Upload folder using huggingface_hub (part 12)
96aab11 verified
Raw
History Blame Contribute Delete
5.45 kB
import requests
import json
from datetime import date, datetime, timedelta
import os
from typing import Optional, Dict, Union, List
def getbookbyid(is_id: int, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Returns a book"
id: ID of the book
"""
url = f"https://bbcast-api.p.rapidapi.com/books/{is_id}"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "bbcast-api.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def getbookauthorsbyid(is_id: int, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Returns an author"
id: ID of the author
"""
url = f"https://bbcast-api.p.rapidapi.com/authors/{is_id}"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "bbcast-api.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def getbooks(offset: int, limit: int, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Returns all books"
offset: Offset of the books
limit: Limit of the books
"""
url = f"https://bbcast-api.p.rapidapi.com/books"
querystring = {'offset': offset, 'limit': limit, }
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "bbcast-api.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def getbooksubjectsbyid(is_id: int, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Returns a subject"
id: ID of the subject
"""
url = f"https://bbcast-api.p.rapidapi.com/subjects/{is_id}"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "bbcast-api.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def searchbooks(limit: int, offset: int, query: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Returns a book"
limit: Limit of the books
offset: Offset of the books
query: Search query
"""
url = f"https://bbcast-api.p.rapidapi.com/search"
querystring = {'limit': limit, 'offset': offset, 'query': query, }
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "bbcast-api.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def getbooksbysubject(limit: int, subject: str, offset: int, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Returns all books by subject"
limit: Limit of the books
subject: Subject of the books
offset: Offset of the books
"""
url = f"https://bbcast-api.p.rapidapi.com/bysubject"
querystring = {'limit': limit, 'subject': subject, 'offset': offset, }
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "bbcast-api.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def getsubjects(limit: int, offset: int, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Returns all subjects"
limit: Limit of the subjects
offset: Offset of the subjects
"""
url = f"https://bbcast-api.p.rapidapi.com/subjects"
querystring = {'limit': limit, 'offset': offset, }
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "bbcast-api.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def gettext(is_id: int, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Returns text of the book"
id: ID of the book
"""
url = f"https://bbcast-api.p.rapidapi.com/gettext/{is_id}"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "bbcast-api.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation