{$mode objfpc}{$H+}
uses
opensslsockets,fphttpclient,fpjson,jsonparser;
var
SearchResult,ResultItem: TJSONObject;
ResultEnum: TJSONEnum;
begin
SearchResult := GetJSON(TFPHTTPClient.SimpleGet('https://www.googleapis.com/customsearch/v1?key=<use yours>&cx=<also use yours>&q=<your query here>')) as TJSONObject;
for ResultEnum in SearchResult.Find('items') do begin
ResultItem := ResultEnum.Value as TJSONObject;
WriteLn(ResultItem['title'].AsString);
WriteLn(ResultItem['link'].AsString);
WriteLn(ResultItem['snippet'].AsString);
WriteLn;
end;
SearchResult.Free;
end.