I got a big problem right now...I've recently been working on an nft collection, revealed the collection just a couple of days ago. The metadata was like messed up with wrong indexes taking place on most images. Now, I've already updated and loaded the new metadata to the smart contract. In fact if I go to opensea, and pick an item from the collection, open it, and click on the refresh metadata button, after waiting a few seconds and refreshing the page... The metadata on that item shows to be CORRECT.
The thing is that I just can't go and open each item to refresh it 1 by 1, right?! The collection is a 10'000 piece collection... So I hope you can understand what I mean... It is so frustrating... Opensea shall really give the opportunity to batch refresh don't you think?
Anyway, may you suggest me a script that I can run with python and will run a for loop to refresh these items?
https://api.opensea.io/api/v1//asset/{contract address}/{token_id}/?force_update=true
I know that running this will not work without an API from opensea; I've already submitted a request, but it seems they are busy doing other stuff.... I feel desperate about it; Will the opensea team batch refresh it for me if I ask them to?!
Any advice?! Thank you StackOverflow comunity :)
```python
import requests
import time
endpoint = "https://api.opensea.io/api/v1"
collection_slug = "sparkling-luna"
headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"X-API-KEY": "your_api_key_here"
}
for token_id in range(10000):
url = f"{endpoint}/asset/{collection_slug}/{token_id}/?force_update=true"
response = requests.request("PUT", url, headers=headers)
if response.status_code == 200:
print(f"Refreshed metadata for token {token_id}")
else:
print(f"Failed to refresh metadata for token {token_id}")
time.sleep(1
)
``
I tried to run this script and taking out the headers to try without API... but nothing, seems that the script will work only with an opensea api...Right?