All Projects → josueeduardo → Rest Client

josueeduardo / Rest Client

Licence: mit

Programming Languages

java
68154 projects - #9 most used programming language

Labels

Projects that are alternatives of or similar to Rest Client

Gimlet
A micro web application framework for OpenResty written in Moonscript inspired by Martini & Sinatra.
Stars: ✭ 23 (+15%)
Mutual labels:  rest-api
Express Boilerplate
🚀 Starter project for a RESTful API in Node with Express & mongoose component-based
Stars: ✭ 9 (-55%)
Mutual labels:  rest-api
Rest Api Examples
Test and Prototype with Fake Online REST/OAuth 2 APIs Examples
Stars: ✭ 13 (-35%)
Mutual labels:  rest-api
Nestjs Cqrs Starter
Nestjs-cqrs API
Stars: ✭ 25 (+25%)
Mutual labels:  rest-api
Detor
🙊 A simple REST API to identify requests made from TOR network.
Stars: ✭ 26 (+30%)
Mutual labels:  rest-api
Spring Boot Rest Api Example
Implement REST APIs using Spring Boot and Spring Session.
Stars: ✭ 10 (-50%)
Mutual labels:  rest-api
Koa Typeorm Starter
Starter project for using koa with TS and TypeORM
Stars: ✭ 23 (+15%)
Mutual labels:  rest-api
Apps Android Wikiedudashboard
Access WikiEdu Dashboard from Android App.
Stars: ✭ 20 (+0%)
Mutual labels:  rest-api
Swagger Core
Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API
Stars: ✭ 6,898 (+34390%)
Mutual labels:  rest-api
Sentence Aligner Rust
rest service + frontend to align sentences , in rust
Stars: ✭ 13 (-35%)
Mutual labels:  rest-api
Nodejs Restapi Using Express Mysql
Nodejs Restful API for CRUD operation using MySQL
Stars: ✭ 25 (+25%)
Mutual labels:  rest-api
Project Dashboard With Django
Agile Project Management dashboard with Django REST and Vue.js
Stars: ✭ 25 (+25%)
Mutual labels:  rest-api
Symfony Api Skeleton
rest api skeleton based on symfony-flex, api-platform, fosuserbundle etc.
Stars: ✭ 11 (-45%)
Mutual labels:  rest-api
Django Rest Booking Api
A Restful api which allows you to book sports events or update existing odds.
Stars: ✭ 24 (+20%)
Mutual labels:  rest-api
Swagger Editor
Swagger Editor
Stars: ✭ 7,365 (+36725%)
Mutual labels:  rest-api
Unity Powershell
PowerShell module for managing EMC Unity arrays
Stars: ✭ 23 (+15%)
Mutual labels:  rest-api
Flask Scaffold
Prototype Database driven Web apps in Angular 6, Bootstrap 4 and REST API's with Flask (Python 3 framework)
Stars: ✭ 853 (+4165%)
Mutual labels:  rest-api
E Commerce 2 django
Guest register, user register, user login, user logout, account home page, product view history, change password, reset password, change name, send activation email when register, resend activation email, add shipping address, add billing address, add nickname to the addresses, edit shipping address, edit billing address, view list of your addresses, reuse shipping addresses when order products, reuse billing addresses when ordeer products, show sales analytics if staff or admin only using -chart.js-, get analytics data with Ajax, receive marketing email, change if user will receive marketing email or not by admin, send contact message with Ajax, products list, product detail, download product detail as a PDF file, download digital product files -if the user purchased that digital product only-, orders list, list of digital products files, order detail, download order detail as a PDF file, verify order ownership with Ajax -to secure order detail page-, show cart products, add or remove product from cart, checkout page, thanks page when order placed successfully, add or reuse payment method, add or reuse payment method with Ajax, search products by title, search products by description, search products by price, search products by tag title, write tags for products -by admin only-, auto fill contact email, full name if user logged in.
Stars: ✭ 20 (+0%)
Mutual labels:  rest-api
Restforms
Forms adapter for InterSystems Cache
Stars: ✭ 14 (-30%)
Mutual labels:  rest-api
Binding Of Isaac Api
A RESTful API for the Binding of Isaac game series
Stars: ✭ 11 (-45%)
Mutual labels:  rest-api

RestClient - Unirest fork

This fork is intended to fix the bugs left by the original authors, improve the API, and provide continuous support. Improvements, new ideas, and bug reports are always welcome. The

License

Features

Apart from the features provided by the original Unirest Java, this fork also has:

  • Updated API to make use of Java 8
  • Major Bug fixes
  • Support for multiple independent clients
  • General API improvements
  • Updated async requests to use Java 8 CompletableFuture
  • Lazy response body parsing
  • Default Gson parser

Maven

<dependency>
    <groupId>io.joshworks.unirest</groupId>
    <artifactId>unirest-java</artifactId>
    <version>1.7.1</version>
</dependency>

Creating a new client with defaults

The following example creates a new basic RestClient instance. At the moment, each client will have its own HttpClient sync and async client.

RestClient client = RestClient.builder().build();

Creating Request

RestClient client = RestClient.builder().build();

HttpResponse<JsonNode> jsonResponse = client.post("http://httpbin.org/post")
  .header("accept", "application/json")
  .queryString("apiKey", "123")
  .asJson();

Base url

RestClient client = RestClient.builder().baseUrl("http://my-api.com/v1").build();
String response = client.get("/some-resource").asString();

Unirest client

Unirest provides the same static methods as the original version. It's ideal for simple usage with default configuration.

String response = Unirest.get("http://my-api.com/v1").asString();

Path parameters

With the new API, there's no need to concatenate path parameters, making the it easier and much more convenient to use. You can either provide a varargs path. Or you can use a template and then use .routeParam() to specify its values.

//Sends a request to http://my-api.com/v1/users
String response = client.post("http://my-api.com", "v1", "users").asString();

//Alternatively

//Also Sends a request to http://my-api.com/v1/users
String response = client.get("http://my-api.com/{verion}/{endpoint}")
  .routeParam("verion", "v1")
  .routeParam("endpoint", "users")
  .asString();

Async requests with CompletableFuture

When using asynchronous requests you can use Java 8 CompletableFuture to handle the response. This also gives you the ability to compose multiple requests in a convenient way.

client.get("http://my-api.com/v1/hello")
        .asStringAsync()
        .thenAccept(resp -> {
            System.out.println(resp.body())
         })
         .exceptionally(e -> {
            e.printStackTrace();
            return null;
         });
         

New multipart/form-data and x-www-form-urlencoded API

The new API for form data makes easier to specify the right values for each type of request. When using .part(...) a multipart/form-data request will be sent, .field(...) will create x-www-form-urlencoded request. This makes the interface cleaner and less error prone. The content type is also set automatically.

//multipart
client.post("http://my-service.com/fileUpload")
        .part("param3", value)
        .part("file", new File("test.txt"))
        .asJson();

//form-urlencoded
client.post("http://my-service.com/login")
                .field("username", "admin")
                .field("password", "admin123")
                .asJson();

Serialization

Before using asObject(Class) or .body(Object), is necessary to provide a custom implementation of the ObjectMapper interface. This should be done for each client. Json is supported out-of-the-box, so there's no need to register any other json mapper unless you want a custom configuration. Here's how to configure a new ObjectMapper:

public class XmlMapper implements ObjectMapper {
   
    @Override
    public <T> T readValue(String value, Class<T> valueType) {
        //...
    }

    @Override
    public String writeValue(Object value) {
        //...
    }
}

ObjectMappers.register(MediaType.APPLICATION_XML_TYPE, new XmlMapper());


HttpResponse<User> response = client.post("http://my-api.com/echo-xml")
                .header("Accept", "application/xml")
                .header("Content-Type", "application/xml")
                .body(new User("John"))
                .asObject(User.class);

Client stats

The API also exposes HttpClient's PoolStats, so you can inspect the usage of each client.

   
   ClientStats stats = client.stats();
   int leased = stats.sync.getLeased();
   int available = stats.sync.getAvailable();
   int max = stats.sync.getMax();
   int pending = stats.sync.getPending();

   //All clients
   Map<String, ClientStats> allStats = ClientContainer.stats();
   //...

Exiting an application

RestClient starts a background idle thread monitor, which is a daemon thread. When exiting the application, you can use the ClientContainer to release all the allocated resources, as follows:

//If a client is no longer needed and you want to dispose its resources
client.shutdown();

//When your application is shutting down:
//Closes all client connections and the monitor
ClientContainer.shutdown();

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].