Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Weekly Challenges

Solve the challenge, share your solution and summit the ranks of our Community!

Also available in | Français | Português | Español | 日本語
IDEAS WANTED

Want to get involved? We're always looking for ideas and content for Weekly Challenges.

SUBMIT YOUR IDEA

Challenge #139: Spooky API Connection

JamesCameron
8 - Asteroid

My Effort - took a while. Hat tip to @mbogusz for new api workings

Spoiler
JamesCameron_0-1580228051341.png
dsmdavid
11 - Bolide

This was interesting...It seems the API that was used when this challenge was posted is still active, but not admitting new users (and will phase out at the end of the month) (FYI @JoeM )
I've registered for the API that supersedes this one https://fdc.nal.usda.gov/api-key-signup.html

A quick search suggests the old id's don't seem to exist in the new API/database (web info says you can use ndbid to search, but I've been unable to find those provided in the starting challenge -either using the API or the web searchbox), so I've done two sets of calls: one to search by name, and then get the first result for each;and a second to get the details (i.e. calories). Not surprisingly, the numbers don't quite add up...

 

Spoiler
dsmdavid_0-1584810220113.png

 

 

It should be possible to search using the ndbid, but I get no results

Spoiler
dsmdavid_0-1584811262452.png
but in postman:
dsmdavid_1-1584811362272.png

so I may be doing something wrong..

 

 

Reesetrain2
9 - Comet

All,

 

I had some trouble getting the request for the API as I had to peek at others.

-This is a really good example of an API though.

Spoiler
Capture.PNG

 

CallieYuan
8 - Asteroid

First API workflow

atcodedog05
22 - Nova
22 - Nova

Might want to re look at the weekly challenge question.

The API link might be changes was getting something like below.

https://developer.nrel.gov/api/alt-fuel-stations/v1/nearest.json?api_key=dMl1hnQlgN2PLQMVDNedM2qQ851...

 

I can see some people have pointed it out too 🙂

 

Either ways i took reference of another posted solution to solve the weekly challenge 🙂

 

Spoiler
 
atcodedog05_0-1585895590678.png

 

 

On a spree to binge complete weekly challenges
Adrenaline rush

JennyMartin
9 - Comet
Spoiler
AWC139.PNG

Good API Practice, it's been a while!

Jonathan-Sherman
15 - Aurora
15 - Aurora

Challenge 139 is done!

 

Spoiler
image.png
hanykowska
11 - Bolide

I get slightly different numbers but I was using a different API (as others mentioned the original one doesn't seem to be working)

 

Spoiler
hanykowska_0-1589658370165.png

 

Jean-Balteryx
16 - Nebula
16 - Nebula

Here is my solution !

johnemery
11 - Bolide

Well, I got an answer anyway.

 

As others have mentioned, the original API is no longer active. I used the following URL:

https://api.nal.usda.gov/fdc/v1/foods?fdcIds=[IDs]&api_key=[Key]

where [IDs] is a comma-separated list of IDs and [Key] is your API key.

 

The candy IDs have also changed. I used the following list:

Snickers 789264
Candy Corn 425594
Tootsie Roll Pop 427751
Sweetarts 570272
Atomic Fireballs 476145
Chewy Sours 789635
Sour Patch Kids 579277

 

My final answer doesn't match the solution. I assume this is due to the changes with the API. Otherwise, I believe my workflow to be logically correct.

 

Spoiler
Capture.PNG