Fetch avatars for your next service in a single API call.
Development has moved to the DevClad Mono[turbo]repo
- 🚀 Generate avatars on the fly
- 🎨 100 avatars included from Craftwork.design (I'm not affiliated with them, just a fan)
- 🎨 Abstraction over Boring Avatars included as well.
- ✨ Tiny as fuck.
- ✨ Serverless. Configurable. Easily deployable.
api/getpic/
api/avatar/
-?stream=True
query outputs an SVG for you.
?name=string
- Your username. Defaults toCactus Jack
.?size=int
- Size of the avatar. Default is 128.?variant=string
- Variant of the avatar. Default isbeam
.?stream=bool
- Stream the SVG instead of returning a URL. Default is False.
marble
pixel
beam
sunset
ring
bauhaus
All these variants and avatars (under api/avatar/
route) are from Boring Avatars.
- Head over to userpics.devclad.com and "Get a random user pic".
- Use the URL in your app.
/api/getpic/
is the endpoint to get a random avatar.
def random_avatar():
name = str(uuid.uuid4())[:8]
with open(f"media/avatars/{name}.png", "wb+") as f:
url = requests.get("https://userpics.devclad.com/api/getpic")
response = requests.get(url.text, stream=True)
if not response.ok:
raise Exception("Could not get avatar")
for block in response.iter_content(1024):
if not block:
break
f.write(block)
return f"avatars/{name}.png"
You can try svg too btw, haven't tested it but it should work.
accountId := os.Getenv("ACCOUNT_ID")
bucketName := os.Getenv("BUCKET_NAME")
accessKeyId := os.Getenv("API_ACCESS_KEY")
accessKeySecret := os.Getenv("API_SECRET_KEY")
- Create an R2 bucket on Cloudflare.
- Generate S3 Token via
Manage R2 API Tokens
in R2 Dashboard. - Set your environment variables.
- Deploy ⚡
do the usual. install dependencies via yarn
and run yarn run start
/yarn run dev
.
Make sure to setup environment variables in your Vercel dashboard. Also make sure to have S3 API access and secret on the recieving end if your bucket is private like mine.
Resource | Service |
---|---|
Storage | Cloudflare R2 (S3 compatible) |
Serverless Hosting | Vercel (AWS Lambda) |
Check out the issues for more info.
template-go-vercel was helpful while deploying.