The endpoint you're using is incorrect, you have to replace state by country in the URL, as explained in the API documention. In your case, the correct URL is:
This is a request for the population of Niger, whose alpha-2 code is
NE. If you were looking for the US state of Nebraska, as far as I know the WorldBank does not provide data about it. In this case, you'd have to look at other sources.
Now, if you're really looking for the data of all countries, downloading a dump as suggested by @IvanBegtin may be the most optimal solution for you and for the World Bank servers (see their recommendations for querying their API: https://datahelpdesk.worldbank.org/knowledgebase/articles/902064-development-best-practices ).
Alternatively, you could query the API for getting the data of all countries, using
all instead of a country code (e.g., https://api.worldbank.org/v2/country/all/indicator/SP.POP.TOTL?date=2021). However, by default the results are limited to 50 by request. So to get all the data, you'll have to run multiple queries or to use the
per_page argument as explained in their documentation (e.g. https://api.worldbank.org/v2/country/all/indicator/SP.POP.TOTL?date=2021&per_page=300 to get 300 results per query). Again, beware of their recommendations for querying the API, to avoid putting too much strain on their servers.