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

Error 451 with https://ghapi.huchen.dev/ #130

Open
hedyhli opened this issue Oct 4, 2020 · 43 comments
Open

Error 451 with https://ghapi.huchen.dev/ #130

hedyhli opened this issue Oct 4, 2020 · 43 comments

Comments

@hedyhli
Copy link

hedyhli commented Oct 4, 2020

image

@nahtnam
Copy link

nahtnam commented Oct 4, 2020

Same here

I believe Vercel provides free hosting for open source projects, have you applied to that?

@huchenme
Copy link
Owner

huchenme commented Oct 4, 2020

Unfortunately Vercel did not want to sponsor this project as it is API only. I could no longer find a good free host for the project. I suggest you clone the repo and deploy the code somewhere 😞

@omarryhan
Copy link
Contributor

That's sad news :/

@github should definitely be sponsoring this or atleast provide an API of their own.

@omarryhan
Copy link
Contributor

@huchenme How about we add a simple frontend that makes use of the API, that wouldn't be breaching Vercel's TOS, right?

@huchenme
Copy link
Owner

huchenme commented Oct 4, 2020

I can try add frontend for this actually

edwardpayton added a commit to edwardpayton/github95 that referenced this issue Oct 4, 2020
(unofficial) trending api is offline
as per huchenme/github-trending-api#130
will deploy my own instance of the trending api
@sandoche
Copy link
Contributor

sandoche commented Oct 4, 2020

@huchenme I can give you the code of GitNews https://git.news if you wish.
Let me know!

@huchenme
Copy link
Owner

huchenme commented Oct 5, 2020

@sandoche I do have some code, let me add to the repo during nights and apply Vercel's sponsor again, if everything goes smooth it should be back in a week 🤞
Meanwhile, if you need the API now, I suggest you clone the code and deploy to somewhere like Vercel

@akane10
Copy link

akane10 commented Oct 5, 2020

I use this api for my personal website. Since it's having an issue, I cloned and hosted it.
So in the meantime, feel free to use it, gtrend.yapie.me

@huchenme
Copy link
Owner

huchenme commented Oct 5, 2020

@akane10 that is great, may I know where did you host it?

@akane10
Copy link

akane10 commented Oct 5, 2020

@huchenme yeah sure, it's on digitalocean.
But anyway, isn't there netlify function and it is free?

@huchenme
Copy link
Owner

huchenme commented Oct 5, 2020

@akane10 I tried Netlify function and could not recall what did not work as expected. if you plan to keep your server, do you mind if I point ghapi.huchen.dev to your server temporarily?

@akane10
Copy link

akane10 commented Oct 5, 2020

@huchenme Yes, sure. I don't mind

@huchenme
Copy link
Owner

huchenme commented Oct 6, 2020

The issue I was facing for Netlify is the caching: s-maxage does not actually work: if I hit https://ghapi.huchen.dev/repositories?language=javascript, all the subsequent requests with different parameters (e.g. https://ghapi.huchen.dev/repositories?language=java) will return the same results (javascript)

If anyone has any luck with Netlify please let me know

@huchenme
Copy link
Owner

huchenme commented Oct 6, 2020

This is a miracle. They just blocked me
image

I am thinking to deploy to Netlify without caching. It might be slower, and it might hit the limit soon as well 🤞

@huchenme
Copy link
Owner

huchenme commented Oct 6, 2020

It is back now! the only downside is that it does not have browser cache now

@huchenme huchenme closed this as completed Oct 6, 2020
@huchenme huchenme reopened this Oct 8, 2020
@huchenme
Copy link
Owner

huchenme commented Oct 8, 2020

It quickly finished the free quota in Netlify, have to stop the project.

@nahtnam
Copy link

nahtnam commented Oct 9, 2020

Hmm, have you considered instead making a library that we can import and await and it will make the request and parse the request for us? That way you don't have to worry about hosting it, and we are able to use the code you wrote

@akane10
Copy link

akane10 commented Oct 9, 2020

@nahtnam he already did it actually https://github.com/huchenme/github-trending-api#install.
And yeah I agree, that's totally fine if there is no API, only library.
We appreciate your work @huchenme.

@pupubird
Copy link

Hey hey for anyone that's reading on this, I had been using this library for quite a long time, definitely appreciate your work! @huchenme !

I had also created a self-hosted version of the scraper server ( with AWS lambda function compatible ), https://github.com/pupubird/get-github-trending

And the demo site here https://hackertab.pupubird.com/repositories

All credits go to @huchenme

@pupubird
Copy link

pupubird commented Oct 11, 2020

Also, by utilizing AWS CloudFront, I am able to cache the response with TTL to hourly, will write up a tutorial about it too!

@waningflow
Copy link

Feel free to use.
https://github-trending-api.waningflow.com/languages
https://github-trending-api.waningflow.com/repositories?language=typescript&since=daily

@Smeet97Kathiria
Copy link

Smeet97Kathiria commented Oct 15, 2020

@waningflow will this ever go down? is there a limit ?

@waningflow
Copy link

@Smeet97Kathiria Deployed on Function Compute of Aliyun. About first 500k requests per month are free.

@Smeet97Kathiria
Copy link

@waningflow what happens after it hit the limits?

@waningflow
Copy link

waningflow commented Oct 16, 2020

@Smeet97Kathiria I suppose it's not likely to reach the limit for normal usage. If it does, I may restrict the apis temporarily. It's also recommended to deploy the service youself. Here is what I use in Function Compute of Aliyun, github-trending-api-node. Just yarn to install dependencies and upload the whole git to the platform.

@hedyhli
Copy link
Author

hedyhli commented Oct 16, 2020

hey @akane10 I tried out your url, and it seems https://gtrend.yapie.me/spoken_languages doesn't work?

@akane10
Copy link

akane10 commented Oct 16, 2020

@hedythedev yeah, route languages and spoken_languages was I disabled for a reason.
But it is now working.
In case anyone uses my endpoints, it won't run out of request, as long as I can affort my VM.

@andraz-at
Copy link

andraz-at commented Oct 16, 2020

Your problem is caused by re-computing the same exact data thousands of times for no good reason. In the cloud CPU is expensive, disk is practically free. Use functions to write static data in files, then route users to static files like it's 1995.

Can you workaround this issue by creating an AWS hosted endpoint (trivially built with AWS Amplify -> Hosting)?

Then you just need to add a Lambda function which calculates all required responses and stores the responses into static files to an S3 bucket. From this bucket you can serve static files as a web page by simply enabling public access to this static hosting (amplify hosting does that in the background for you).

tl;dr: Create a trivial "web site" to set up free web hosting + create a Lambda function to update this same "web site's" files in the S3 bucket (fetch, parse, write json...).

@omarryhan
Copy link
Contributor

@andraz-at Instead of making the function store the response on S3, wouldn't it be simpler to cache all the function responses on a CDN e.g. AWS Cloudfront or Cloudflare? Serving from a CDN cache is even cheaper than serving directly from S3.

Since these responses will only change once a day, you can set the TTL to be 86400 seconds (1 day). That way, it's very unlikely you run out of free function calls on most FAAS providers.

If my memory serves me correctly, @huchenme was actually caching the responses when this project was being hosted on Vercel, it's a bummer that they suspended this project and his account as well :/

@cm3z4
Copy link

cm3z4 commented Oct 17, 2020

Hey @akane10, I'm currently routing my site/app GitYeti to your server. Is that okay?

@pupubird
Copy link

Hey hey for anyone that's reading on this, I had been using this library for quite a long time, definitely appreciate your work! @huchenme !

I had also created a self-hosted version of the scraper server ( with AWS lambda function compatible ), https://github.com/pupubird/get-github-trending

And the demo site here https://hackertab.pupubird.com/repositories

All credits go to @huchenme

@andraz-at hey, I had already implemented caching on CloudFront site ( the cdn ), do feel free to directly deploy to your aws account using serverless deploy !

@akane10
Copy link

akane10 commented Oct 17, 2020

Hey @akane10, I'm currently routing my site/app GitYeti to your server. Is that okay?

@cm3z4 yes, sure. Feel free to use it.

@wonderbeyond
Copy link
Contributor

@huchenme
I've tried hard to revert your recent commits which are tightly bound to now.sh and netlify.
I recalled the src/server.js file to make it able to run as a normal web server.
Then I made a deployment to heroku: https://github-trending-api-wonder.herokuapp.com/

My fork: https://github.com/wonderbeyond/github-trending-api/

@andraz-at
Copy link

@andraz-at Instead of making the function store the response on S3, wouldn't it be simpler to cache all the function responses on a CDN e.g. AWS Cloudfront or Cloudflare? Serving from a CDN cache is even cheaper than serving directly from S3.

Since these responses will only change once a day, you can set the TTL to be 86400 seconds (1 day). That way, it's very unlikely you run out of free function calls on most FAAS providers.

Yes, there are alternative optimizations available. My point was that we can chain all those optimizations one after another in a way to fit all requests into the free tier limit of AWS (preferably the permanent one, not the 12 months one).

Alternative would be to use AWS lambda periodically (CRON event) only for processing the data, then push the hosting on GitHub pages / GitHub gists by programmatically updating those files remotely. This would also be a nice way of making GitHub host their own feed by serving static files. 🙂

We can also do both, to spread the load. But premature optimization is a slippery slope to stop doing anything at all, so we better skip digging deeper if not needed.

@Smeet97Kathiria
Copy link

@waningflow are both of your urls down?

@Smeet97Kathiria
Copy link

Hi, @pupubird can I route my app https://apps.apple.com/us/app/superrepo/id1517331914 to your site?

@pupubird
Copy link

pupubird commented Nov 2, 2020

Hey @Smeet97Kathiria sure!

@pupubird
Copy link

pupubird commented Nov 2, 2020

Cuz I am using it for the unofficial hackertab huchenme/hacker-tab-extension#55 too, so you are free to use as well

@Smeet97Kathiria
Copy link

@pupubird Thanks

@pupubird
Copy link

pupubird commented Nov 2, 2020

welcome @Smeet97Kathiria

@yvonmanzi
Copy link

Hey hey for anyone that's reading on this, I had been using this library for quite a long time, definitely appreciate your work! @huchenme !

I had also created a self-hosted version of the scraper server ( with AWS lambda function compatible ), https://github.com/pupubird/get-github-trending

And the demo site here https://hackertab.pupubird.com/repositories

All credits go to @huchenme

This looks pretty good! Good work!

@RishabhKodes
Copy link

Guys feel free to use mine! http://192.168.1.33:8000/

Thanks

@Sky24n
Copy link

Sky24n commented Dec 15, 2020

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

No branches or pull requests