Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![serpapi-java](https://github.com/serpapi/serpapi-java/actions/workflows/gradle.yml/badge.svg)](https://github.com/serpapi/serpapi-java/actions/workflows/gradle.yml)
[![](https://jitpack.io/v/serpapi/serpapi-java.svg)](https://jitpack.io/#serpapi/serpapi-java)

Integrate search data into your Java application. This library is the official wrapper for SerpApi (https://serpapi.com).
Integrate search data into your Java application. This library is the official wrapper for [SerpApi](https://serpapi.com).

SerpApi supports Google, Google Maps, Google Shopping, Baidu, Yandex, Yahoo, eBay, App Stores, and more.

Expand Down Expand Up @@ -539,6 +539,54 @@ System.out.println(results.toString());
see: [https://serpapi.com/images-results](https://serpapi.com/images-results)


## Migration from google-search-results-java

If you are upgrading from the legacy [`google-search-results-java`](https://github.com/serpapi/google-search-results-java) library, here is a summary of what changed.

### Dependency

```gradle
// before
implementation 'com.github.serpapi:google-search-results-java:2.0.0'

// after
implementation 'com.github.serpapi:serpapi-java:1.1.0'
```

### Class and method renames

| Old (`google-search-results-java`) | New (`serpapi-java`) |
|------------------------------------|----------------------|
| `GoogleSearch` | `SerpApi` |
| `SerpApiSearch` | `SerpApi` |
| `client.getJson()` | `client.search(parameter)` |
| `client.getHtml()` | `client.html(parameter)` |
| `client.getSearchArchive(id)` | `client.searchArchive(id)` |
| `client.getAccount()` | `client.account()` |
| `client.getLocation(parameter)` | `client.location(parameter)` |
| `SerpApiSearchException` | `SerpApiException` |

### Example

```java
// before
Map<String, String> parameter = new HashMap<>();
parameter.put("q", "coffee");
parameter.put("api_key", "your_api_key");
GoogleSearch search = new GoogleSearch(parameter);
JsonObject results = search.getJson();

// after
Map<String, String> auth = new HashMap<>();
auth.put("api_key", "your_api_key");
SerpApi client = new SerpApi(auth);

Map<String, String> parameter = new HashMap<>();
parameter.put("q", "coffee");
parameter.put("engine", "google");
JsonObject results = client.search(parameter);
```

### Contributing

We use JUnit, **GitHub Actions** (see [workflow](https://github.com/serpapi/serpapi-java/blob/master/.github/workflows/gradle.yml)), and Gradle.
Expand Down
50 changes: 49 additions & 1 deletion README.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ end
[![serpapi-java](https://github.com/serpapi/serpapi-java/actions/workflows/gradle.yml/badge.svg)](https://github.com/serpapi/serpapi-java/actions/workflows/gradle.yml)
[![](https://jitpack.io/v/serpapi/serpapi-java.svg)](https://jitpack.io/#serpapi/serpapi-java)

Integrate search data into your Java application. This library is the official wrapper for SerpApi (https://serpapi.com).
Integrate search data into your Java application. This library is the official wrapper for [SerpApi](https://serpapi.com).

SerpApi supports Google, Google Maps, Google Shopping, Baidu, Yandex, Yahoo, eBay, App Stores, and more.

Expand Down Expand Up @@ -276,6 +276,54 @@ see: [https://serpapi.com/google-play-api](https://serpapi.com/google-play-api)
see: [https://serpapi.com/images-results](https://serpapi.com/images-results)


## Migration from google-search-results-java

If you are upgrading from the legacy [`google-search-results-java`](https://github.com/serpapi/google-search-results-java) library, here is a summary of what changed.

### Dependency

```gradle
// before
implementation 'com.github.serpapi:google-search-results-java:2.0.0'

// after
implementation 'com.github.serpapi:serpapi-java:1.1.0'
```

### Class and method renames

| Old (`google-search-results-java`) | New (`serpapi-java`) |
|------------------------------------|----------------------|
| `GoogleSearch` | `SerpApi` |
| `SerpApiSearch` | `SerpApi` |
| `client.getJson()` | `client.search(parameter)` |
| `client.getHtml()` | `client.html(parameter)` |
| `client.getSearchArchive(id)` | `client.searchArchive(id)` |
| `client.getAccount()` | `client.account()` |
| `client.getLocation(parameter)` | `client.location(parameter)` |
| `SerpApiSearchException` | `SerpApiException` |

### Example

```java
// before
Map<String, String> parameter = new HashMap<>();
parameter.put("q", "coffee");
parameter.put("api_key", "your_api_key");
GoogleSearch search = new GoogleSearch(parameter);
JsonObject results = search.getJson();

// after
Map<String, String> auth = new HashMap<>();
auth.put("api_key", "your_api_key");
SerpApi client = new SerpApi(auth);

Map<String, String> parameter = new HashMap<>();
parameter.put("q", "coffee");
parameter.put("engine", "google");
JsonObject results = client.search(parameter);
```

### Contributing

We use JUnit, **GitHub Actions** (see [workflow](https://github.com/serpapi/serpapi-java/blob/master/.github/workflows/gradle.yml)), and Gradle.
Expand Down
Loading