Facebook API for Python.
Clean example request for the media downloader endpoint. Replace YOUR API and the media URL, then run the code.
Checking
Clean example request for the media downloader endpoint. Replace YOUR API and the media URL, then run the code.
import requests
import urllib.parse
API_KEY = "YOUR API"
VIDEO_URL = "URL FACEBOOK"
ENDPOINT = "https://senpai-bot.store/facebookdl"
def main():
encoded_url = urllib.parse.quote(VIDEO_URL, safe="")
full_url = f"{ENDPOINT}?apikey={API_KEY}&url={encoded_url}"
try:
response = requests.get(full_url)
response.raise_for_status()
except requests.RequestException as e:
print(f"Error making request: {e}")
return
try:
data = response.json()
except ValueError as e:
print(f"Error decoding JSON: {e}")
return
if data.get("code") != 200:
print(f"API returned error code: {data.get('code')} - {data.get('message')}")
return
result = data.get("result", {})
print("Title:", result.get("title"))
print("Uploader:", result.get("uploader"))
print("Duration:", result.get("duration"))
print("Video URL:", result.get("video_url"))
print("Thumbnail:", result.get("thumbnail"))
print("Post URL:", result.get("post_url"))
if __name__ == "__main__":
main()