How-to
Use your API key
Use the API key that I Need A Database provisions when you create a project.
Get the key
- Sign up and create your first project.
- Copy the API key from the project-created screen.
- Regenerate it from the project dashboard if you need a new secret.
- Store it as a server-side secret.
Use the key
Send the key in an Authorization header with each project API request.
curl https://ineedadatabase.com/api/v1/projects/proj_123/collections \
-H "Authorization: Bearer inadb_..."How authentication works
I Need A Database currently uses one full-access bearer API key per project. The full key is returned once when the project is created or regenerated.
Authorization: Bearer inadb_...Regenerating a key immediately revokes the previous one, so update your deployments before removing the old secret from your systems.
Keep it secret, keep it safe
Remember that this key has full access to everything in the project, including deleting data. Use it from your server, worker, or automation job rather than exposing it in browser-side code.
Use a server proxy
For frontend apps, call your own server route or serverless function from the browser. That route should read the API key from environment variables and call I Need A Database server-side.
export async function GET() {
const response = await fetch(
`https://ineedadatabase.com/api/v1/projects/${process.env.INEEDADATABASE_PROJECT_ID}/collections/recipes/documents`,
{
headers: {
Authorization: `Bearer ${process.env.INEEDADATABASE_API_KEY}`
}
}
);
return Response.json(await response.json(), { status: response.status });
}