Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] Ability to download entire plugin list in one request #32

Open
mludowise opened this issue Jun 13, 2017 · 3 comments
Open

[API] Ability to download entire plugin list in one request #32

mludowise opened this issue Jun 13, 2017 · 3 comments

Comments

@mludowise
Copy link

Copying over from this thread.

I'd like the ability to get the entire list of plugins in one HTTPS request for Sketch Plugin Manager since it would be a significant amount of work to incorporate paging. It's okay if the request takes a little longer to load or if it's cached and potentially a little out of date (no more than a day).

@mludowise
Copy link
Author

Actually, an alternative that I just thought of. If the API can return the number of total results in the JSON, that might enable me to use paging. GitHub does something like this in their Search API where they return the total_count of results and then a list of the actual items.

Essentially, I'm using Apple's NSTableView which needs to know how many rows the table has in order to make scrolling work reasonably well. This solution would still take some refactoring and I would need to evaluate how the user experience will respond to incrementally loading pages as the user scrolls, but if it's significantly easier to implement than I can look into it.

@willdavis
Copy link

We actually have header based pagination in the API already 😄
I'll make sure to go through the API docs and make sure this is better documented.

check out:

curl -is https://api.sketchpacks.com/v1/plugins?page=2

The response will have these headers:

Link: <https://api.sketchpacks.com/v1/plugins?page=1>; rel="first", <https://api.sketchpacks.com/v1/plugins?page=1>; rel="prev", <https://api.sketchpacks.com/v1/plugins?page=36>; rel="last", <https://api.sketchpacks.com/v1/plugins?page=3>; rel="next"
Per-Page: 10
Total: 360

You can use the Link header to navigate between pages. The max Per-Page is currently 25

I also plan to make better use of the Etag and If-Modified-Since headers in the future. This will allow for better client side caching and allow you to check for cache changes using request headers. If there are no changes, the API would return 304 (not modified).

@mludowise
Copy link
Author

@willdavis ahah! I didn't think to look in the header 😌

I can potentially start playing with this over the next couple days. It would still be significantly easier on my end to get all the results in one request though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants