[Python] ClassMarker API Integration

Discussão em 'Python' iniciado por Stack, Janeiro 25, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to use the ClassMarker API on my website, but I keep getting an apiKeyAuthFail error; the documentation mentions this:

    $your_api_key = 'd4tsE7SvEgzAKlJPFrlvAz3oe9uFQnxy';
    $your_api_secret = 'keepThisSecret';
    $current_unix_timestamp = time();
    $signature = md5($your_api_key . $your_api_secret . $current_unix_timestamp);


    This is what im doing in python:

    def prepare_classmarker_request(apikey, apisecret):
    timestamp = str(int(time.time()))
    signature = hashlib.md5(f"{apikey}{apisecret}{timestamp}".encode()).hexdigest()
    return signature, timestamp


    This is an example they have in their documentation:

    https://api.classmarker.com/v1.json?api_key=XXXX&signature=XXXX&timestamp=XXXX


    This is how im trying to consume it:

    @app.route('/test-auth', methods=['POST','GET'])
    def test_auth():
    signature, timestamp = prepare_classmarker_request(API_KEY, API_SECRET)

    url = f"https://api.classmarker.com/v1.json?apikey={API_KEY}&signature={signature}&timestamp={timestamp}"

    response = requests.get(url)

    if response.status_code == 200:
    tests = response.json()
    return jsonify(tests)
    else:
    return jsonify({
    "message": "Failed to authenticate",
    "status": response.status_code,
    "response": response.json()
    })


    There are not a lot of examples in their website or at least I dint find many... https://www.classmarker.com/docs/ClassMarker-Integration.pdf

    https://www.classmarker.com/online-testing/docs/api/#classmarker-api

    What am I trying to accomplish?

    I am building a website for the user to create quizzes and have the results delivered instantly: speaking, written (grammar), reading and listening. I am looking for APIs or services that can help me with this to avoid building everything from scratch.

    Continue reading...

Compartilhe esta Página