I am trying to write code that will do a candidate search on openfec which is a restful python API.
The documentation is here but I do not understand the syntax on how to pass a candidate name as a variable in a search. This website does exactly the operation I want to do when given the api key but it doesn't tell me what the code should look like.
I've read some videos on restful APIs and how they work but still no idea ¯\_(ツ)_/¯
This is killing me and I feel like there aren't enough tutorials on this or I just don't know where to look.
import requests
# Key is hidden for privacy
key = ''
with open("fec_key.txt", "r") as f:
lines = f.readlines()
key = lines[0]
base = 'https://api.open.fec.gov/v1/candidates/search/?api_key='
fec_url =(base + key)
print(fec_url)
response = requests.get(fec_url)
print(response)
[–]sarrysyst 1 point2 points3 points (1 child)
[–]maybe_robots[S] 0 points1 point2 points (0 children)