Google image search says api no longer available - google-api

I am using google image search API. Till yesterday it was working, but today morning it says "This API is no longer available"
Is it officially closed, Or any error at my side
Request
https://ajax.googleapis.com/ajax/services/search/images?v=1.0&rsz=8&q=cute+kittens
Response
{"responseData": null, "responseDetails": "This API is no longer available.", "responseStatus": 403}

The answer I found was using Google's Custom Search Engine (CSE) API. Note that this is limited to 100 free requests per day.
Creating cx and modifying it to search for images
Create custom search engine at https://cse.google.com/cse/create/new based on your search criteria.
Choose sites to search (leave this blank if you want to search the entire web, otherwise you can enter a site to search in one particular site)
Enter a name and a language for your search engine.
Click "create." You can now find cx in your browser URL.
Under "Modify your search engine," click the "Control Panel" button. In the "edit" section you will find an "Image Search" label with an ON/OFF button, change it to ON. Click "update" to save your changes.
Conducting a search with the API
The API endpoint url is https://www.googleapis.com/customsearch/v1
The following JSON parameters are used for this API:
q: specifies search text
num: specifies number of results. Requires an integer value between 1 and 10 (inclusive)
start: the "offset" for the results, which result the search should start at. Requires an integer value between 1 and 101.
imgSize: the size of the image. I used "medium"
searchType: must be set to "image"
filetype: specifies the file type for the image. I used `"jpg", but you can leave this out if file extension doesn't matter to you.
key: an API key, obtained from https://console.developers.google.com/
cx: the custom search engine ID from the previous section
Simply make a GET request by passing above parameters as JSON to the API endpoint (also listed above).
Note: If you set a list of referrers in the search engine settings, visiting the URL via your browser will likely not work. You will need to make an AJAX call (or the equivalent from another language) from a server specified in this list. It will work for only the referrers which were specified in the configuration settings.
Reference:
https://developers.google.com/custom-search/json-api/v1/reference/cse/list

Now You can search images with Custom image search API.
You can do this with two steps:
Get CUSTOM_SEARCH_ID
Go to - https://cse.google.ru/cse/all
Here you must create new Search Engine. Do this and enable Image Search at there.
Screen(i am Russian... sorry)
then get this search engine ID. To do this press at Get Code button:
And there find line with cx = "here will be your CUSTOM_SEARCH_ID":
Ok. It's done, now second step:
Get SERVER_KEY
Go to google Console - https://console.developers.google.com/project
Press to Create project button, enter the name and other required information.
Pick this project and go to Enable Apis
Now find Custom Search Engine.
And Enable it.
Now we must go to Credentials and create new Server Key:
Ok. Now we can use Image Search.
Query:
https://www.googleapis.com/customsearch/v1?key=SERVER_KEY&cx=CUSTOM_SEARCH_ID&q=flower&searchType=image&fileType=jpg&imgSize=xlarge&alt=json
Replace the SERVER_KEY and CUSTOM_SEARCH_ID and call this request.
Limit: for free you can search only 100 images per day.

If this is just for your own purposes (not for production) and you're not planning to abuse Google Image Search, you can simply extract first image URL from Google search results using JSOUP.
For example:
Code to retrieve image URL of the first thumbnail:
public static String FindImage(String question, String ua) {
String finRes = "";
try {
String googleUrl = "https://www.google.com/search?tbm=isch&q=" + question.replace(",", "");
Document doc1 = Jsoup.connect(googleUrl).userAgent(ua).timeout(10 * 1000).get();
Element media = doc1.select("[data-src]").first();
String finUrl = media.attr("abs:data-src");
finRes= "<img src=\"" + finUrl.replace("&quot", "") + "\" border=1/>";
} catch (Exception e) {
System.out.println(e);
}
return finRes;
}
Guide:
question - image search term
ua - user agent of the browser

After I read several responses I compiled a response with images:
Access the website: https://developers.google.com/custom-search/v1/introduction, on the page you will find this part, so click in the button Get a Key:
Create or select a project, and then NEXT:
Copy the API KEY:
Access the website to create your CX: https://cse.google.com/cse/create/new, write some random domain like “www.anypage.com”, (after we will delete), select a language, and define some name for your search engine. Click on the Button CREATE.
Will see this page, then click in Control Panel:
Copy the Search engine ID for later (this is your CX). After you can set to search in all websites (active Search the entire web, select on the random website www.anypage.com then click on the button Delete) and you can active Image search. So will see like this:
And Using REST you can get the results, using this example code (searching for flower):
<html lang="pt">
<head>
<title>JSON Custom Search API Example</title>
</head>
<body>
<div id="content"></div>
<script>
function hndlr(response) {
console.log(response);
for (var i = 0; i < response.items.length; i++) {
var item = response.items[i];
// in production code, item.htmlTitle should have the HTML entities escaped.
document.getElementById("content").innerHTML += "<br>" + item.htmlTitle;
}
}
</script>
<script src="https://www.googleapis.com/customsearch/v1?key=API_KEY&cx=SEARCH_ENGINE_KEY&q=flower&searchType=image&callback=hndlr"></script>
</body>
</html>
The base code is found here: https://developers.google.com/custom-search/v1/using_rest
After setting your API_KEY (key) and your SEARCH ENGINE KEY (cx), the result will see like this:
Thanks to #Vijay Shegokar, #aftamat4ik and #Alladinian

This is the full URL template to be used
We can eliminate unnecessary parameters.
https://www.googleapis.com/customsearch/v1?q={searchTerms}&num={count?}&start={startIndex?}&lr={language?}&safe={safe?}&cx={cx?}&cref={cref?}&sort={sort?}&filter={filter?}&gl={gl?}&cr={cr?}&googlehost={googleHost?}&c2coff={disableCnTwTranslation?}&hq={hq?}&hl={hl?}&siteSearch={siteSearch?}&siteSearchFilter={siteSearchFilter?}&exactTerms={exactTerms?}&excludeTerms={excludeTerms?}&linkSite={linkSite?}&orTerms={orTerms?}&relatedSite={relatedSite?}&dateRestrict={dateRestrict?}&lowRange={lowRange?}&highRange={highRange?}&searchType={searchType}&fileType={fileType?}&rights={rights?}&imgSize={imgSize?}&imgType={imgType?}&imgColorType={imgColorType?}&imgDominantColor={imgDominantColor?}&alt=json
I am using
https://www.googleapis.com/customsearch/v1?key=ap_key&cx=cx&q=hello&searchType=image&imgSize=xlarge&alt=json&num=10&start=1

Change the API url to
Google Custom Image search
Provide the same parameters along with with API KEY and CX.
More Info and Explorer

The Yahoo Boss API is a reasonable substitute, although it's not free and the results are not quite as good.
UPDATE: YAHOO BOSS JSON Search API will discontinue on March 31, 2016

SerpAPI enables to search through Google Images and returns a clean json. it integrates with most of the programming languages: python, php, java, golang, nodejs...
https://serpapi.com/images-results
Google limit the number of search per day.
but this service provides unlimited searches...

looks like we need to implement google custom search API
https://developers.google.com/custom-search/
says so on top of the page you provided yourself

Related

Retrieve specific value from api response in google sheets

Sorting out some of my trading cards into google sheets. I would like retrieve the average price of the card using yugiohprices api (https://yugiohprices.docs.apiary.io/#reference/checking-card-prices/check-price-for-cards-print-tag/check-price-for-card's-print-tag?console=1)
I can link the cell to retrieve the cards data. But I would only like to get the average price value
sample sheet
NAME, SET, AVERAGE_PRICE
JINZO PSV-000 =IMPORTDATA(CONCATENATE("https://yugiohprices.com/api/price_for_print_tag/",B2))
https://yugiohprices.com/api/price_for_print_tag/PSV-000
{"status":"success","data":{"name":"Blue-Eyes White Dragon","card_type":"monster","property":null,"family":"light","type":"Dragon / Normal","price_data":{"name":"Legend of Blue Eyes White Dragon","print_tag":"LOB-001","rarity":"Ultra Rare","price_data":{"status":"success","data":{"listings":[],"prices":{"high":125000.0,"low":22.22,"average":81.48,"shift":-0.281354736285059,"shift_3":-0.275475724702116,"shift_7":-0.302755433852473,"shift_21":-0.345173993409949,"shift_30":-0.302874743326489,"shift_90":0.0978172999191593,"shift_180":0.886984715145901,"shift_365":-0.525699982536818,"updated_at":"2022-04-11 13:55:38 -0600"}}}}}}
When you want to retrieve the value from JSON data, I thought that a custom function created by Google Apps Script might be useful.
Sample script:
Please copy and paste the following script to the script editor of Spreadsheet. And save the script. When you use this, please put =SAMPLE("https://yugiohprices.com/api/price_for_print_tag/PSV-000") to a cell. By this, the value of obj.data.price_data.price_data.data.prices.average is retrieved.
function SAMPLE(url) {
const res = UrlFetchApp.fetch(url);
const obj = JSON.parse(res.getContentText());
return obj.data.price_data.price_data.data.prices.average;
}
Testing:
When this script is run using =SAMPLE("https://yugiohprices.com/api/price_for_print_tag/PSV-000"), the following result is obtained.
Note:
If the above custom function doesn't work, please reopen Spreadsheet and test it again.
References:
Custom Functions in Google Sheets

How to search Zoho custom module using API v2?

I am using an access token with ZohoCRM.modules.custom.READ.
When I send a GET request to https://www.zohoapis.com/crm/v2/Custom/search, I get the following error.
{
"code": "INVALID_MODULE",
"details": {},
"message": "the module name given seems to be invalid",
"status": "error"
}
What am I doing wrong and how do I define the module I am trying to pull data from (it is called CustomModule2)?
Figured it out...
First, needed to go to https://crm.zoho.com/crm/{org_id}/settings/modules to find the actual name of CustomModule2 which is Adresses livraison.
Then, needed to go to https://crm.zoho.com/crm/{org_id}/settings/api/modules to find the API name for Adresses livraison which is Adresses_livraison.
Finally, needed to go to https://crm.zoho.com/crm/{org_id}/settings/api/modules/CustomModule2?step=FieldsList to find the API name of the field I wanted to use as a search criteria (it was Compte].
The final query using httpie is as follows.
http GET https://www.zohoapis.com/crm/v2/Adresses_livraison/search \
Authorization:"Zoho-oauthtoken {access_token}" \
criteria=="(Compte:equals:{account_id})"
Zoho is up there in the most awkward developer experiences I have encountered.
Just an update for anyone still looking into this, because I noticed that the links aren't always the same, depending on whether it's a sandbox or not, etc. So the steps are:
Go to your CRM page/dashboard and click on the Settings (cogwheel icon) on the top-right, next to your account image.
A bunch of items in panel boxes open. In the panel named "Developer Space" choose APIs
There it opens a bunch of tabs and sub-tabs and a Dashboard (As shown on the image below). The "Dashboard" sub-tab should be selected, all you have to do is switch to the sub-tab "API-Names"

Accuracy of wbsearchentities in wikidata API [duplicate]

I'm using wbsearchentities (wikidata api) in a python request and I'm wondering why returned results are not the same that those seen on Wikidata. For example, the following command in Python:
url = "https://www.wikidata.org/w/api.php?action=wbsearchentities&search=%s&format=json&limit=50&formatversion=2&language=en" % ('New York Landmarks Preservation Commission')
r = requests.post(url,headers={"User-Agent" : "Magic Browser"})
returns nothing but the same search in the search box of Wikidata returns 2 results (one is the good one: New York City Landmarks Preservation Commission.
Ideally, I would like to have all these results returned from my python request.
The search box in the top right of Wikidata uses the wbsearchentities API module to provide the auto suggestion dropdown search.
If you press enter after entering your search instead of clicking on one of the suggestions you will end up on the Special:Search page.
As you can see they API result returns no results but the special page does.
That is due to these searches working in entirely different ways.
The Special:Search page is a MediaWiki concept that Wikibase provides
data to.
The wbsearchentities API module provided by Wikibase itself.

facebook userid from username in excel power query

I have been spending time on excel power query in the past two days but did not figure out how to fetch facebook userid if i have the username.
For instance, if I have the username zuck OR
the profile url https://www.facebook.com/zuck
using any of the above, is it possible to find the uid (facebook numeric id). In this example, the ID is 4
Somewhat similar to what http://findmyfbid.com does, I want to find out if it is possible with excel power query.
Thanks
Looking around the Power Query Facebook connector and the Facebook Graph API reference I can't find any obvious way to look up user id's from the username.
http://findmyfbid.com/failure indicates that a search engine had to index the public usernames in order to find the id. You can open a page like https://www.facebook.com/Code.org/ in your browser and muck through the HTML and find the username yourself, assuming the page is still public.
On the other hand, findmyfbid.com has already solved this problem. Here's how to query against their website directly using a custom Power Query function FindId:
let
// Assume you've already URL-encoded the id
FindId = (id as text) as text =>
let
Source = Web.Contents("http://findmyfbid.com/", [
Content = Text.ToBinary("url=" & id),
Headers = [#"Content-Type"= "application/x-www-form-urlencoded"]
]),
// Web.Page can't POST directly, so force Web.Contents to execute the POST
WebPage = Web.Page(Binary.Buffer(Source)),
// Hopefully findmyfbid.com doesn't change their HTML layout
DrillDown = WebPage[Data]{0}
{[Name="HTML"]}[Children]
{[Name="BODY"]}[Children]
{[Name="DIV"]}[Children]
{[Name="DIV"]}[Children]
{[Name="CODE"]}[Children]
{[Kind="Text"]}[Text]
in
DrillDown,
ExampleCodeOrg = FindId("code.org")
in
ExampleCodeOrg
And you find that Code.org has an Id of 309754825787494.

Sitefinity: Where can I find the master GUID for a content item?

I'm building a web service for a client that pulls data from the Sitefinity CMS. The problem is they want to pass in a Guid for the service and receive the info about this item. No problem except I only have been able to locate the "live" Guid for one Item (and that was by combing through the HTML in the back end).
I was going to look at the tables in SQL Server but I'm not sure which table to look at. The content items have several tables all related of course and there isn't any documentation on how to look at this. I can find plenty of documentation on querying the master Guid, but no place to find it.
Oh, and these are custom content types built by the Module Builder.
Any Help would be SOOOOO appreciated!
var master = DynamicModuleManager.GetManager().Lifecycle.GetMaster(<liveGuidHere>);
One of the biggest consumers of Sitefinity webservices is Sitefinity. The best place to start looking for that guid is to take a look at what web service calls are being made when you pull up your custom content item list in the backend. I used the chrome developer tools and check in the network tab.
One I found for a stores module made with module builder was something to the effect of http://www.testsite.com/Sitefinity/Services/DynamicModules/Data.svc/?managerType=Telerik.Sitefinity.DynamicModules.DynamicModuleManager&providerName=OpenAccessProvider&itemType=Telerik.Sitefinity.DynamicTypes.Model.Stores.Store&provider=OpenAccessProvider&sortExpression=LastModified%20DESC&skip=0&take=50
The json this returns is a list of all the masters with their ids (note in the list that the content items all have have a status of 0) http://www.sitefinity.com/documentation/documentationarticles/developers-guide/sitefinity-essentials/modules/content-lifecycle
When you go to Administration / Module Builder / Your Module, you will see a link to the API on the top right corner.
This link goes to a page full of API examples for your particular module which is kind of cool.
Basically you would have to find your item first using LINQ and the GetValue extension method.
Once you have the item you can get its ID or any other property.
using Telerik.Sitefinity.Utilities.TypeConverters;
using Telerik.Sitefinity.DynamicModules;
using Telerik.Sitefinity.Model;
....
var mgr = DynamicModuleManager.GetManager();
var countrymasters = from ctry in mgr.GetDataItems(TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Destinations.Destination"))
where ctry.GetValue<string>("culture") == siteid &&
(ctry.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && ctry.Visible == true)
select new
{
airport_cd = ctry.GetValue<string>("airport_cd"),
country_master_cd = ctry.GetValue<string>("country_master_cd")
};

Resources