Closed SmileyJoe closed 1 year ago
Closing as I found the documentation under contributing:
You shouldn't be using the API for this use case.
There are two ways you could do this:
@mdi/svg
and reference the meta.json
file for each icon's metadata. Read the svg/{ICON_NAME}.svg
to get the SVG and extract the d
attribute from the path
.Install @mdi/js
. You can directly get the path data this way.
import { mdiAccount } from '@mdi/js';
console.log(mdiAccount); // M12,...14Z
Thanks for the reply @mririgoyen , I'm not sure if I'm missing something but I don't see how that fits into a java based library for android?
The idea of the lib is to load icons as needed based on the name of the icon, this can come from an api or be set in code, and then store the icon locally, is that the same thing you had in mind?
Yes, that would be ideal for a number of reasons. You would bring all assets down locally, avoiding network requests. This will be much quicker for your users and prevent unneeded network traffic to the site. You also avoid things breaking if the site goes down for some reason.
Please note that the article you found on our API documentation explicitly states:
Please do not use these endpoints to scrape the site or to build third party applications. All data is provided in the meta.json on the CDN or in the GitHub repo after every release.
So, in your case, the two options available to you would be:
Use @mdi/svg
, either from NPM or from cloning the GitHub repo. Read the meta.json
file and then the svg/{ICON_NAME.svg}
files to get the information you need.
Continue using the CDN to get the meta.json
file, but instead of using the API to get the icon, just use the CDN again.
https://cdn.jsdelivr.net/npm/@mdi/svg@7.1.96/svg/account.svg
The first option bring all icons local and removes the need for network requests, which would be the ideal path IMO. The second option slightly alters what you are currently doing to avoid using the API.
Ah, I see, ok cool, I must have missed that api note on the old documentation. Thanks, let me make some updates.
Sure thing! Let us know if you have any other questions. Limiting the use of the API is not only a benefit for you and your users, but for us as well. Running servers on ad-only income is a tough balancing act. 😄
Hi,
I hope this is the correct repo to put this under,
I wrote and maintain a little library (https://github.com/SmileyJoe/lib_android_icons) to help with loading icons in Android. It gets a list of all icons from
https://cdn.jsdelivr.net/npm/@mdi/svg@{version}/meta.json
and then uses thematerialdesignicons.com/api/icon/{id}
endpoint to load the svg data.The cdn url is still returning the list of icons, however, the
api/icon/{id}
endpoint is returning a302
with a redirect topictogrammers.com/library/mdi/?welcome
With the move to pictogrammers is there an updated url to retrieve the icon data?
Thanks