Skip to content

A basic rest api interaction service to streamline API communication based on the http package

License

Notifications You must be signed in to change notification settings

Iconica-Development/dart_api_service

Repository files navigation

A simple API service that follows a FirebaseFirestore-like definition of resource endpoints.

Features

  • Call endpoints with Put, Patch, Delete, Post and Get http methods
  • Use converters for type safe interaction with endpoints.
  • Allow authentication due to an auth credentials service.

Getting started

To use the this API service in your Dart or Flutter, add the following to the pubspec

  flutter_start:
    git:
      url: https://github.com/Iconica-Development/dart_api_service
      ref: <Version>

Usage

TODO: Include short and useful examples for package users. Add longer examples to /example folder.

  var authService = MockAuthService();
  var apiService = HttpApiService(
    baseUrl: Uri.parse("https://jsonplaceholder.typicode.com"),
    authenticationService: authService,
  );

  var converter = ApiConverter.fromSerializable(PostComment.fromMap);

  var endPoint = apiService.endpoint("/posts/:post");
  var comments = endPoint
      .child("/comments")
      .withConverter(
        converter.list(),
      )
      .authenticate()
      .addHeaders({
    "accept": "application/json",
  }).withVariables({
    "post": 1,
  });

  try {
    var post = await comments.get();
    print(post.result);
  } on ApiException catch (e) {
    print(e.statusCode);
    print(e.inner.body);
  }

Issues

Please file any issues, bugs or feature request as an issue on our GitHub page. Commercial support is available if you need help with integration with your app or services. You can contact us at [email protected].

Want to contribute

If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our contribution guide and send us your pull request.

Author

This dart_api_service for Flutter and Dart is developed by Iconica. You can contact us at [email protected]

About

A basic rest api interaction service to streamline API communication based on the http package

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages