Created
January 6, 2021 00:33
-
-
Save sudotong/d4b409f4de790597f049c0e446bf8a67 to your computer and use it in GitHub Desktop.
An example on connecting to the Fireflies API with Python 3
This file contains 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
# An example to get some data using the Fireflies GraphQL API | |
import requests | |
headers = {"Authorization": "Bearer YOUR-TOKEN-GOES-HERE"} | |
def run_query(query): # A simple function to use requests.post to make the API call. Note the json= section. | |
request = requests.post('https://api.fireflies.ai/graphql', json={'query': query}, headers=headers) | |
if request.status_code == 200: | |
return request.json() | |
else: | |
raise Exception("Query failed to run by returning code of {}. {}".format(request.status_code, query)) | |
# The GraphQL query (with a few aditional bits included) itself defined as a multi-line string. | |
query = """ | |
{ | |
user { | |
recent_transcript | |
} | |
} | |
""" | |
result = run_query(query) # Execute the query | |
recent_transcript = result["data"]["user"]["recent_transcript"] # Drill down the dictionary | |
print("Most recent transcript from user - {}".format(recent_transcript)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment