Pictogrammers / pictogrammers.com

Code for Pictogrammers.com
https://pictogrammers.com
80 stars 18 forks source link

Where is the API now? #32

Closed penn5 closed 1 year ago

penn5 commented 1 year ago

https://github.com/Pictogrammers/pictogrammers.com/blob/39490f3c44e614888dab9b881549c42e4d5d740f/docs/contribute/api.mdx#base-url mentions that the API may move as the base URL transitions. Currently, the API redirects to pictogrammers.com which returns 404.

Templarian commented 1 year ago

@penn5 Just to preface the API is only for contributors building or extending the website. All of the data is provided in the meta.json (the public website uses that data and not the API).

With that said if you're building features for the site the API is at https://dev.materialdesignicons.com/api/ You probably forgot the subfolder (this is moving to https://api.pictogrammers.com/*, but we're still working on that after a few more site features go out.

mririgoyen commented 1 year ago

Yep, what @Templarian said. 😄 We would be really interesting in what you're currently using the API for. If you're using it for something not related to the site and need help transitioning to using the meta.json files, please let us know.

penn5 commented 1 year ago

I'm using the API to automatically check for updates to icons in my android app. I grab all the metadata from meta.json and just use the API for exports.

penn5 commented 1 year ago

https://dev.materialdesignicons.com/api/packages returns 404... The same error for https://dev.materialdesignicons.com/api/download/icon/vectordrawable/93D7B6DC-17D2-4A2B-B787-79E2E8BEF304.

I got the earlier error not because I missed out the /api but because I wasn't using the dev. prefix (this used to work).

mririgoyen commented 1 year ago

This doesn't sound like an appropriate use case for the API. When we release new versions of the package, simply update and the meta.json will have the latest changes. Additionally, you can easily generate a Vector Drawable using the path data.

penn5 commented 1 year ago

I don't see the problem with using the API for this - it only takes place at build time just before a release and I make about 10-20 requests. That probably averages at one request per day, maximum. I know I can generate the drawable from a path, but where should I get this path data? Either by parsing the SVGs in https://github.com/Templarian/MaterialDesign (very ugly) or from the API (broken).

Whatever the problems with my use case, the issue still exists.

Templarian commented 1 year ago

@penn5 The JSDelivr CDN is exactly what you would need. Our third party guide describes best practices for obtaining this data. These releases are always stable and up to date with latest.

We'll be implementing API keys eventually, so relying on the private site API will eventually break.

mririgoyen commented 1 year ago

I don't see the problem with using the API for this.

The problem is that it goes against our wishes. The documentation link you shared in the very first post 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.

Unfortunately, that means we aren't going to provide assistance to you in figuring out how to consume it. As Templarian stated, we're in planning stages to implement API keys to prevent just this type of behavior, which means even if you figure it out, it will permanently break for you soonish. It's really in your best interest to utilize the static assets (e.g. meta.json) or the CDN.

penn5 commented 1 year ago

I did switch to the CDN. I think you should a) make more clear on the documentation how this is used, for people who aren't familiar with Javascript packages, and b) fix your API for anyone who is a valid user (since it doesn't seem to work).

It would also be nice to be able to fetch the raw path data, rather than having to parse the SVG files.

mririgoyen commented 1 year ago

It would also be nice to be able to fetch the raw path data, rather than having to parse the SVG files.

Raw path data is available via @mdi/js if you're using JavaScript to do your scripting.

penn5 commented 1 year ago

Raw path data is available via @mdi/js if you're using JavaScript to do your scripting.

I'm not.