Over the last few months I was working on a project that manages hundreds of Google Business Profile locations.
I expected the integration to be straightforward, but the API turned out to be much harder than I anticipated.
The biggest pain points were:
• OAuth access tokens expiring every hour
• Refresh token race conditions
• Manual pagination using nextPageToken
• Handling 429 rate limits and random 503 responses
• Writing the same boilerplate for every project
After solving these problems multiple times, I decided to extract everything into an open-source SDK.
Some features:
✅ Automatic OAuth token refresh
✅ Thread-safe token management
✅ Auto-pagination (fetch all pages automatically)
✅ Built-in retry with exponential backoff
✅ Fully typed TypeScript API
✅ Zero runtime dependencies
Example:
import { GBPClient, ConsoleLogger } from '@vitabletech/gbp-sdk';
const client = new GBPClient({
clientId: 'YOUR_GOOGLE_CLIENT_ID',
clientSecret: 'YOUR_GOOGLE_CLIENT_SECRET',
refreshToken: 'YOUR_REFRESH_TOKEN',
tokenStorage: 'file',
// stores tokens in gbp-tokens.json
logger: new ConsoleLogger(),
// optional pluggable logger
});
async function main() {
// Automatically handles token generation and pagination!
const accounts = await client.accounts.listAll();
if (accounts.length > 0) {
const accountName = accounts[0].name;
const locations = await client.locations.listAll(accountName);
console.log(`Found ${locations.length} locations for ${accountName}`);
}
}
main();
Enter fullscreen mode Exit fullscreen mode
The project is completely open source.
I’d really appreciate feedback from anyone who has worked with the Google Business Profile API.
What features would you want to see next?
GitHub: https://github.com/vitabletech/gbp-sdk
npm: https://www.npmjs.com/package/@vitabletech/gbp-sdk
답글 남기기