wp_remote_get with Google Books API

I’m pretty sure you have to add the keywords or the search terms directly to the query, for example:

$key = 'flowers'; // search for word flowers in book titles.

// fill rest in as you desire
$args = array(
     'timeout' => '5',
     'redirection' => '5',
     'sslverify' => false // for localhost
);

//check for titles using +intitle
$response = wp_remote_get( 'https://www.googleapis.com/books/v1/volumes?q='. $key . '+intitle', $args );

This returns:

  "kind": "books#volumes",
     "totalItems": 795,
      //...etc etc

      'response' => 
    array
      'code' => int 200
     //etc etc..

Not sure how accurate the API is because the first book returned clearly does not have the word flowers in the title, it returns “Encyclopaedia Britannica”, but I have not read the API docs.

Also for better quick debugging throw this into a plugin or your functions.php:

add_action( 'http_api_debug', 'viper_http_api_debug', 10, 5 );

function viper_http_api_debug( $response, $type, $class, $args, $url ) {
    // You can change this from error_log() to var_dump() but it can break AJAX requests
    var_dump( 'Request URL: ' . var_export( $url, true ) );
    var_dump( 'Request Args: ' . var_export( $args, true ) );
    var_dump( 'Request Response : ' . var_export( $response, true ) );
}