I’m trying to use the Bubble API Connector plugin to connect to an API from the Bureau of Labor https://www.bls.gov/developers/home.htm
I’ve been able to connect when initializing the call, but haven’t been able to retrieve any data. I’m not sure how I’m supposed to configure parameters to make it successful.
Here is what I have so far:
Also, here is some sample code in Python from their API documentation, I just don’t know how to recreate this using the plugin.
import requests
import json
import prettytable
headers = {‘Content-type’: ‘application/json’}
data = json.dumps({“seriesid”: [‘CUUR0000SA0’,‘SUUR0000SA0’],“startyear”:“2011”, “endyear”:“2014”})
p = requests.post(‘https://api.bls.gov/publicAPI/v1/timeseries/data/’, data=data, headers=headers)
json_data = json.loads(p.text)
for series in json_data[‘Results’][‘series’]:
x=prettytable.PrettyTable([“series id”,“year”,“period”,“value”,“footnotes”])
seriesId = series[‘seriesID’]
for item in series[‘data’]:
year = item[‘year’]
period = item[‘period’]
value = item[‘value’]
footnotes=""
for footnote in item[‘footnotes’]:
if footnote:
footnotes = footnotes + footnote[‘text’] + ‘,’
‘if ‘M01’ <= period <= ‘M12’:’
x.add_row([seriesId,year,period,value,footnotes[0:-1]])
output = open(“c:\temp\” + seriesId + “.txt”,“w”)
output.write (x.get_string())
output.close()
Can anyone help please?