Skip to main content
Follow these best practices to ensure reliable, efficient, and secure integration with the Proofly SDK.

Authentication & Security

Never commit API keys to version control. Use environment variables:
const apiKey = process.env.PROOFLY_API_KEY;
if (!apiKey) {
  throw new Error('PROOFLY_API_KEY is required');
}
const client = new PlankProofly({ apiKey });
Use separate API keys for development, staging, and production to track usage and isolate environments.

Performance Optimization

Provide as much information as possible (photo, birth year, location) to improve match accuracy and reduce the need for follow-up searches.
If you need to perform multiple independent searches, run them in parallel:
const [result1, result2] = await Promise.all([
  client.profiles.search({ name: 'User 1' }),
  client.profiles.search({ name: 'User 2' })
]);

Error Handling

Catch errors and handle specific status codes (e.g., 429 for rate limits).
try {
  await client.profiles.search({...});
} catch (err) {
  if (err.status === 429) {
    // Handle rate limit
  }
}
Log the error message and status code for debugging.

Testing

In your unit tests, mock the SDK client to avoid making real API calls.
jest.mock('@plank-proofly/api', () => ({
  PlankProofly: jest.fn().mockImplementation(() => ({
    profiles: {
      search: jest.fn().mockResolvedValue({
        primaryMatch: { facebookId: '123', confidence: 0.95 }
      })
    }
  }))
}));