Image Search Abstraction - API

I’m having some trouble finding an API to use for the Image Search Abstraction project.

I’ve already spent hours on this and am pretty frustrated. It seems the major options are google and bing (open to other options, just haven’t been able to find any viable ones).

Google APIs are confusing as hell. Not sure which one to use… I signed up for a key but have no idea how to implement.

Bing looks a lot easier but the service ends in Dec of this year. After that it turns into a paid service on Azure… Do I implement with Bing for the time being and just let it break in Dec?

Any help greatly appreciated.



I used the bing API and found it pretty manageable. I didn’t realize the free service ends in Dec though, that’s too bad. But really, does it matter? Not every project is gonna go on your portfolio; I haven’t looked back at this one since completing it. It’s just for learning.

Thanks for the reply… I completely agree, I was more worried about having to go back and rewrite it if I want the full-stack cert, or even the backend if I haven’t completed it by the time the API is inactivated.

I was unaware of this change to Bing’s TOS…bummer.

If you do end up needing to redo it, you’ll be more experienced by then and probably find Google easier then! Just use Bing for now, it’s pretty easy to work with :slight_smile:

Thanks, I agree, I think that’s my best bet right now.

I was wondering about this myself. Hunting for a free API to use should not be part of the challenge.

I’m trying to use the Google Custom Search API right now, but as near as I can tell it’s complete garbage. After getting a key and fumbling about creating a custom search engine, the results seem to be useless. There is no way I can find to scope the search to images only.

I agree. I didn’t actually know it was expected that I would use an API until I searched Gitter.

It’s a surprising omission, since the Nightlife app instructions specify using the Yelp API. That said, the stock app doesn’t specify an API…seems to be random as to whether or not FCC decides to hold your hand at that point. I would prefer that they suggested an API to use, since the coding presents enough challenges without having to burn several hours researching and testing various APIs.

I just finished mine, I used the Imgur Gallery Search API.

It’s an alright API, it can either return: (1) link to a gallery with the first image, (2) an image. #2 you can extract thumbnails, but not with #1. There is an endpoint to get thumbnails but that is on a per-image basis.

Fun times:

Your account has been temporarily suspended
Someone may have used your account --------- to send out a lot of junk messages or
done something else that violates the Microsoft Services Agreement.

All my attempts to get an account for this have failed. Hooray. And the text message verification does not work for me. It may be I cannot complete this challenge.

And I’ve never used the account for anything but getting a free subscription to PluralSight for 3 months.

1 Like

I may try using this:

It may not provide all the information the challenge states is required, though.

The correct API appears to be this:

But you need to create your own “custom” search engine and configure it properly. When you do this, you must ensure “Image search” is enabled. (Off by default). In the actual API call I limited fileType to JPG. This may not be necessary.

The JSON payload will match what the fCC example app produces, so it must be the same API.

Good luck!


Thanks. In addition, I installed npm google-search, and had npm dotenv loaded before defining the keys and cse_id from my .env file. With that, I’m up and running. Thanks again.

1 Like

Fantastic. I’m going to install those now, thanks!

I should specify that I am getting search results, and am now trying to figure out how to extract images from the results, but it felt like a win when I saw that console.log

Oh, it’s worth noting that if in excitement you try to directly output the whole JSON reply from Google back to the client, you’ll get a circular reference error.

Error: TypeError: Converting circular structure to JSON

Ultimately, you need to pluck a subset of keys from the data Google sends. You can still inspect the data and send it to console.log this way if you’re curious:

I can’t emphasize enough the value of using mocking and unit testing when working through the data transformation of the response from Google. It includes much information that is likely not valuable for this challenge and it’s easier to iterate through a solution to extract just what you need if you aren’t constantly hitting the actual API.

For this, I used axios, axios-mock-adapter, tape, and ramda. The latter can make the data transformation easier, but it isn’t as popular as other functional libraries so Google is not as useful here. The imperative approach to transforming the data works fine, too.

It seems the cse_thumbnail and cse_image keys are optional, so be aware!

1 Like

So how does that work, do you need to hit the Google API once to get a sample of JSOn then hard code that while using axios/mock?

Yes, that’s ultimately what I ended up doing.

Hi guys.

Does any of you tried flickr api for this project?

I tried to use it since Bing is gone, and Google’s one is a bit confusing. But on Flickr I can’t seem to figure out how to get links to images. If anyone knows how to get them, please help me out.

Thanks a lot.