Skip to content

Instantly share code, notes, and snippets.

@pojomi
Last active October 21, 2022 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save pojomi/9537b5448dc2b6b02ca8b9d32d16e577 to your computer and use it in GitHub Desktop.
Save pojomi/9537b5448dc2b6b02ca8b9d32d16e577 to your computer and use it in GitHub Desktop.
Searches warframe.market API for most recent average price scrape, then requests to open warframe.market item page
import urllib.parse as parse
import urllib.request
from urllib.request import urlopen as req_url
import json
import string
import webbrowser
# Search API for most recent average price scrape
def warframe():
print("Search for an item")
search = input()
print("Searching for " + string.capwords(search) + "...")
main_url = req_url('https://api.warframe.market/v1/items/' + search.replace(' ', '_') + '/statistics')
data = main_url.read()
parsed = json.loads(data)
parsed_data = parsed['payload']['statistics']['48hours'][-1]['min_price']
date_time = parsed['payload']['statistics']['48hours'][-1]['datetime']
print(string.capwords(search) + " minimum price is " + str(parsed_data) + " platinum as of " + date_time)
# Request to open search on warframe.market
def browser_open():
print('Would you like to buy/sell ' + string.capwords(search) + "? y/n")
browser_answer = input()
if browser_answer == "y":
webbrowser.open_new('https://warframe.market/items/' + search.replace(' ', '_'))
#if browser_answer == "n":
browser_open()
# Restart the script
def restart_script():
print('Start a new search? y/n')
answer = input()
if answer == "y":
warframe()
if answer == "n":
print('Goodbye')
restart_script()
warframe()
@QuariumStackHS
Copy link

QuariumStackHS commented Jun 30, 2020

hello i have a little probleme:

python .\main.py
Search for an item
frost_prime_blueprint
Searching for Frost_prime_blueprint...
Traceback (most recent call last):
  File ".\main.py", line 41, in <module>
    warframe()
  File ".\main.py", line 14, in warframe
    main_url = req_url('https://api.warframe.market/fr/items/' + search.replace(' ', '_') + '/statistics')
  File "C:\Users\slow\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Users\slow\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "C:\Users\slow\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 640, in http_response
    response = self.parent.error(
  File "C:\Users\slow\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 563, in error
    result = self._call_chain(*args)
  File "C:\Users\slow\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 502, in _call_chain
    result = func(*args)
  File "C:\Users\slow\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 755, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "C:\Users\slow\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "C:\Users\slow\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 640, in http_response
    response = self.parent.error(
  File "C:\Users\slow\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 569, in error
    return self._call_chain(*args)
  File "C:\Users\slow\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 502, in _call_chain
    result = func(*args)
  File "C:\Users\slow\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

@pojomi
Copy link
Author

pojomi commented Jun 30, 2020 via email

@Gamariio
Copy link

Gamariio commented May 7, 2021

Excuse me, don't work for me :/

warframe()
Search for an item

frost prime
Searching for Frost Prime...
Traceback (most recent call last):

File "", line 1, in
warframe()

File "C:\Users\roman.spyder-py3\TestWarframe.py", line 14, in warframe
main_url = req_url('https://api.warframe.market/v1/items/' + search.replace(' ', '_') + '/statistics')

File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\request.py", line 222, in urlopen

File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\request.py", line 531, in open

File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\request.py", line 641, in http_response

File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\request.py", line 563, in error

File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\request.py", line 503, in _call_chain

File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\request.py", line 755, in http_error_302

File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\request.py", line 531, in open

File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\request.py", line 641, in http_response

File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\request.py", line 569, in error

File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\request.py", line 503, in _call_chain

File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\request.py", line 649, in http_error_default

HTTPError: Forbidden

@DragonCoding-Reiko
Copy link

Same Problem here. The API responds with an forbidden. As far as i know the API doesn't allow a call to the statistics. At least there's nothing in the documentation stating it.

@QuariumStackHS
Copy link

look like the API changed a bit since this was build, back then I wanted a discord bot that can help. Lol

@RiahiFedi
Copy link

Since the API changed all you need to replace are these lines:

main_url = req_url('https://api.warframe.market/v1/items/' + search.replace(' ', '_') + '/orders')
data = main_url.read()
parsed = json.loads(data)
parsed_data = parsed['payload']['orders'][-1]['platinum']
date_time = parsed['payload']['orders'][-1]['last_update']

I tested it and it should work fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment