Podcastindex-org / docs-api

Developer documentation for the podcastindex.org api.
https://podcastindex-org.github.io/docs-api/
MIT License
54 stars 29 forks source link

Ratelimiting #30

Open Siebe opened 3 years ago

Siebe commented 3 years ago

So, like I told @daveajones , I found out there's a rate limiting system in place... the hard way :} So thank so much for the warning and plz update docs <3

And also:

As a developer, when I create an service on the API, I would like to be informed on the current status of my requests and limits, so I can avoid hitting that 429 or predict when I am able to send new requests.

Normally this is done through headers, plus some explanation in the documentation on how to interpret these headers. A countdown header and knowing cooldown/reset time would suffice I think. Protip: custom headers usually start with x- and I have a feeling that might help pushing them through Cloudflare.

picard102 commented 5 months ago

What is the rate limit set to and for what period?

cbarlow26 commented 5 months ago

@daveajones said, "You want to keep your requests at less than one per second" (#16 ). Is this per account, per key, or per client?

daveajones commented 5 months ago

We don't publish rate limits because we have no SLA's or guarantees. We are a free project that runs on donations and I don't want everyone pushing their usage right up to the edge of the published rate limits. If everyone does that we can't support the load. We adjust things continuously as needed to support the load we have at the time.

SteveCutler commented 2 months ago

If I hit the rate limit would I start getting a 401 error?

Trying to debug why my authorization suddenly became invalid

daveajones commented 2 months ago

No. A rate limit is a 429. Make sure you are using a proper user agent header and not the ones from the sample code.

SteveCutler commented 2 months ago

No. A rate limit is a 429. Make sure you are using a proper user agent header and not the ones from the sample code.

I think I'm doing everything right, I had it working and then all of a sudden it stopped. This is my request code, I don't know if anything jumps out to you when you look at this:

const headerTime = Math.floor(Date.now() / 1000).toString() const key = import.meta.env.VITE_PODCASTINDEX_KEY const secret = import.meta.env.VITE_PODCASTINDEX_SECRET const hashInput = key + secret + headerTime

        const hash = CryptoJS.SHA1(hashInput).toString(CryptoJS.enc.Hex)

        const episodesResponse = await axios.get(
            `https://api.podcastindex.org/api/1.0/episodes/byfeedid?id=${id}`,
            {
                headers: {
                    'User-Agent': 'AppleMusicDashboard/1.0',
                    'X-Auth-Key': key,
                    'X-Auth-Date': headerTime,
                    Authorization: hash,
                },
                params: {
                    fulltext: true,
                    max: 10,
                },
            }
        )
        console.log('episodes', episodesResponse)

all the variables print out fine when I log them to console, but I'm getting the hash auth error: The hash in the Authorization header doesn't match up. Please check your hash compute code: https://podcastindex-org.github.io/docs-api/#overview--authentication-details

I've tried to test my key/secret out on the docs page but I'm also getting this error there

SteveCutler commented 2 months ago

Resolved by making a new key secret pair. Maybe I didn't copy/paste them correctly last time..