Get in touch!
The User Avatar API, like all of Abstract's APIs, is organized around REST. It is designed to use predictable, resource-oriented URL's and to use HTTP status codes to indicate errors.
All communications with the User Avatar API must be secured TLS 1.2 or greater.
All of Abstract's API are versioned. The User Avatar API is currently on Version 1.
Your API key is your unique authentication key to be used to access Abstract's User Avatar API. Note that each of Abstract's API has a unique API key, so you will need different keys to access the User Avatar and IP Geolocation APIs, for example. To authenticate your requests, you will need to append your API key to the base URL.
The name you want to create an avatar for. You can submit multiple names (such as first, middle, and last), and the API will default to displaying two letters in the avatar. You can change the number of letters displayed with the char_limit parameter below.
Your unique API key. Note that each user has unique API keys for each of Abstract's APIs, so your IP Geolocation API key will not work for as your User Avatar key, for example.
The size of the square avatar image in pixels. It defaults to 32 pixels, and is available in sizes from 6 to 512 pixels.
The desired format of the returned image. It defaults to "svg", but can also be specified as "png".
The size of the font as a percent of the image_size. It defaults to 0.5, but it can be set between 0.1 and 1.0.
The maximum number of characters displayed in the avatar. It defaults to 2. The actual number of characters displayed can be less than this number, but it cannot be more. The characters will first be chosen from distinct words, then from the second letter of distinct words. For example, with a char_limit of 2, the string "John" will return "JO", "John Smith" will return "JS", and "John Patrick Smith" will return "JS".
The hex color for the background. It defaults to 335eea. When including a hex color, you do not need to include the "#". So &background_color=e4704a would be valid and &background_color=#e4704a would be invalid.
The hex color for the font. It defaults to white, i.e.,ffffff. When including a hex color, you do not need to include the "#". So &font_color=e4704a would be valid and &font_color=#e4704a would be invalid.
Sets the initials in the avatar to all capitals. It defaults to true.
Sets the initials in the avatar to all italics. It defaults to false.
Sets the initials in the avatar to bold. It defaults to false.
To create a user avatar via the API, the absolute minimum required is your unique API key and at least 1 character in the name.
? apikey = YOUR_UNIQUE_API_KEY
& name = John Smith
This simple request would return the following image:
When users sign up for an app or website, it's common to allow them to upload an image of themselves. However, in many cases users don't do that right away (or ever!), and you and they are stuck with a bunch of bland and empty spaces where an image should be. You can automatically spice up the interface by adding a custom avatar for that user that's created from their name or initials.
Gravtar describes their service as providing "an image that follows you from site to site appearing beside your name when you do things like comment or post on a blog. Avatars help identify your posts on blogs and web forums, so why not on any site?". This is a very popular option for getting a user's image, but it's not always available. Users of Abstract's User Avatar API will often use our service as a fall back when a gravtar cannot be found.
We support most characters (including emoji!). We're also rolling out support for additional languages and characters like Arabic, Bengali, Hebrew, Chinese, Japanese, and Thai.
November 19, 2020
Added new text formatting and color options
July 1, 2020
Improved support for Hebrew, Arabic, and other right-to-left scripts
July 6, 2020
Added additional avatar color options