GoogleAPI Library
This project provides a simple interface for interacting with Google Drive and Firebase Realtime Database using only fetch
requests, without setting up an HTTP server.
Engines
Installation
npm install googleapi-library
Usage
Authentication
To use this library, you need to provide Google service account credentials.
import { GoogleAuth } from "googleapi-library";
const credentials = {
client_email: "your-service-account@your-project.iam.gserviceaccount.com",
private_key: "your-private-key"
};
const googleAuth = new GoogleAuth(credentials);
Google Drive
Initialize Google Drive
const drive = googleAuth.drive("your-folder-id");
Upload a File
const fileId = await drive.create(myFile);
console.log("Uploaded file ID:", fileId);
Delete a File
const success = await drive.remove("file-id");
console.log("File deleted:", success);
List Files
const files = await drive.filter();
console.log("Files:", files);
Firebase Realtime Database
Initialize Database
const database = googleAuth.database("https://your-database.firebaseio.com");
Retrieve Data
const data = await database.findAll("/path");
console.log("Data:", data);
Insert or Update Data
await database.create("/path", { key: "value" });
Delete Data
await database.remove("/path");
Query Data
const result = await database.query("/users", { orderBy: "name", equalTo: "John" });
console.log("Query Result:", result);
License
This project is licensed under the MIT License.