# How do i make a working fetch website block

(This is a template, feel free to delete it.)

What's problem you are encountering?
im trying to make a project to show how much messages you have on scratch, i dont know how to do that
What have you tried that didn't work?
i tried the website used in wit web browser ( like from https://api.allorigins.win/raw?url= )
but it always reported 0 even if the user does not exist
Post a project example, link, or screenshot:
Snap! 6.9.2 Build Your Own Blocks
copied text (api thing):
{"count":0}
copied text (real thing):
{"code":"ResourceNotFound","message":"/users/erererereeeeeeeeeeeeeeeeeeeee/messages/count does not exist"}
(edit: someones custom blocks helped me)

maybe 0 is just the default for nonexistent users. I put in the name griffpatch and it said 1708170.

Could it be the case-insensitivity? I put "WarpedWartWars" (my Scratch username) in and I got 0 even though

Not a solution, but I noticed there was a bit of code that could be made easier. It's the URL [ cors-anywhere.com] block script. Here is a simpler way:

The Scratch message count API returns {"count": 0} when a user with user agents related to automated scripts (like ones starting with "python-" or "curl") visits it.

if you don't know already, you have to go to https://cors-anywhere.herokuapp.com/corsdemo and then click on "Request temporary access to the demo server" before you can use cors-anywhere. I think that may be your problem.

I don't understand that at all.

I think what he or she is saying is that if it detects an automated script then it automatically returns 0.

I got the {count:0} but I don't remember anything automated about my Scratch account.

this is fixed, now i finished making it, but it is delayed to 5 secs because CORS requests are limited to 50 per 60 mins (1 hour)

Not automated Scratch account, an automated script.

I still don't understand. An automated script where?

Here is a Scratch Wiki I made (yes, I made it) explaining how to hack Scratch's cloud variables in Python. Not that I'm telling you to actually follow the tutorial. I just mean something like this is considered an automated script and so if Scratch API detects that, it will return 0. Link: How to Access the Scratch API Using Python 3 - Scratch Wiki

Does that include users that aren't the (I don't know what words to put here)? For example, if someone with an automated script goes to, say, https://api.scratch.mit.edu/users/WarpedWartWars/messages/count, would that say {"count":0} forever?

Did you happen to receive those two messages recently when you checked? Because the API takes a while to update. That is why even after you look at the message it still shows that you haven't.

Yes, but when a non-automated script visits it will be normal.

I'm not sure.

Ok.

It always reports 0 for me even though I have 2 current messages.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.