Docs
FireSnippets
FireSnippetsDocumentation | Fire Snippets Docs

Documentation

An introduction to FireSnippets, a library that simplifies Firebase integration.

The basics

The FireSnippets library provides programmatic access to Firebase functionalities, allowing developers to build custom features to do things like sync real-time data and user authentication with their web applications, manage Firestore databases, and more.

To use FireSnippets, you need a Firebase project and a FireSnippets API key. What you can do with the library depends on how you integrate it into your project. Once you have a Firebase project set up and have obtained an API key from your FireSnippets dashboard, you can begin using the library in your applications.

Using FireSnippets

Whether you're managing your own web applications, providing Firebase services to your customers or clients, or writing a mobile app, the FireSnippets library has features to manage and sync your data with minimal setup.

You can also use FireSnippets to handle data in different ways for different purposes. If you are syncing a large amount of data with Firebase, you can use batch operations to avoid hitting the API request limits. For building integrations that let other users access data from their own Firebase projects, you should authenticate with OAuth 2. And if you're developing an app for iOS or Android, you can use the native Firebase SDKs alongside FireSnippets to provide a seamless experience.

Library structure

The FireSnippets library generally follows object-oriented conventions, with some deviations.

  • Methods are typically actions like login, signUp, or add.
  • Parameters are passed as arguments to these methods.
  • Responses are usually Promises that resolve with results or reject with errors.
  • Data is handled in JSON format.

We use this documentation to describe each method. The method descriptions also contain type information to help you error-check your code.

The root import for the library is via CDN or NPM package. For example, if you're using a CDN, you can include:

<!-- Include Firebase CDN -->
<script src="https://www.gstatic.com/firebasejs/9.0.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.0.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.0.0/firebase-firestore.js"></script>
 
<!-- Include FireSnippets CDN -->
<script src="https://cdn.firesnippets.com/fire-snippets.js"></script>

If you're using NPM, you can install it via:

npm install fire-snippets

Note: Make sure to replace any placeholder values with your actual API key and snippet IDs in your code to avoid errors.

Connecting to Firebase

You can authenticate requests using either your Firebase configuration or an OAuth access token, depending on your use case. You should use your Firebase configuration if you're writing code that tightly couples your application data to your Firebase project; if you need to access someone else's Firebase data, you should use OAuth 2.

For more information on the Firebase OAuth 2 flow, see the Firebase authentication documentation.

If you're integrating with FireSnippets using one of the supported frameworks, you won't need to worry about the implementation details for authentication, as FireSnippets handles this internally.

Authenticate with an API key or OAuth 2 token

API keys and OAuth 2 tokens can be used to make authenticated requests in similar ways. We'll refer to both as tokens.

You can initialize FireSnippets with your API key:

const fireSnippets = new FireSnippets('your-api-key');

API limits

To improve the experience for all our users, we impose some limits on API requests. These limits prevent a single user from making too many expensive calls at once. Exceeding the limits can result in your API access being disabled, so be mindful of the quantity and complexity of your requests. Currently, there are no options to raise the limit on a per-customer basis.

Throttling

The FireSnippets API has a limit on the number of simultaneous connections. You'll receive a 429 error if you reach the limit. At exceptionally high volumes, you may receive an HTTP 429 or 403 without a JSON body.

We recommend that you cache frequently accessed values that do not change often in your application's data store. This will prevent your application from bumping up against the throttling limitations and will likely provide faster access to that data.

Timeouts

The FireSnippets API has a timeout on API calls. You may see this type of timeout after you've made a network socket connection and are already sending and receiving data.

Response times are dependent on the complexity of your request and the general load across Firebase services. Some methods in the FireSnippets library perform operations that are large and slow to execute. Once you know what data you need, optimize your queries and requests to retrieve only what is essential to you.

Note: Ensure that all your Firebase configurations and FireSnippets settings are correctly set up to avoid errors in your application.


Note: Replace all placeholder values like 'your-api-key', 'your-login-snippet-id', etc., with the actual values provided in your FireSnippets dashboard.


Was this helpful?
Docs
Copyright © Fire Snippets. All rights reserved.