Skip to content

Shrieked/Unofficial-NameMC-API-Docs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo1

Unofficial NameMC API Documentation made by Faav.
Documentation for https://namemc.com and www.faav.tk/v1/namemc.



Contents


About

I created this API for people who need to use NameMC's database in a automated way.


Limitations

This API scrapes the NameMC website in order to provide accurate responses. If the NameMC layout changes or goes offline, this API will provide inaccurate information or will not function at all. Please keep this in mind while using this API.


Routes


Official NameMC API


Usage Examples

JavaScript:

See it in action

<html>
<head>
	<script>
	var getJSON = function(url, callback) {
	   var xhr = new XMLHttpRequest();
	   xhr.open('GET', url, true);
	   xhr.responseType = 'json';
	   xhr.onload = function() {
	     var status = xhr.status;
	     if (status === 200) {
	       callback(null, xhr.response);
	     } else {
	       callback(status, xhr.response);
	     }
	   };
	   xhr.send();
	};

	getJSON('https://www.faav.tk/v1/namemc/capecount?username=Marc',
	function(err, data) {
	 if (err !== null) {
	   document.getElementById('marc').innerHTML = err;
	 } else {
	   document.getElementById('marc').innerHTML = 'Marc has '+data.formatted+' capes.';
	 }
	});
	</script>
</head>
	<body>
	<p id="marc">Marc has 0 capes.</p>
	</body>
</html>

PHP:

See it in action

<?php 
$namemc_api = json_decode(file_get_contents("https://www.faav.tk/v1/namemc/capecount?username=Marc"), false);
$marcs_capes = $namemc_api -> formatted;
 echo '<p>Marc has '.$marcs_capes." capes.</p>";
?>

Java:

OkHttp & Gson:

public static void main(String[] args) {
	final OkHttpClient okHttpClient = new OkHttpClient();
	final Gson gson = new Gson();

	final Request request = new Request.Builder()
		.url("https://www.faav.tk/v1/namemc/capecount?username=Marc")
		.get()
		.build();

	try (final Response response = okHttpClient.newCall(request).execute()) {
		if (response.isSuccessful()) {
			final JsonObject jsonObject = gson.fromJson(response.body().charStream(), JsonObject.class);
			System.out.printf("Marc has %s capes", jsonObject.get("formatted").getAsString());
		}
	} catch (IOException e) {
		e.printStackTrace();
	}
}

Contributions

Thank you JerreBor (Jero) for the Java usage example, and thank you 88 (lucky swede) for the documentation template.


Disclaimer

This API is not affiliated nor indorsed by NameMC, Minecraft, Mojang, or Microsoft.

About

Unofficial NameMC API Documentation made by Faav#0130. Documentation for https://namemc.com and www.faav.tk/v1/namemc.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%