Unable to retrieve data from Thingspeak API (PurpleAir)
이전 댓글 표시
Hello,
I am having trouble accessing the Thingspeak API with PurpleAir.
Currently my code contains this,
temp_df = pd.read_csv(StringIO(requests.get("https://api.thingspeak.com/channels/"+repr(id)+"/feeds.csv?resutls=8000&api_key="+api+"&end="+end_time).text))
where api_key is retrived from api.purpleair and end_time is for my time period.
Now it just returns -1.
This code worked before for several years however it stopped working today. I assume it blocked me out from accessing the data. How can I fix this?
댓글 수: 3
Christopher Stapels
2022년 5월 19일
Are you reading multiple channels or just one channel?
Kyongwon Yoo
2022년 5월 19일
Kyongwon Yoo
2022년 5월 19일
답변 (2개)
Christopher Stapels
2022년 5월 19일
0 개 추천
Thank you for noting that the issue you had is resolved. If you are reading multiple channels, please be sure to use a short delay between each read attempt, so as not to create undue burden on the server.
Frederic Lhoest
2022년 9월 29일
0 개 추천
Hi there,
I have the same issue; using the command line curl command on macOS it works fine.
Same thing with a php cURL function I'm receiving -1 ...
댓글 수: 6
Christopher Stapels
2022년 9월 29일
Frederic, are you using exactly the smae call as the OP? Are you requesting this same query for multiple channels simultaneously or at least sequentially?
Frederic Lhoest
2022년 9월 29일
Hi Christopher,
Thanks for jumping in. I think the issue is on the way I'm using the cURL function in php, not quite sure yet... Exact same request in the command line works perfectly, but my php script is not. I still need to figure it out.
Basically what "-1" means when your get it as returned value ?
Thanks
Christopher Stapels
2022년 9월 29일
-1 genrally means unauthorized or badly formatted request.
Frederic Lhoest
2022년 9월 29일
Ok thanks !
Frederic Lhoest
2022년 10월 12일
All works ! ;)
I created a framework to assist me retrieving data : https://github.com/flhoest/ThingSpeak/blob/main/tsFramework.php
Christopher Stapels
2022년 10월 14일
Thanks for sharing! I made a small pull request to keep people who use the function in a loop from slamming the server.
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!