Mojang API

Discussion in 'Programming' started by Mistri, May 29, 2016.

  1. Hi,

    I'm making a simple site that lists all of the available 3 letter MC usernames with PHP, and I've successfully done everything, except for one minor issue.

    When I'm scanning the names, I use the Mojang API, and there is a limit on it (very annoying limit) -- 600 request per 10 minutes, which is 1 per second, and my scanner is faster than that. If I try to scan it, after 600 it will give me an error until the 10 minutes is up. I have tried waiting in between each request, but if I do that, it will take over half a day to scan, and I don't have that kind of time for the site.

    My question is: is there ANY other way to get username information other than the Mojang API (that doesn't have a request limit)? If not, is there any way to bypass this limit? I have a low budget so I can't afford any proxies if that is what you are suggesting (although I'm not familiar with proxies, so I don't know if they cost money -- if it's free, you could suggest it).

  2. kottalizer


    You could use open proxies. A quick search should give you thousands of IP addresses and port numbers to try on. Mind you they're usually very unreliable and may disappear (and reappear) at any time.

    Tldr there's no way you haven't already suggested.
  3. I believe there are also other APIs that use the same feature which may not be rate limited. Those may not be the best things to use since they are community run and may not be the most reliable. Also this is definitely abusing their API, so they may ban you.
  4. foncused

    Moderator Patron

    Do those APIs just use proxies themselves? Just wondering. I also use Mojang's API directly.
  5. I think they use multiple servers (that they own) and a caching system.
  6. Buy a /24 of IP addresses l0l
  7. Well, actually, does Mojang's API support IPv6?

    That could be practical.
  8. When you're finished can I see the website xD
  9. There are tons of other websites that offer such functionality. Just google around and you will find some.
  10. JamesJ


    Maybe just add a 1 second delay between each search? There is no need to be a dick with the API. If they see that people are abusing the API, they'll just look into either harsher rate-limits, new authentication methods or just remove the API.

    Don't abuse it. There are rare limits in reason for a place. Proper caching and efficient searching will prevent you from hitting that rate-limit.
    • Winner Winner x 1
  11. I think the issue for him is that he can't cache it. I agree that you shouldn't be a dick about these things.
  12. Maybe he is looping through all the permutations of <LETTER> <LETTER> <LETTER>
  13. The ones that work all use Mojang's API.

    Anyways, @foncused brought to my attention that I can do 100 names per URL, but it is POST rather than GET, so I'm having a bit of trouble with it. I'll get back to you guys if I figure it out!
  14. They all use the Mojang API, but they also have their own database and multiple IP's, so you're less limited.
  15. Alright, can't figure it out. If anyone's good with PHP, please help me out with this. I'm not the best, this is just a small project for me.

    When I try to use Mojang's POST methods, I get an error.
    Code (Text):

    //set POST variables
    $url = '';
    $fields = array(
        'minecraft' => urlencode("Mistri")

    //url-ify the data for the POST
    foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
    rtrim($fields_string, '&');

    //open connection
    $ch = curl_init();

    //set the url, number of POST vars, POST data
    curl_setopt($ch,CURLOPT_URL, $url);
    curl_setopt($ch,CURLOPT_POST, count($fields));
    curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                      
        'Content-Type: application/json',                                                                            
        'Content-Length: ' . strlen($data_string))                                                              

    //execute post
    $result = curl_exec($ch);

    //close connection

    Code (Text):
    {"error":"IllegalArgumentException","errorMessage":"profileNames is null"}
  16. Nice! I fixed the error
  17. Uh... how?
  18. Sorry for the necro, but if you guys are interested in where this ended up:
    • Like Like x 2
  19. Wow that look awesome! Great job :D
    • Like Like x 1
  20. Thank you! :D