direction_'s blog

By direction_, history, 3 years ago, In English

Is there any way still like I can get basic user information for their codechef profile like handle, contest rating, country Ranking, Globel Ranking, and the total number of questions solved all time?

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
23 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hey, see if this helps- https://codechef-api.vercel.app/{username} replace {username} with your codechef id

  • »
    »
    23 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Thanks

  • »
    »
    21 month(s) ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    It's working.

  • »
    »
    17 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    This is not working now... My codechef handle is jai_kumar30 Could you please resolve the problem in my code? Am I doing something wrong?

    // Fetch CodeChef data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ async function fetchCodechefData() { const url=https: //codechef-api.vercel.app/{jai_kumar30};

    try {
        const response=await fetch(url);
    
        if ( !response.ok) {
            throw new Error(`HTTP error ! status: $$$ { response.status }<br /><br /> '); }<br /><br /> const data=await response.json();<br /><br /> if (data.status==='OK') { const user=data.result; // Adjust based on the actual structure<br /><br /> document.getElementById('codechef-rating').textContent='Rating: $$$ {
                user.rating || 'Unrated'
            }
    
            `;
        }
    
        else {
            throw new Error('Failed to fetch data');
        }
    }
    
    catch (error) {
        console.error('Error:', error);
        const ratingElement=document.getElementById('codechef-rating');
    
        if (ratingElement) {
            ratingElement.textContent='Error fetching rating';
        }
    
        else {
            console.error('Element not found');
        }
    }

    } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    • »
      »
      »
      17 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      @J_A_I_KUMAR i think the error is here:

      in the url you have to replace {username} with your username without the curly braces

      try this: const url=https://codechef-api.vercel.app/jai_kumar30;

»
15 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can there be an API for dead users as well? it will help a lot, as lot of programmers don't give contests upon reaching a desired rating range.

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

The deployment is paused now