For the complete documentation index, see llms.txt. This page is also available as Markdown.

API Integration Guide

This guide covers integrating Pullbay's data APIs into backend applications and services. Learn authentication, error handling, rate limiting, and how to build robust integrations across Python, Node.js, PHP, and Ruby.


Architecture: Server-Side Integration Only

Why Server-Side Only?

API keys are secrets. Exposing them in client-side JavaScript, mobile apps, or public repositories allows attackers to:

  • Consume your API quota and credits

  • Impersonate your application

  • Access your data

  • Cause financial damage through runaway API usage

Where to Store Your API Key

Do:

  • Environment variables in your backend application

  • Secrets manager (AWS Secrets Manager, HashiCorp Vault, Google Secret Manager)

  • Encrypted configuration files (accessed only by your backend)

  • Secure CI/CD pipeline secrets

Don't:

  • Hardcoded in source files

  • Client-side JavaScript

  • Mobile app code

  • Public repositories (GitHub, GitLab, etc.)

  • Unencrypted configuration files


Client-Side Access: Build a Backend Proxy

If your frontend needs to fetch Pullbay data, never call Pullbay directly from the browser. Instead, build a backend API endpoint that acts as a proxy:

Proxy Pattern

Benefits:

  • API key never leaves your backend

  • Control who can access review data

  • Add authentication/authorization

  • Rate limit per user

  • Cache responses to reduce credits

Example Backend Proxy (Node.js):


Response Envelope

All Pullbay responses follow the same envelope. Understanding this structure is essential before implementing any client:

Field
Description

requestId

Unique request identifier — log this for every call. Also returned as the X-Request-Id header.

status

HTTP status code mirrored in the body

success

true on success, false on error

data

Array of result objects

pagination

Present on paginated endpoints; fields are null when not applicable

pricing.creditsCharged

Credits consumed by this request

Error responses:


Centralized PullbayClient Class

Create a centralized client class for all Pullbay API calls. This ensures consistent authentication, error handling, and credit tracking across your application.

Python Example


Implementation Checklist

Before deploying your integration, ensure you've implemented:


Language-Specific Examples

Python (with Requests and Retries)

Complete production-ready Python integration:

Node.js (with Axios)

PHP (with Guzzle)

Ruby (with Net::HTTP)


Testing and Mocking

Mocking Responses in Unit Tests

Never make real API calls in unit tests. Mock the Pullbay response envelope instead.

Python mock example:


Security Considerations

Environment Variables vs Secrets Manager

For development — use .env files:

For production — use a secrets manager:

API Key Rotation

  1. Generate a new API key in the Pullbay dashboard

  2. Update your secrets manager with the new key

  3. Redeploy or reload configuration

  4. Verify the new key works

  5. Deactivate the old key


Frequently Asked Questions

Should I cache Pullbay responses?

Yes. Caching reduces credits and improves latency. Cache the full response body keyed by endpoint + parameters. Use a TTL appropriate for data freshness (e.g. 1 hour for reviews, 24 hours for static app metadata).

How do I handle API key rotation without downtime?

Store the key in a secrets manager rather than in code. When you rotate:

  1. Update the secret in the secrets manager

  2. The application reads the new key on the next request (or on restart, depending on your setup)

  3. No code changes or redeployment needed

Can I call Pullbay from a browser?

No. Never expose your API key in client-side code. Build a backend proxy endpoint that adds the key server-side (see the Proxy Pattern section above).

What is the difference between maxItems and using cursor?
  • maxItems — Pullbay paginates internally and returns all items in a single response (up to the endpoint maximum). Simpler but takes longer for large datasets.

  • cursor — You paginate one page at a time, processing results incrementally. More control; you can stop early to save credits.

They are mutually exclusive — you cannot use both on the same request.

How do I monitor credit usage?

Log pricing.creditsCharged from every response. Accumulate totals in your application and set up alerts when burn rate exceeds a threshold. The Pullbay dashboard also shows usage analytics.

What's the best way to handle rate limiting?

Respond to 429 responses by reading the X-RateLimit-Reset header and waiting until that timestamp before retrying. The Python, Node.js, PHP, and Ruby examples above all implement exponential backoff as a fallback.

Last updated