Json REST API Client

Easy null-safe to use starting point to implement a client library for a json REST API.

Usage

Create your client

  final dummyApiClientV1 =
      JsonRestApiClient(Uri.parse('http://dummy.restapiexample.com/api/v1'));

Perform a GET request with optional query paramters

Let the JsonRestApiClient do the query component encoding.

  final response1 = await dummyApiClientV1.request(
    'GET',
    '/employee/1',
    queryParameters: {'foo': 'bar'}
  );

Perform any other request and send json data

  final response2 = await dummyApiClientV1.request(
    'POST',
    '/create',
    json: {
      'employee_name': 'Tiger Nixon',
      'employee_salary': 320800,
      'employee_age': 61,
    },
  );

You are able to send arrays too

  final response2 = await dummyApiClientV1.request(
    'PATCH',
    '/sendarray',
    json: ['foo', 'bar'],
  );

Libraries

json_rest_api_client
Easy to use starting point to implement a client library for a json REST API.