I want search result like Google search.
Here if I search for 'tokyo' then it gives me four results containing place 'tokyo'. Same functionality I want to do using Foursquare API. Currently I am able to find near places from current position or given position.
You need to use the https://api.foursquare.com/v2/venues/search endpoint and use the query parameter so that it will return matches based on your keyword. Since you're on iOS you can use UITableView to show the results as search suggestions or other libraries that fit your requirement. Since it will be like an autocomplete/autosuggest search, I suggest that you try to call the endpoint on the change event of the text field with a delay.
Example using AFNetworking Library for iOS:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
[params setObject:FOURSQUARE_CLIENTID forKey:@"client_id"];
[params setObject:FOURSQUARE_CLIENTSECRET forKey:@"client_secret"];
[params setObject:searchTextField.text forKey:@"query"];
[params setObject:LatLong forKey:@"ll"];
[params setObject:FOURSQUARE_VERSION forKey:@"v"];
[manager GET:@"https://api.foursquare.com/v2/venues/search" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
//Process the JSON response here and output each venue name as search suggestion
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
I suggest you read more on the FourSquare documentation and how to process JSON results and show them to a UITableView if you don't know how to yet.
Also notice that you still have to provide your "ll" as parameter since you can only query for nearby places using the endpoint.
For global search and not using "ll" or "nearby" parameter. You can try to use the global intent which according to the documentation:
Finds the most globally relevant venues for the search, independent of location. Ignores all other parameters other than query and limit.