|
1 | | -# outscraper-java |
2 | | -The library provides convenient access to the Outscraper API from applications written in the Java language. Allows using Outscraper's services from your code. |
| 1 | +# Outscraper Java Library |
| 2 | + |
| 3 | +The library provides convenient access to the [Outscraper API](https://app.outscraper.com/api-docs) from applications written in the Java language. Allows using [Outscraper's services](https://outscraper.com/services/) from your code. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +Java 11 or later |
| 8 | + |
| 9 | +### Gradle users |
| 10 | + |
| 11 | +Add this dependency to your project's build file: |
| 12 | +``` sh |
| 13 | +implementation "com.outscraper:outscraper-java:0.0.1" |
| 14 | +``` |
| 15 | + |
| 16 | +### Others |
| 17 | + |
| 18 | +You'll need to manually install the following JARs: |
| 19 | + |
| 20 | +- [The Outscraper JAR](https://search.maven.org/remote_content?g=com.outscraper&a=outscraper-java&v=LATEST) |
| 21 | +- [Json](https://repo1.maven.org/maven2/org/json/json/20090211/json-20090211.jar) |
| 22 | +- [Httpcomponents](https://repo1.maven.org/maven2/org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13.jar) |
| 23 | +- [Guava](https://repo1.maven.org/maven2/com/google/guava/guava/30.1.1-jre/guava-30.1.1-jre.jar) |
| 24 | + |
| 25 | +## Initialization |
| 26 | +```java |
| 27 | +OutscraperClient client = new OutscraperClient("SECRET_API_KEY"); |
| 28 | +``` |
| 29 | +[Link to the profile page to create the API key](https://app.outscraper.com/profile) |
| 30 | + |
| 31 | +## Usage |
| 32 | + |
| 33 | +```java |
| 34 | +// Search for businesses in specific locations: |
| 35 | +JSONArray results = client.googleMapsSearchV2(new HashMap<String, Object>() {{ |
| 36 | + put("query", "bars ny usa"); |
| 37 | + put("limit", 10); |
| 38 | +}}); |
| 39 | +System.out.println(results); |
| 40 | + |
| 41 | +// Get data of the specific place by id |
| 42 | +JSONArray results = client.googleMapsSearchV2(new HashMap<String, Object>() {{ |
| 43 | + put("query", "rChIJrc9T9fpYwokRdvjYRHT8nI4"); |
| 44 | + put("language", "en"); |
| 45 | +}}); |
| 46 | +System.out.println(results); |
| 47 | + |
| 48 | +// Get reviews of the specific place by id |
| 49 | +JSONArray results = client.googleMapsReviewsV3(new HashMap<String, Object>() {{ |
| 50 | + put("query", "rChIJrc9T9fpYwokRdvjYRHT8nI4"); |
| 51 | + put("reviewsLimit", 20); |
| 52 | + put("language", "en"); |
| 53 | +}}); |
| 54 | +System.out.println(results); |
| 55 | + |
| 56 | +// Search contacts from website |
| 57 | +JSONArray results = client.emailsAndContacts(new HashMap<String, Object>() {{ |
| 58 | + put("query", "outscraper.com"); |
| 59 | +}}); |
| 60 | +System.out.println(results); |
| 61 | +``` |
| 62 | + |
| 63 | +[More examples](https://github.com/outscraper/outscraper-java/tree/master/examples) |
| 64 | + |
| 65 | +## Contributing |
| 66 | +Bug reports and pull requests are welcome on GitHub at https://github.com/outscraper/outscraper-java. |
0 commit comments