Firebase API Client Libraries for Dart

Overview

Firebase API Client Libraries for Dart

melos

This is based on the googleapis.dart repository but instead aimed at supporting Firebase related APIs only. Additionally, this adds support for several unlisted (but discoverable) Firebase APIs that are not listed on the official discovery API that googleapis.dart uses (and is currently limited to) as well as several private APIs (APIs that require an API key to view discovery information).

See ./generated/firebaseapis/README.md for information on all the currently supported APIs.

Usage Example

// Import the APIs you want to use
import 'package:firebaseapis/firebaseremoteconfig/v1.dart' as remote_config;
import 'package:firebaseapis/firebaserules/v1.dart' as firebase_rules;
// Import Auth client
import 'package:googleapis_auth/auth_io.dart' as auth;

// Get an Auth Client
final authClient = await auth.clientViaApplicationDefaultCredentials(scopes: [
  remote_config.FirebaseRemoteConfigApi.cloudPlatformScope,
]);

// Call some APIs
final rc = remote_config.FirebaseRemoteConfigApi(authClient);
final config =
  await rc.projects.getRemoteConfig('projects/
   
    '
   );
print(config.parameters);
print(config.parameters?.values.first.defaultValue);
print(config.parameters?.values.first.description);
print(config.parameters?.values.first.valueType);

final fr = firebase_rules.FirebaseRulesApi(authClient);
final rules =
  await fr.projects.rulesets.list('projects/
   
    '
   );
print(rules.rulesets?.first.name);
print(rules.rulesets?.first.source?.files?.first.content);

Contributing

This project uses Melos to manage the project and dependencies.

To install Melos, run the following command from your SSH client:

pub global activate melos

Next, at the root of your locally cloned repository bootstrap the projects dependencies:

melos bootstrap

The bootstrap command locally links all dependencies within the project without having to provide manual dependency_overrides. This allows all plugins, examples and tests to build from the local clone project.

You do not need to run flutter pub get once bootstrap has been completed.

Adding a new API

To add a new API and generate library code for it is fairly straightforward;

  1. Add the API to the apis list in ./config.yaml
  2. Run melos run config:download to update the downloaded discovery document JSON files that are in ./discovery.
    • Note: several APIs require an API key to be able to read the discovery information. Set a API_KEY environment variable before running the command to be able to download the discovery documents for these private APIs, e.g. API_KEY= melos run config:download .
  3. Run melos run config:generate to generate new Dart library code for the API, which outputs to ./generated/firebaseapis.

Maintained by Invertase.

You might also like...

A WordPress API client for dart with support for WooCommerce and custom namespaces.

A WordPress API client for dart with support for WooCommerce and custom namespaces.

WordPress REST API client for Dart | Flutter Description A WordPress REST API client for dart with support for WooCommerce and custom namespaces/endpo

Nov 26, 2022

An API Client for Discord, written in Dart.

discord_api_client An API Client for Discord, written in Dart. Features TODO: List what your package can do. Maybe include images, gifs, or videos. Ge

Feb 15, 2022

Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight Node.js based Bhagavad Gita API [An open source rest api on indian Vedic Scripture Shrimad Bhagavad Gita].

Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight Node.js based Bhagavad Gita API [An open source rest api on indian Vedic Scripture Shrimad Bhagavad Gita].

Gita Bhagavad Gita flutter app. Download App - Playstore Web Application About Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight No

Apr 5, 2022

Beautiful Weather App using API with support for dark mode. Created by Jakub Sobański ( API ) and Martin Gogołowicz (UI, API help)

Beautiful Weather App using API with support for dark mode. Created by Jakub Sobański ( API ) and Martin Gogołowicz (UI, API help)

Flutter Weather App using API with darkmode support Flutter 2.8.1 Null Safety Beautiful Weather App using https://github.com/MonsieurZbanowanYY/Weathe

Nov 29, 2022

Let's setup Firebase​​ for our Flutter​​ app on Android​, iOS​ and Flutter Web. Setup Firebase to use Firebase products.

Let's setup Firebase​​ for our Flutter​​ app on Android​, iOS​ and Flutter Web.  Setup Firebase to use Firebase products.

Flutter Tutorial - Firebase Setup For Flutter Web Let's setup Firebase for our Flutter app on Android, iOS and Flutter Web. Setup Firebase to use Fire

Apr 27, 2022

A Dart client for the NATS messaging system. Design to use with Dart and Flutter.

Dart-NATS A Dart client for the NATS messaging system. Design to use with Dart and flutter. Flutter Web Support by WebSocket client.connect(Uri.parse(

Nov 18, 2022

Socketio dart server and client - Full Socket.io implementation using Dart Lang

Socketio dart server and client - Full Socket.io implementation using Dart Lang

Getting Started Step 1: Run dart_server.dart Step 2: Android Emulator has proble

Jan 23, 2022

Authentication API client with Flutter (Login, Register, Google Login, Facebook Login, Apple Login)

Authentication API client with Flutter (Login, Register, Google Login, Facebook Login, Apple Login)

Flutter Auth App (Login, Register, Google Login, Facebook Login, Apple Login) To use this client, get the server up and running. Try it out now! App S

Jan 4, 2023

Powerful, helpfull, extensible and highly customizable API's that wrap http client to make communication easier with Axelor server with boilerplate code free.

Powerful, helpfull, extensible and highly customizable API's that wrap http client to make communication easier with Axelor server with boilerplate code free.

flutter_axelor_sdk Powerful, helpful, extensible and highly customizable API's that wrap http client to make communication easier with Axelor server w

Dec 25, 2022
Comments
  • Retrun type of `runAggregationQuery` is different from actual return value

    Retrun type of `runAggregationQuery` is different from actual return value

    I found a bug with runAggregationQuery.

      async.Future<RunAggregationQueryResponse> runAggregationQuery(
        RunAggregationQueryRequest request,
        core.String parent, {
        core.String? $fields,
      }) async {
        final _body = convert.json.encode(request);
        final _queryParams = <core.String, core.List<core.String>>{
          if ($fields != null) 'fields': [$fields],
        };
        final _url =
            'v1/' + core.Uri.encodeFull('$parent') + ':runAggregationQuery';
        final _response = await _requester.request(
          _url,
          'POST',
          body: _body,
          queryParams: _queryParams,
        );
        return RunAggregationQueryResponse.fromJson(
            _response as core.Map<core.String, core.dynamic>);
      }
    

    I got an error here. So I printed out the _response, and it's a list, not a map. So as casting triggers the type error below. 스크린샷 2022-10-21 오후 2 31 18

    Unhandled exception:
    type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>' in type cast
    #0      ProjectsDatabasesDocumentsResource.runAggregationQuery (package:firebaseapis/firestore/v1.dart:1455:19)
    <asynchronous suspension>
    #1      CRUDDocument.countDocuments (package:firestore_migration/src/crud_document.dart:46:9)
    <asynchronous suspension>
    #2      Migration_0_0_1.execute (package:firestore_migration/migrations/versions/0_0_1.dart:30:19)
    <asynchronous suspension>
    #3      main (file:///Users/kimsooyoung/Documents/flutter_packages/firestore_migration/bin/firestore_migration.dart:57:3)
    <asynchronous suspension>
    

    I guess it's because I handed over List<Aggregation> when I called the function. Many aggregations, and many responses, I think. Note that it's because of its type, List. I also got the list response when I handed over only one Aggregation.(in a list)

      Future<int> countDocuments(StructuredQuery structuredQuery) async {
        final request = RunAggregationQueryRequest(
          structuredAggregationQuery: StructuredAggregationQuery(
           // HERE
            aggregations: [
              Aggregation(
                alias: 'result_1',
                count: Count(),
              ),
              Aggregation(
                alias: 'result_2',
                count: Count(),
              ),
            ],
            structuredQuery: structuredQuery,
          ),
        );
        final result =
            await firestoreApi.projects.databases.documents.runAggregationQuery(
          request,
          rootPath,
        );
        final count = int.parse(
            (result.result?.aggregateFields?['result'])?.integerValue ?? '0');
        return count;
      }
    

    So, I tried to make a fix pr, but it seems like a generated code, which is not suitable for a manual fix.

    Also, I searched google API document. Below link is in Ruby, but it seems like it returns Enumerable. https://cloud.google.com/ruby/docs/reference/google-cloud-firestore-v1/latest/Google-Cloud-Firestore-V1-Firestore-Client#Google__Cloud__Firestore__V1__Firestore__Client_run_aggregation_query_instance_

    Any answer on how to fix this would be appreciated!

    References

    • https://github.com/invertase/dart_firebase_apis/blob/main/generated/firebaseapis/lib/firestore/v1.dart#L1455
    opened by swimmingkiim 0
  • clientViaApplicationDefaultCredentials  Null check operator used on a null value

    clientViaApplicationDefaultCredentials Null check operator used on a null value

    I am facing an issue when I use firebase to authenticate with GCP Secret Manager in Flutter:

    [VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: Null check operator used on a null value
    #0      clientViaApplicationDefaultCredentials (package:googleapis_auth/auth_io.dart:77:49)
    

    On Mac I launch in iTerm:

    export GOOGLE_APPLICATION_CREDENTIALS="PATH_TO_JSON_FILE/service-account-file.json"
    

    Then my code is:

    import 'package:googleapis_auth/auth_io.dart' as auth;
    
    final client = await auth.clientViaApplicationDefaultCredentials(scopes: [FirestoreApi.cloudPlatformScope]);
    

    When I launch the app, I have Platform.environment['GOOGLE_APPLICATION_CREDENTIALS']: null

    What is the proper ways to set this variable and to use this package?

    opened by loic-hamdi 0
Owner
Invertase
Building awesome open source products.
Invertase
Dart API Client which wraps the QvaPay API

qvapay_api_client Dart API Client which wraps the QvaPay API The client needs Dio to perform the requests, you must inject an instance in the construc

QvaPay 7 Nov 2, 2022
An Imgur API Client Library that uses Imgur's v3 API for Dart

imgur.dart An Imgur API Client Library that uses Imgur's v3 API for Dart. Usage

null 2 Dec 2, 2022
Import & use javascript libraries in your flutter web projects

Import JS Library Import & use javascript libraries in your flutter web projects. flutter: assets: - assets/howler.js importJsLibrary(url: "./as

Florent CHAMPIGNY 29 Oct 1, 2022
An examples of navigation with the Flutter and GetX libraries

Ejemplos de navegación en Flutter Dentro de este repositorio podrán acceder a ej

null 0 Dec 22, 2021
A Flutter plugin for the native FingerprintJS Pro libraries

FingerprintJS Pro Flutter Official Flutter plugin for 100% accurate device identification, created for the FingerprintJS Pro Server API. This plugin c

FingerprintJS 25 Dec 24, 2022
In this project, we will design a travel app UI with a parallax effect for a unique scroll experience. You will learn how to create your own parallax effect without using external libraries.

Travel App UI In this part, we will design a travel app UI with a parallax effect for a unique scroll experience. You will learn how to create your ow

DebugErrorX 5 Dec 5, 2022
A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package. Built after react apollo

Flutter GraphQL Table of Contents Flutter GraphQL Table of Contents About this project Installation Usage GraphQL Provider [Graphql Link and Headers]

Snowball Digital 45 Nov 9, 2022
A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.

GraphQL Flutter ?? Bulletin See the v3 -> v4 Migration Guide if you're still on v3. Maintenance status: Low. Follow #762 for updates on the planned ar

Zino & Co. 3.1k Jan 5, 2023
Vrchat mobile client - VRChat Unofficial Mobile Client For Flutter

VRChatMC VRChatの非公式なAPIを利用したVRChatのモバイルクライアント Flutterで作成されたシンプルなUIが特徴的です iosビルドは

ふぁ 8 Sep 28, 2022
Mysql.dart - MySQL client for Dart written in Dart

Native MySQL client written in Dart for Dart See example directory for examples

null 48 Dec 29, 2022