New API Version with PNG Support #179
Closed
FlorianKoerner
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The DiceBear API is the fastest and most popular way to use DiceBear. Every day the API creates over 7 million avatars for your projects. And our sponsor bunny.net can answer more than 86% of requests directly from the CDN cache - for fast response times around the globe.
Today I'd like to introduce you the new DiceBear API, which is fully compatible with the old API and includes many new features.
PNG Support
Many of you have asked for PNG support because not all platforms support the SVG format. I am happy to announce that the API now officially supports the PNG format up to a size of 248x248px. Just replace the "svg" in the URL with "png".
Example SVG avatar:
https://avatars.dicebear.com/api/adventurer/john.svg
Example PNG avatar:
https://avatars.dicebear.com/api/adventurer/john.png
Simplified passing of options
If many options are set, the URL can quickly become very long and unreadable. From now on you can omit the square brackets for arrays and connect options with a comma. I hope this change makes the API a bit more accessible for everyone.
Here is an example of how the URL might have looked before:
https://avatars.dicebear.com/api/avataaars/john.svg?top[]=shortHair&top[]=eyepatch&top[]=hat&hatColor[]=heather&hatColor[]=gray02&hatColor[]=gray01&hatColor[]=gray&hatColor[]=blue03&accessories[]=kurt
And this is how it can look like now:
https://avatars.dicebear.com/api/avataaars/john.svg?top=shortHair,eyepatch,hat&hatColor=heather,gray02,gray01&hatColor=gray,blue03&accessories=kurt
Changed routes
The old API routes have several problems: Versioning is optional, routes are not under a separate domain, and routing is inefficient. All these problems are solved with the new API endpoint "api.dicebear.com". The new routing looks like this:
For a fixed minor version:
With the last minor version under a major version:
The other placeholders can be replaced with the desired avatar style and format (svg or png) as usual.
The API currently supports versions
4.4
,4.5
,4.6
,4.7
,4.8
,4.9
,4.10
,4.x
,5.0
and5.x
. As mentioned above, the API remains completely compatible with the old one. So you don't have to rewrite your code right now.The new routes and features of the new API will be described in more detail in the upcoming documentation for version 5.0.
Beta Was this translation helpful? Give feedback.
All reactions