mludowise / Sketch-Plugin-Manager

Keeping your Sketch plugins up to date.
https://mludowise.github.io/Sketch-Plugin-Manager/
Apache License 2.0
333 stars 14 forks source link

[Enhancement Request] - Use Sketchpacks API #24

Open willdavis opened 7 years ago

willdavis commented 7 years ago

Hi, I wanted to reach out and see if you would be interested in using the Sketchpacks API to help with searching and managing plugins?

The API keeps a unique index of all plugin identifiers. So when you parse a manifest locally, you can use the identifier to fetch additional information about the plugin from the API.

If you'd like to check out the API, you can try it here: http://docs.sketchpacks.apiary.io

Some use cases

Weighted Full-Text Search

search across plugins manifest.name, manifest.title, manifest.description, and README.md.

https://api.sketchpacks.com/v1/plugins?text=plugin manager

GET Batches of Plugins

fetch groups of plugins to minimize API requests and improve performance.

https://api.sketchpacks.com/v1/plugins?in=plugin.identifier1,plugin.identifier2,...,plugin.identifierN

Download Version or SHA

You can download a plugin's latest version, or provide a semantic version or SHA to download.

https://api.sketchpacks.com/v1/plugins/{identifier}/download
https://api.sketchpacks.com/v1/plugins/{identifier}/download?version=1.2.3
https://api.sketchpacks.com/v1/plugins/{identifier}/download?version={full_commit_sha}

Update Checks using Semantic Version Ranges

allows you to check for plugin updates with semantic version ranges. you can also leave out the range to get the latest version that is greater than the given version. (checks Github releases as well as manifest.version)

https://api.sketchpacks.com/v1/plugins/{identifier}/download/update/1.2.3
https://api.sketchpacks.com/v1/plugins/{identifier}/download/update/1.2.3?range=<2.0.0

Plugin Analytics

allows you to get download metrics for a plugin. It includes an all_time, weekly, and monthly count for each plugin. High level metrics are also included when you search for plugins.

https://api.sketchpacks.com/v1/plugins/{identifier}/rollup

Live Updates to the Registry

powered by Sketchpacks Relay which allows Sketch Developers to publish plugins quickly and deliver updates in near real-time.

mludowise commented 7 years ago

Thank you for pointing me to the API. It would be nice to use the same API so we can both leverage the same download count, but I don't think I can currently use this for the following reasons.

  1. I don't have paging implemented and it would actually take quite a bit of work to do this. I currently download the entire catalog and use Apple's Core Data library to perform search and sort. I tried to see if I could use the API with a really big page size, but it looks like the per_page parameter doesn't do anything (the highest I can get it to go is 25 items).
  2. It looks like the API doesn't do partial text search (e.g. searching for "pl" and getting "Sketch Plugin Manager" to display as a result. I currently load my results as the user types and according to my analytics tracking, the majority of my users only do partial searches to get their results. Note, that I could bypass this and use Core Data to search across the results locally if I could load all the results in one request.
  3. The way I do updates and downloads is through Git, so even if I used this API, it wouldn't increment the download counter. It's quite possible I may change this behavior given Sketch's new plugin update system, in which case your API could potentially make this easier on me.

I need to look into Sketch's new update system to evaluate if it's worth continuing to manage updates via Git. If it's not, then the Sketchpacks API makes a lot of sense to use but I would prefer a way to get the entire catalog in one HTTPS request.

mludowise commented 7 years ago

@willdavis I'd like to file bugs & enhancement requests on the Sketchpacks API. Is this the best place to do it?

willdavis commented 7 years ago

You can use bug-reports for issues and feedback for enhancements. I think we may combine these in the future to make it more clear. But for now either is fine.

I would prefer a way to get the entire catalog in one HTTPS request

I can definitely add this in for you. I'll only be able to update it once a day though, but it should give you something to search & sort against. Hopefully this can help you with points 1 and 2.

It looks like the API doesn't do partial text search

I would like to add this feature in the near future. We've had requests for it on Sketchpacks also. I definitely prefer the type-ahead experience for searching 👍

Would a left anchored LIKE query work for you? This would be an easy way to do indexed searches for partial words, but would not work for partials in the middle of a string.

WHERE name LIKE '%value'

Thanks for the feedback!

mludowise commented 7 years ago

Yes, a LIKE should do the job. Note that getting the results in one request is a higher priority request because I can continue loading the data into Core Data and performing the search locally.

I moved these items into their own enhancement requests linked above.

mludowise commented 7 years ago

I found a few bugs in the API which I filed and also made a few enhancement requests.

These are the specific items that are blocking me from being able to use the Sketchpacks API because they are capabilities that my API has which Sketchpacks does not (listed in priority order):

  1. [API] Ability to download entire plugin list in one request
  2. [API] Description is missing for some plugins
  3. [API] thumbnail_url is always empty
  4. Include plugins not hosted on GitHub
  5. [API] Add plugin homepage field

The "API" that I'm currently using is just an hourly crawl of the official Plugin Directory combined with some metadata from the plugin's manifest file and Github project. It would be great if I didn't have to support it anymore, but there are a few fields I'm using that aren't currently in the Sketchpacks API. If you're at all curious about how it's generated, I'm happy to add you to separate GitHub project that generates it (currently private).