Skip to content

berrysauce/altar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Altar icon

Altar

Altar is a tiny API for the generation of identicons (Wikipedia). Altar always generates the same image from the same input through hashing and simple calculations.

This means that you can use Altar to generate profile pictures for users based on their username, or any other unique identifier.

Altar was built from the ground up with few dependencies, but is inspired from GitHub's Identicons and minidenticons.

Due to its small size, Altar is very fast. Local Waiting / Local Time To First Byte times are usually between 3-4 ms.

Installation

  • Locally – install Altar wherever Python is supported by cloning the repository, installing all dependencies with pip install -r requirements.txt and running main.py
  • Cloud – run your own instance of Altar on Railway. Just click the button below and you'll be guided through the setup.

Deploy on Railway

🔐 Restrict Access

It is possible to restrict the access to your Altar instance. To do that, simply create a .env file in the directory where Altar is and add API_KEY as a variable.

If you're hosting Altar on Vercel, go to Settings → Environment Variables and add API_KEY there. Choose a key for your Altar instance and set it as the value of the environment variable.

To make authenticated requests to Altar, use the x-api-key HTTP header with the API_KEY as the value.

How to use

An API request to Altar only requires the data you want to use to generate the identicon. There are overrides (e.g. for the file size and color) which can be found in the documentation.

GET  https://altar.berrysauce.dev/generate?data=example

Uptime

Altar currently has two public endpoints:

Note

As Altar always generates the same image based on your input, it's recommendet to use the CDN endpoint for better performance.

Warning

Altar is just a small project, therefore security cannot always be guaranteed. It's only recommended to pass on usernames or unique identifiers to Altar, which do not include or grant access to personal information.

Headers

Header Type Description Required
x-api-key String API Key for authentication, if it was set as an environment variable. no (if set, yes ⚠️)

Query Parameters

Query Type Description Required
data String Data to be used for identicon generation yes ⚠️
color String HEX Color to be used for the identicon foreground without '#' (default: generated based on input) no
background String HEX Color to be used for the identicon background without '#' prefix (default: none/transparent) no
size Integer Width & Height of the scaled SVG (default: 250) no
padding Integer Padding for the identicon (default: 0) no

Development

  1. Install Altar wherever Python is supported by cloning the repository
  2. Install all dependencies with pip install -r requirements.txt
  3. Run main.py with python main.py

Note

Altar is built with Python 3.9.x, but should work with any Python version above 3.6

License

Altar is licensed under the MIT license.

Copyright (c) 2023 Paul Haedrich

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: