[Python] DmarketAPI Error receiving orders: 404, {"Code":"Not Found","Message":"Not Found"}

Discussão em 'Python' iniciado por Stack, Julho 14, 2025.

  1. Stack

    Stack Membro Participativo

    The code automatically retrieves a list of active orders (orders to buy or sell items) from the DMarket platform via their API, and then deletes each of them. It uses your API keys for authorization, creates a signature for a secure request, sends a request to the DMarket server to get a list of orders, and, if there are any, deletes them one by one.

    But after running the code: Error receiving orders: 404, {"Code":"Not Found","Message":"Not Found"}, I checked the DmarketAPI documentation, everything seems to be correct, but the code does not work.

    import time
    import json
    import requests
    from nacl.bindings import crypto_sign

    PUBLIC_KEY = ""
    SECRET_KEY = ""

    ROOT_API_URL = "https://api.dmarket.com"


    def sign_request(method, path, body=""):
    nonce = str(int(time.time()))
    string_to_sign = method + path + body + nonce
    signature = crypto_sign(string_to_sign.encode(),
    bytes.fromhex(SECRET_KEY))[:64].hex()
    headers = {
    "X-Api-Key": PUBLIC_KEY,
    "X-Request-Sign": f"dmar ed25519 {signature}",
    "X-Sign-Date": nonce,
    "Content-Type": "application/json"
    }
    return headers


    def get_user_orders():
    path = "/marketplace-api/v1/user-orders"
    headers = sign_request("GET", path)
    response = requests.get(ROOT_API_URL + path, headers=headers)
    if response.status_code == 200:
    return response.json().get("orders", [])
    else:
    print(
    f"[!] Error receiving orders: {response.status_code}, {response.text}")
    return []


    def delete_order(order_id):
    path = f"/marketplace-api/v1/orders/{order_id}"
    headers = sign_request("DELETE", path)
    response = requests.delete(ROOT_API_URL + path, headers=headers)
    if response.status_code == 200:
    print(f"[-ORDER] Deleted order: {order_id}")
    else:
    print(
    f"[!] Error deleting orders {order_id}: {response.status_code}, {response.text}")


    def main():
    print("\n Getting and deleting orders...")
    orders = get_user_orders()
    if not orders:
    print("No active orders.")
    return
    for order in orders:
    order_id = order.get("orderId")
    if order_id:
    delete_order(order_id)


    if __name__ == "__main__":
    main()

    Continue reading...

Compartilhe esta Página