This simple example shows how you can use Unkey API key authentication with a Go stdlib middleware.
Clone the example and build
1git clone https://github.com/diwasrimal/unkey-go-stdlib-auth2cd unkey-go-stdlib-auth3go build -o server .
Get your unkey root key from https://app.unkey.com/settings/root-keys. Create a new api from https://app.unkey.com/apis
and also get its api id. Then create a .env
file in the root directory with these variables.
1UNKEY_API_ID=your_api_id2UNKEY_ROOT_KEY=your_root_key
Run the server
1./server
Create a new key for your api. Make a request to server including your api key in the Authorization header.
1curl -X GET localhost:3030 -H 'Authorization: your_api_key'
2500 verifications and 100K successful rate‑limited requests per month. No CC required.